{"id":2228533,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2228533/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260426190920.2051289-2-philpem@philpem.me.uk/","project":{"id":13,"url":"http://patchwork.ozlabs.org/api/1.2/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260426190920.2051289-2-philpem@philpem.me.uk>","list_archive_url":null,"date":"2026-04-26T19:09:14","name":"[v3,1/7] ata: libata-scsi: add atapi_max_lun module parameter","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"84fa22356b9ad5c8c93c28a0c9ed67e12e39433b","submitter":{"id":93108,"url":"http://patchwork.ozlabs.org/api/1.2/people/93108/?format=json","name":"Phil Pemberton","email":"philpem@philpem.me.uk"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260426190920.2051289-2-philpem@philpem.me.uk/mbox/","series":[{"id":501551,"url":"http://patchwork.ozlabs.org/api/1.2/series/501551/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/list/?series=501551","date":"2026-04-26T19:09:18","name":"ata: libata-scsi: multi-LUN ATAPI device support","version":3,"mbox":"http://patchwork.ozlabs.org/series/501551/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228533/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228533/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-ide+bounces-5534-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=Pkei29j5;\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-5534-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=\"Pkei29j5\"","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 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3bst714Xz1yHg\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 05:12:02 +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 CD960302E334\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 19:09:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id CC0A237C0FB;\n\tSun, 26 Apr 2026 19:09:37 +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 3E1BB37C112;\n\tSun, 26 Apr 2026 19:09:36 +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 509B8BD366;\n\tSun, 26 Apr 2026 19:09:29 +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 0213D5FBA6;\n\tSun, 26 Apr 2026 20:09:29 +0100 (BST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777230577; cv=none;\n b=Ee12UQnvG0HKEhvuUYQynMfu/9TVnh0cEH6slF01oXUbdMM8gR/j3IzuaNXX6pvkilk0yMiJrZe0K4EYx2OgVM3zOMGx8Wgl/AYugQbLw5Ezk2GXZuRWYiUuWGGmZsZSEWycJyaxzmmcQ3N6qXpRYF8QaPUC+brfujaWSs7tMRg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777230577; c=relaxed/simple;\n\tbh=Ui1185AFfkku0MdzhMjt01W74TSAjdA+/L8qfGI0kN8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=no8bkvgq1wgprVxmtH43Xhu+YtHPMHs1u0lZHSXVYHj7gGH9GPqMKyBnnHbx0Rq6PyQlqndpYTIXKExKs7SbhP4u8+ZWiQ6nQIrcZiT36XBKDpqQcx0kYLP2VDdAN4kdaqP9rMrCnuY9nT9vymK88PLa3gu7+CMsWLS2Z/0YgCE=","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=Pkei29j5; 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=1777230569;\n\tbh=Ui1185AFfkku0MdzhMjt01W74TSAjdA+/L8qfGI0kN8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Pkei29j5i5ZucIfwkkAACnm9l1S1pPwvoyUKla9oyvWTeFXZOgjqL/UvNjqynjGyE\n\t nYke2/RxVlWmc6G7LM9IZ5YkVH5pfWh2r/7nL2DXeNE5tLqB5A8k7YPLFWX6wAN/bK\n\t VoXJJHOZGhYJQ0ZtPE499mEEmkHK+Y37YgVbtk0E=","From":"Phil Pemberton <philpem@philpem.me.uk>","To":"linux-ide@vger.kernel.org,\n\tlinux-scsi@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org,\n\tDamien Le Moal <dlemoal@kernel.org>,\n\tNiklas Cassel <cassel@kernel.org>,\n\t\"James E . J . Bottomley\" <James.Bottomley@HansenPartnership.com>,\n\t\"Martin K . Petersen\" <martin.petersen@oracle.com>,\n\tHannes Reinecke <hare@suse.de>,\n\tPhil Pemberton <philpem@philpem.me.uk>","Subject":"[PATCH v3 1/7] ata: libata-scsi: add atapi_max_lun module parameter","Date":"Sun, 26 Apr 2026 20:09:14 +0100","Message-ID":"<20260426190920.2051289-2-philpem@philpem.me.uk>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260426190920.2051289-1-philpem@philpem.me.uk>","References":"<20260426190920.2051289-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":"Until now libata has hard-coded shost->max_lun = 1 for every ATA host,\nso the SCSI layer never scans past LUN 0.  This blocks support for\nthe small handful of multi-LUN ATAPI devices (Panasonic LF-1195C and\nCOMPAQ PD-1 PD/CD combos export CD on LUN 0 and PD on LUN 1; old\nNakamichi MJ-x.y CD changers expose one LUN per disc slot, up to 7).\n\nIntroduce a libata module parameter, atapi_max_lun, that controls the\nupper bound of the per-host SCSI LUN scan.  Default is 1, preserving\ncurrent behaviour exactly: out-of-the-box only LUN 0 is scanned.\nRange is clamped to 1..ATAPI_MAX_LUN (8, the SCSI-2 ceiling).\n\nSubsequent patches gate actual LUN>0 probing on BLIST_FORCELUN, so a\ndevice must both be on the SCSI device list (or carry the appropriate\nquirk) and run on a host whose atapi_max_lun has been raised before\nany extra LUNs are scanned.\n\nReviewed-by: Hannes Reinecke <hare@suse.de>\nSigned-off-by: Phil Pemberton <philpem@philpem.me.uk>\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(-)","diff":"diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c\nindex 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 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)\");\ndiff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\nindex 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 \ndiff --git a/drivers/ata/libata.h b/drivers/ata/libata.h\nindex 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;\ndiff --git a/include/linux/libata.h b/include/linux/libata.h\nindex 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 \n","prefixes":["v3","1/7"]}