{"id":2221591,"url":"http://patchwork.ozlabs.org/api/1.1/covers/2221591/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/cover/20260409210559.155864-1-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-1-philpem@philpem.me.uk>","date":"2026-04-09T21:05:56","name":"[RFC,0/3] ata: libata-scsi: add multi-LUN support for ATAPI devices","submitter":{"id":93108,"url":"http://patchwork.ozlabs.org/api/1.1/people/93108/?format=json","name":"Phil Pemberton","email":"philpem@philpem.me.uk"},"mbox":"http://patchwork.ozlabs.org/project/linux-ide/cover/20260409210559.155864-1-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/covers/2221591/comments/","headers":{"Return-Path":"\n <linux-ide+bounces-5468-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=iGTExLeU;\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-5468-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=\"iGTExLeU\"","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\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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsCDp6j3Dz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 07:07:22 +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 CAA55302DB69\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  9 Apr 2026 21:06:18 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id CE6CB37A488;\n\tThu,  9 Apr 2026 21:06:13 +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 40A2F329E55;\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 BA1C0BE5E3;\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 357115F938;\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=1775768773; cv=none;\n b=qw0qaB+UBEGXBhJXGRSfAiGgavz+hqoZsJJcUOI9BofBwXBJVYC7NTJArYI+AuOr+bRVPy1umAQ880k7xUnZS68mO6lJ4mpXDtMvpXdcErF//1oyYtCy3J/tawhuOk3sZNQdpTcoCtdgnj5JtosJFzJEIIUOFfomA9ZhKAFeQdU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775768773; c=relaxed/simple;\n\tbh=LZRSc3ws+hA05ffZ6eP+5ye0375utWSgNdrh2BPpoJc=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=p2Ws9qhORau6gDaAo0c8zZ/7fF5HyjAy7vG/BaWZIU+Kydwiqo3tePsHQRnvLMJZAB0SBA+l8bWZflEDr2+27wwfeoFTHXlbSHlgsR5fYC4sn3YrVBubpthl6hJh6swHEy62HwKduLaA76iJy3Hv+YUFHHaMFNVNvyPvJW1AQis=","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=iGTExLeU; 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=LZRSc3ws+hA05ffZ6eP+5ye0375utWSgNdrh2BPpoJc=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=iGTExLeUZq+A93RNKCI+2BlCNJQtmCzJhV8WlRLaK7iZIiR8MCuMhLStSg5X07fa+\n\t 8aZyxN4pxkHHgrxIc9pZ3AY9W+xKVswr81/hNCTvfr7RP/ih3q7jzaA89Lg4X6xLMT\n\t /hI8iKlY6cwUc+zqiJGIU0erDxjdrKOjOZqfUHI0=","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":"[RFC PATCH 0/3] ata: libata-scsi: add multi-LUN support for ATAPI\n devices","Date":"Thu,  9 Apr 2026 22:05:56 +0100","Message-ID":"<20260409210559.155864-1-philpem@philpem.me.uk>","X-Mailer":"git-send-email 2.43.0","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":"Hi all,\n\nThis series gives libata support for ATAPI devices with multiple LUNs,\nsuch as the Panasonic PD-1 PD/CD combo drive. This exposes both the\nCD-ROM and rewritable PD optical interfaces: CD-ROM as LUN 0 and PD\nas LUN 1.\n\nlibata has never supported multi-LUN ATAPI. This series adds support\nby fixing the following limitations:\n\n  1. shost->max_lun is hardcoded to 1 in ata_scsi_add_hosts(), preventing\n     the SCSI layer from probing any LUN beyond 0.\n\n  2. __ata_scsi_find_dev() rejects all commands where scsidev->lun != 0,\n     returning NULL and resulting in DID_BAD_TARGET.\n\n  3. The SCSI-2 CDB LUN field (byte 1, bits 7:5) is never populated.\n     ATAPI tunnels SCSI commands over the ATA PACKET interface, and the\n     transport-layer LUN addressing used by SPC-3+ is not available.\n     Older multi-LUN ATAPI devices rely on this CDB field to route\n     commands to the correct LUN.\n\n  4. ata_scsi_scan_host() only calls __scsi_add_device() for LUN 0,\n     never probing additional LUNs even when the SCSI device info table\n     would indicate the device supports them.\n\n  5. ata_scsi_dev_config() assigned dev->sdev for every LUN, and\n     ata_scsi_sdev_destroy() tore down the entire ATA device whenever\n     any sdev was destroyed -- so removing a spurious LUN result during\n     scanning would kill the whole port.\n\nThe series is split as:\n\n  1/3: scsi_devinfo: add the COMPAQ-branded variant of the PD-1 to the\n       device info table.  An entry already exists for the Panasonic\n       OEM-branded \"MATSHITA PD-1\" and the NEC \"NEC PD-1 ODX654P\".\n\n  2/3: libata-scsi: raise max_lun, route non-zero LUNs to the same\n       ata_device for ATAPI, encode the LUN in CDB byte 1, and fix the\n       slave_configure/slave_destroy callbacks to track LUN 0 only.\n\n  3/3: libata-scsi: probe additional LUNs in ata_scsi_scan_host() for\n       ATAPI devices flagged BLIST_FORCELUN, stopping at PDT 0x1f.\n\nTested on a Panasonic LF-1195C PD/CD (Compaq branded) attached to an\nata_piix host on i686. The CD-ROM enumerates as an 'sr' device and\nthe PD side enumerates as an 'sd' block device. Both LUNs work for I/O:\nthe CD reads correctly, and the PD drive can be partitioned, formatted\nand mounted. An iHAS124 DVD writer on the same machine (single-LUN, no\nBLIST_FORCELUN entry) is unaffected: it does not enter the multi-LUN\nprobing path.\n\nIf the iHAS124 is scanned regardless, it seems to ignore the LUN\nparameter, and enumerates as eight drives. I expect most standard ATAPI\ndevices would behave this way, hence the BLIST_FORCELUN gate.\n\nThe \"PDT 0x1f\" check is based on the behaviour of the Panasonic PD/CD\ndrive: when an unrecognised LUN is probed, it responds with SCSI\nperipheral device type 0x1F (no device).\n\nAll testing was done on kernel 7.0.0-rc7+.\n\nThis is marked RFC because:\n\n  - The CDB-byte-1 LUN encoding is a SCSI-2-era convention that may\n    affect well-behaved modern devices in unexpected ways.  It is\n    currently applied to all non-zero LUN commands on ATAPI devices;\n    a more conservative approach would gate it on a quirk flag.\n\n  - The blast radius of changing __ata_scsi_find_dev() and the slave\n    callbacks deserves wider review, even though all changes are\n    conditional on dev->class == ATA_DEV_ATAPI or sdev->lun == 0.\n\n  - I do not have other multi-LUN ATAPI hardware to test against.\n\nComments and suggestions welcome.\n\nPhil Pemberton (3):\n  scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk\n  ata: libata-scsi: enable multi-LUN support for ATAPI devices\n  ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices\n\n drivers/ata/libata-scsi.c   | 67 ++++++++++++++++++++++++++++++++++---\n drivers/scsi/scsi_devinfo.c |  1 +\n 2 files changed, 64 insertions(+), 4 deletions(-)\n\n--\n2.39.5"}