{"id":2221590,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221590/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260409210559.155864-4-philpem@philpem.me.uk/","project":{"id":13,"url":"http://patchwork.ozlabs.org/api/1.1/projects/13/?format=json","name":"Linux IDE development","link_name":"linux-ide","list_id":"linux-ide.vger.kernel.org","list_email":"linux-ide@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260409210559.155864-4-philpem@philpem.me.uk>","date":"2026-04-09T21:05:59","name":"[3/3] ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ea62334e71636b1db6ee67b51befb8621bf3276c","submitter":{"id":93108,"url":"http://patchwork.ozlabs.org/api/1.1/people/93108/?format=json","name":"Phil Pemberton","email":"philpem@philpem.me.uk"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260409210559.155864-4-philpem@philpem.me.uk/mbox/","series":[{"id":499361,"url":"http://patchwork.ozlabs.org/api/1.1/series/499361/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/list/?series=499361","date":"2026-04-09T21:05:58","name":"ata: libata-scsi: add multi-LUN support for ATAPI devices","version":1,"mbox":"http://patchwork.ozlabs.org/series/499361/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221590/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221590/checks/","tags":{},"headers":{"Return-Path":"\n <linux-ide+bounces-5467-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 (1024-bit key;\n unprotected) header.d=philpem.me.uk header.i=@philpem.me.uk\n header.a=rsa-sha256 header.s=mail header.b=ftTqES+2;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-ide+bounces-5467-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=philpem.me.uk header.i=@philpem.me.uk\n header.b=\"ftTqES+2\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=178.62.38.78","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=philpem.me.uk","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=philpem.me.uk"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\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 4fsCCh6bY5z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 07:06:24 +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 191243017030\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  9 Apr 2026 21:06:14 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 267C1371D08;\n\tThu,  9 Apr 2026 21:06:12 +0000 (UTC)","from nick.sneptech.io (nick.sneptech.io [178.62.38.78])\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 409B8324B2D;\n\tThu,  9 Apr 2026 21:06:10 +0000 (UTC)","from wolf.philpem.me.uk (81-187-163-148.ip4.reverse-dns.uk\n [81.187.163.148])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\t(Authenticated sender: mailrelay_wolf@philpem.me.uk)\n\tby nick.sneptech.io (Postfix) with ESMTPSA id B1651BE599;\n\tThu,  9 Apr 2026 21:06:08 +0000 (UTC)","from cheetah.homenet.philpem.me.uk (cheetah.homenet.philpem.me.uk\n [10.0.0.32])\n\tby wolf.philpem.me.uk (Postfix) with ESMTPSA id 66FB05FC52;\n\tThu,  9 Apr 2026 22:06:08 +0100 (BST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775768772; cv=none;\n b=HWjZV7cgtcdTHIHIzJSXiFx5dLb28G23HhC7DTc35xh4Qug7DuMgUVj2JCAznsajZH9PX6HEqbfy4CWKIJa5PIWxn52jSrhEkV6rvwaV30wGtPX4b7XWT7K8sTCy18Cn+lPhhLqcY/DvJi/WousvSKt5j7hAyQQkfZLVz4OWXPo=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775768772; c=relaxed/simple;\n\tbh=MlOIDuUdpcyW/0eVakGVWxRBBujqmvqNJ1Tze0LcJ9s=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=RGGezC24OT7tk/K0WNTKqOwnoEF+CcxcTbygRXUYB26uxArFohyK3FFOkNCV1SdXxPtDmgW8S3FEF6qKjQ41H8gS1XDrhSTcYkd2ZzOAS44utWOnCqcWWo5pFpITrBr1po5Gy7t2YiZfn4fjQmJb9xMMSqPHcmM8W2O0x6FloMQ=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=philpem.me.uk;\n spf=pass smtp.mailfrom=philpem.me.uk;\n dkim=pass (1024-bit key) header.d=philpem.me.uk header.i=@philpem.me.uk\n header.b=ftTqES+2; arc=none smtp.client-ip=178.62.38.78","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=philpem.me.uk;\n\ts=mail; t=1775768768;\n\tbh=MlOIDuUdpcyW/0eVakGVWxRBBujqmvqNJ1Tze0LcJ9s=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ftTqES+2Not+gEuuu3vOrfk6vfc3c25AxbDSOhl9c0RT0L1/TqQxIXaUwNp2jFRrT\n\t g+pbguHiVr0gs721OKrIjKfwvwLtEUNQzqFTl7n98TIkhVgQof1vb/Nh1E/AhZc8uB\n\t TvmRf4mLSiSzRq4nIu+jFzt2XlHJXn/QJY8BS6zA=","From":"Phil Pemberton <philpem@philpem.me.uk>","To":"dlemoal@kernel.org,\n\tcassel@kernel.org,\n\tJames.Bottomley@HansenPartnership.com,\n\tmartin.petersen@oracle.com","Cc":"linux-ide@vger.kernel.org,\n\tlinux-scsi@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tPhil Pemberton <philpem@philpem.me.uk>","Subject":"[PATCH 3/3] ata: libata-scsi: probe additional LUNs for multi-LUN\n ATAPI devices","Date":"Thu,  9 Apr 2026 22:05:59 +0100","Message-ID":"<20260409210559.155864-4-philpem@philpem.me.uk>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260409210559.155864-1-philpem@philpem.me.uk>","References":"<20260409210559.155864-1-philpem@philpem.me.uk>","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","Content-Transfer-Encoding":"8bit"},"content":"Some ATAPI devices (e.g. the Panasonic PD/CD combo drives) implement\nmultiple logical units. For instance the aforementioned PD/CD has a CD\ndrive on LUN 0 and the rewritable Phase-change Dual (PD) block device on\nLUN 1.\n\nata_scsi_scan_host() previously only scanned LUN 0 via\n__scsi_add_device(). With the multi-LUN work now in place, extend this\nscan to probe for additional LUNs on devices which have BLIST_FORCELUN\nset in the SCSI device info table.\n\nScanning stops when __scsi_add_device() fails, or the device reports\ndevice type 0x1f (unknown or no device type). The PD drive returns this\nfor unimplemented LUNs.\n\nThe aforementioned BLIST_FORCELUN guard prevents non-multilun devices\nfrom being affected.\n\nTested with a Panasonic LF-1195C PD/CD with Compaq firmware, which now\ncorrectly enumerates as a CD drive (sr) and PD optical drive (sd).\n\nAlso tested with a LITE-ON iHAS124 DVD drive, which has a single LUN and\nignores the LUN parameter in the CDB. As a result, without the\nBLIST_FORCELUN guard, this drive would pop up as eight separate devices.\n\nAssisted-by: Claude:claude-opus-4-6\nSigned-off-by: Phil Pemberton <philpem@philpem.me.uk>\n---\n drivers/ata/libata-scsi.c | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)","diff":"diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\nindex 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 \t\t\t\tscsi_device_put(sdev);\n \t\t\t} else {\n \t\t\t\tdev->sdev = NULL;\n","prefixes":["3/3"]}