[{"id":3682444,"web_url":"http://patchwork.ozlabs.org/comment/3682444/","msgid":"<401b8b4a-4787-4f70-b531-0c1ddc04f86b@kernel.org>","list_archive_url":null,"date":"2026-04-26T23:14:36","subject":"Re: [PATCH v3 1/7] ata: libata-scsi: add atapi_max_lun module\n parameter","submitter":{"id":86188,"url":"http://patchwork.ozlabs.org/api/people/86188/","name":"Damien Le Moal","email":"dlemoal@kernel.org"},"content":"On 4/27/26 4:09 AM, Phil Pemberton wrote:\n> Until now libata has hard-coded shost->max_lun = 1 for every ATA host,\n> so the SCSI layer never scans past LUN 0.  This blocks support for\n> the small handful of multi-LUN ATAPI devices (Panasonic LF-1195C and\n> COMPAQ PD-1 PD/CD combos export CD on LUN 0 and PD on LUN 1; old\n> Nakamichi MJ-x.y CD changers expose one LUN per disc slot, up to 7).\n> \n> Introduce a libata module parameter, atapi_max_lun, that controls the\n> upper bound of the per-host SCSI LUN scan.  Default is 1, preserving\n> current behaviour exactly: out-of-the-box only LUN 0 is scanned.\n> Range is clamped to 1..ATAPI_MAX_LUN (8, the SCSI-2 ceiling).\n> \n> Subsequent patches gate actual LUN>0 probing on BLIST_FORCELUN, so a\n> device must both be on the SCSI device list (or carry the appropriate\n> quirk) and run on a host whose atapi_max_lun has been raised before\n> any extra LUNs are scanned.\n> \n> Reviewed-by: Hannes Reinecke <hare@suse.de>\n> Signed-off-by: Phil Pemberton <philpem@philpem.me.uk>\n\nThis looks OK to me, but I would prefer renaming things a little:\n\natapi_max_lun -> atapi_max_nr_luns\n\nto avoid confusion between the maximum LUN ID and the maximum number of LUNs\n(yeah, they are only off by one, but better be clear to not trip on that).\n\nOne additional nit below.\n\nWith that fixed, feel free to add:\n\nReviewed-by: Damien Le Moal <dlemoal@kernel.org>\n\n> ---\n>  drivers/ata/libata-core.c | 5 +++++\n>  drivers/ata/libata-scsi.c | 2 +-\n>  drivers/ata/libata.h      | 1 +\n>  include/linux/libata.h    | 1 +\n>  4 files changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c\n> index 374993031895..8c279b6eb1fb 100644\n> --- a/drivers/ata/libata-core.c\n> +++ b/drivers/ata/libata-core.c\n> @@ -122,6 +122,11 @@ int atapi_passthru16 = 1;\n>  module_param(atapi_passthru16, int, 0444);\n>  MODULE_PARM_DESC(atapi_passthru16, \"Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])\");\n>  \n> +int atapi_max_lun = 1;\n> +module_param(atapi_max_lun, int, 0444);\n> +MODULE_PARM_DESC(atapi_max_lun,\n> +\t\"Maximum LUN to scan on ATAPI devices flagged BLIST_FORCELUN (1 [default] .. 7)\");\n\n\t\"Maximum number of LUNs to scan on ATAPI devices flagged \"\n\t\"with BLIST_FORCELUN (1 [default] .. 7)\");\n\n> +\n>  int libata_fua = 0;\n>  module_param_named(fua, libata_fua, int, 0444);\n>  MODULE_PARM_DESC(fua, \"FUA support (0=off [default], 1=on)\");\n> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\n> index 3b65df914ebb..d1665305b552 100644\n> --- a/drivers/ata/libata-scsi.c\n> +++ b/drivers/ata/libata-scsi.c\n> @@ -4620,7 +4620,7 @@ int ata_scsi_add_hosts(struct ata_host *host, const struct scsi_host_template *s\n>  \t\tshost->transportt = ata_scsi_transport_template;\n>  \t\tshost->unique_id = ap->print_id;\n>  \t\tshost->max_id = 16;\n> -\t\tshost->max_lun = 1;\n> +\t\tshost->max_lun = clamp(atapi_max_lun, 1, ATAPI_MAX_LUN);\n>  \t\tshost->max_channel = 1;\n>  \t\tshost->max_cmd_len = 32;\n>  \n> diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h\n> index b5423b6e97de..96d804d02b99 100644\n> --- a/drivers/ata/libata.h\n> +++ b/drivers/ata/libata.h\n> @@ -33,6 +33,7 @@ enum {\n>  #define ATA_PORT_TYPE_NAME\t\"ata_port\"\n>  \n>  extern int atapi_passthru16;\n> +extern int atapi_max_lun;\n>  extern int libata_fua;\n>  extern int libata_noacpi;\n>  extern int libata_allow_tpm;\n> diff --git a/include/linux/libata.h b/include/linux/libata.h\n> index 00346ce3af5e..27b11577826e 100644\n> --- a/include/linux/libata.h\n> +++ b/include/linux/libata.h\n> @@ -131,6 +131,7 @@ enum {\n>  \tATA_SHORT_PAUSE\t\t= 16,\n>  \n>  \tATAPI_MAX_DRAIN\t\t= 16 << 10,\n> +\tATAPI_MAX_LUN\t\t= 8,\t/* SCSI-2 cap (LUN values 0..7) */\n>  \n>  \tATA_ALL_DEVICES\t\t= (1 << ATA_MAX_DEVICES) - 1,\n>","headers":{"Return-Path":"\n <linux-ide+bounces-5542-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ide@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=SWq5jeI7;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ide+bounces-5542-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"SWq5jeI7\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3jG24WgDz1yJX\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 09:14:50 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 337A6300A388\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 23:14:46 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3623A310652;\n\tSun, 26 Apr 2026 23:14:45 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 10E6130FF26;\n\tSun, 26 Apr 2026 23:14:44 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 96729C2BCAF;\n\tSun, 26 Apr 2026 23:14:43 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777245285; cv=none;\n b=EOc5GbgULq/e6eskh3/XjEL4BlJ87UkqMZIXkhbIQz2QtAVFbDwrLkbuZka1tu6vz3uD7feLWVV5r77owqgTIxD9CzuMW2fcIGzKVIHLF35Oz+tL93VlUyr9SVQQNFAWLoWoowoyCCDp3tKDQ+cDDMX6oP7DO5Dod/Fv+H/axsQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777245285; c=relaxed/simple;\n\tbh=fNSO0ZiQYKIxczq5E447tSJrJsB+pPyxyTsjeRVyg24=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=jHlKz2m/EJsZzaZJeRIr3cGnA2hYzSz/IgNMVd0qy9KVm9/uw16VxvHuR4OVwItKZ5a+SETllaDOr6JMeFO1ItUnK3ZcNC7yTET/SmnqMLyS2/vlCrX7PbQRgq7QOCwYMWdZuLhmjaWzFJGbeoy7QlhBtsqscCd52GjYwqQJdzA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=SWq5jeI7; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777245284;\n\tbh=fNSO0ZiQYKIxczq5E447tSJrJsB+pPyxyTsjeRVyg24=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=SWq5jeI7JhgG4vS+sXVmnpYtn6b+4shQZY0inklzt5G2xq7Y0UH7Y4tmMlOoz8AT6\n\t 6vjEu6+GGRUL7Z33WgaL+ByDzD3SEfKktwB0zFmC4QpgpePq3pPZZtXb/GuEuvd++y\n\t x75ydyvaLFAMpVIuyVKYaU6l5KI21t7RabC2Bo7d/QJf9aO9Fj8VrI9V6FuJ8hwwaO\n\t kkpnLa1Ti4o7zfq930L5oykzUGlJBpdIvfVvJ4KZCuGdK27t1ewpZmLVeysIPp0SoU\n\t a4YCTRPrZJesbmX3JQDikY2M8EuOIwUedi4CL+4S1ANXLh1WItSAXtIBIedS+sZTbl\n\t 12raIKaWdT9rg==","Message-ID":"<401b8b4a-4787-4f70-b531-0c1ddc04f86b@kernel.org>","Date":"Mon, 27 Apr 2026 08:14:36 +0900","Precedence":"bulk","X-Mailing-List":"linux-ide@vger.kernel.org","List-Id":"<linux-ide.vger.kernel.org>","List-Subscribe":"<mailto:linux-ide+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ide+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 1/7] ata: libata-scsi: add atapi_max_lun module\n parameter","To":"Phil Pemberton <philpem@philpem.me.uk>, linux-ide@vger.kernel.org,\n linux-scsi@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, Niklas Cassel <cassel@kernel.org>,\n \"James E . J . Bottomley\" <James.Bottomley@HansenPartnership.com>,\n \"Martin K . Petersen\" <martin.petersen@oracle.com>,\n Hannes Reinecke <hare@suse.de>","References":"<20260426190920.2051289-1-philpem@philpem.me.uk>\n <20260426190920.2051289-2-philpem@philpem.me.uk>","Content-Language":"en-US","From":"Damien Le Moal <dlemoal@kernel.org>","Organization":"Western Digital Research","In-Reply-To":"<20260426190920.2051289-2-philpem@philpem.me.uk>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit"}}]