[{"id":3676245,"web_url":"http://patchwork.ozlabs.org/comment/3676245/","msgid":"<2eee9241-8910-431a-9305-b5919937c826@kernel.org>","list_archive_url":null,"date":"2026-04-12T07:41:07","subject":"Re: [PATCH 3/3] ata: libata-scsi: probe additional LUNs for multi-LUN\n ATAPI devices","submitter":{"id":86188,"url":"http://patchwork.ozlabs.org/api/people/86188/","name":"Damien Le Moal","email":"dlemoal@kernel.org"},"content":"On 4/9/26 23:05, Phil Pemberton wrote:\n> Some ATAPI devices (e.g. the Panasonic PD/CD combo drives) implement\n> multiple logical units. For instance the aforementioned PD/CD has a CD\n> drive on LUN 0 and the rewritable Phase-change Dual (PD) block device on\n> LUN 1.\n> \n> ata_scsi_scan_host() previously only scanned LUN 0 via\n> __scsi_add_device(). With the multi-LUN work now in place, extend this\n> scan to probe for additional LUNs on devices which have BLIST_FORCELUN\n> set in the SCSI device info table.\n> \n> Scanning stops when __scsi_add_device() fails, or the device reports\n> device type 0x1f (unknown or no device type). The PD drive returns this\n> for unimplemented LUNs.\n> \n> The aforementioned BLIST_FORCELUN guard prevents non-multilun devices\n> from being affected.\n> \n> Tested with a Panasonic LF-1195C PD/CD with Compaq firmware, which now\n> correctly enumerates as a CD drive (sr) and PD optical drive (sd).\n> \n> Also tested with a LITE-ON iHAS124 DVD drive, which has a single LUN and\n> ignores the LUN parameter in the CDB. As a result, without the\n> BLIST_FORCELUN guard, this drive would pop up as eight separate devices.\n> \n> Assisted-by: Claude:claude-opus-4-6\n> Signed-off-by: Phil Pemberton <philpem@philpem.me.uk>\n> ---\n>  drivers/ata/libata-scsi.c | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n> \n> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\n> index dc6829e60fb3..0a7ce44118fe 100644\n> --- a/drivers/ata/libata-scsi.c\n> +++ b/drivers/ata/libata-scsi.c\n> @@ -4732,6 +4732,35 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)\n>  \t\t\tif (!IS_ERR(sdev)) {\n>  \t\t\t\tdev->sdev = sdev;\n>  \t\t\t\tata_scsi_assign_ofnode(dev, ap);\n> +\t\t\t\t/*\n> +\t\t\t\t * Multi-LUN ATAPI devices (e.g. PD/CD combo\n> +\t\t\t\t * drives) are flagged BLIST_FORCELUN in\n> +\t\t\t\t * scsi_devinfo.  Probe additional LUNs when\n> +\t\t\t\t * the flag is set.\n> +\t\t\t\t */\n> +\t\t\t\tif (dev->class == ATA_DEV_ATAPI &&\n> +\t\t\t\t    (sdev->sdev_bflags & BLIST_FORCELUN)) {\n> +\t\t\t\t\tu64 lun;\n> +\n> +\t\t\t\t\tfor (lun = 1; lun < ap->scsi_host->max_lun;\n> +\t\t\t\t\t     lun++) {\n> +\t\t\t\t\t\tstruct scsi_device *extra;\n> +\n> +\t\t\t\t\t\textra = __scsi_add_device(\n> +\t\t\t\t\t\t\tap->scsi_host,\n> +\t\t\t\t\t\t\tchannel, id, lun,\n> +\t\t\t\t\t\t\tNULL);\n> +\t\t\t\t\t\tif (IS_ERR(extra))\n> +\t\t\t\t\t\t\tbreak;\n> +\t\t\t\t\t\t/* PDT 0x1f: no device type */\n> +\t\t\t\t\t\tif (extra->type == 0x1f) {\n> +\t\t\t\t\t\t\tscsi_remove_device(extra);\n> +\t\t\t\t\t\t\tscsi_device_put(extra);\n> +\t\t\t\t\t\t\tbreak;\n> +\t\t\t\t\t\t}\n> +\t\t\t\t\t\tscsi_device_put(extra);\n> +\t\t\t\t\t}\n> +\t\t\t\t}\n\nIt would be a lot nicer and more readable to have this hunk as a helper\nfunction, e.g.: ata_scsi_scan_atapi_luns().\n\n>  \t\t\t\tscsi_device_put(sdev);\n>  \t\t\t} else {\n>  \t\t\t\tdev->sdev = NULL;","headers":{"Return-Path":"\n <linux-ide+bounces-5475-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=BI9rAeLY;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-ide+bounces-5475-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=\"BI9rAeLY\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\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 4ftjCK5s0Rz1yCx\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 17:41:17 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 7103D3006440\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 12 Apr 2026 07:41:14 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 820973033E8;\n\tSun, 12 Apr 2026 07:41:11 +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 5E92642AA9;\n\tSun, 12 Apr 2026 07:41:11 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 1D3ECC19424;\n\tSun, 12 Apr 2026 07:41:08 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775979671; cv=none;\n b=fSpin9cQJc5sSo+OJBrd3qQBEf7NJybpyyRSKX5wc5x3ej8HM6iXmpyU4COCXnhF8I1z0ZMKzG5TbPcJNTkC21GJnPsSdilv02jLsjpCD0MQuqZ0CqTdAzy74YQmTdPlg7JCM4FW4pXm2wmTvhcwXc5Ut0b2LwM9ameugtZjpbo=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775979671; c=relaxed/simple;\n\tbh=t+fxPRduy+kLlBrpzBK0AZzm4tYLYBcjiNRxQEXXe94=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=WHZJpBvYtng13HMkpnF03wwNaPdBCRz+lhe5VPoha19mRtuNJjti/FQaBRuuZziZDJRBvY/MaBK1WLJ6H72d6Vr4G4nJTaC6bZSx2yA0eiGVA+cVS1nYv51PUcl4if42c1r7frf9U5S2HaSNqDBNICKp+y+5nJqCUyifk7EfgPk=","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=BI9rAeLY; 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=1775979671;\n\tbh=t+fxPRduy+kLlBrpzBK0AZzm4tYLYBcjiNRxQEXXe94=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=BI9rAeLY2FdRh42ALHbBG+mcxSQe8VZ6F1KV7CJ2MnhmKdcRU7wDWT8PGKd4DFYkj\n\t OkTWdzwm+ZjF2KX2WNYetttKY5KNmNU7fVql50PZ+h4w2P2WRV+6ZXxoyp5dBnoHEy\n\t R1rlxT0zgxwh6GUC4dKTgar0tJm7MFq3z8gSSMwpSWbBUMLjhBYx6PSTN02clomA5k\n\t UEkwZZx/IXq2sIQPjhkBzfla1YZW3LYEKobbSP/UKu3r+S4rktR/S+XmxFI77K00SD\n\t GIEpE/uvyjIDu3//NJvtMZltfhme7MeEvAZgVldIvVQoacsFCjZJM+2UO/K1ugQ/FR\n\t xMmYUnIHUP25Q==","Message-ID":"<2eee9241-8910-431a-9305-b5919937c826@kernel.org>","Date":"Sun, 12 Apr 2026 09:41:07 +0200","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 3/3] ata: libata-scsi: probe additional LUNs for multi-LUN\n ATAPI devices","To":"Phil Pemberton <philpem@philpem.me.uk>, cassel@kernel.org,\n James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com","Cc":"linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,\n linux-kernel@vger.kernel.org","References":"<20260409210559.155864-1-philpem@philpem.me.uk>\n <20260409210559.155864-4-philpem@philpem.me.uk>","Content-Language":"en-US","From":"Damien Le Moal <dlemoal@kernel.org>","Organization":"Western Digital Research","In-Reply-To":"<20260409210559.155864-4-philpem@philpem.me.uk>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit"}}]