Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v9 00/11] ata: add multi-LUN support for ATAPI devices
@ 2026-10-06 23:41 Phil Pemberton
  2026-10-06 23:41 ` [PATCH v9 01/11] ata: libata-core: pin SCSI devices during port detach Phil Pemberton
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Phil Pemberton @ 2026-10-06 23:41 UTC (permalink / raw)
  To: linux-ide, linux-scsi
  Cc: linux-kernel, Damien Le Moal, Niklas Cassel,
	James E . J . Bottomley, Martin K . Petersen, Hannes Reinecke,
	Phil Pemberton

This series adds support for multi-LUN ATAPI devices, including the
Panasonic/COMPAQ PD/CD drives. These expose the CD-ROM on LUN 0 and the
PD drive on LUN 1. libata currently scans only LUN 0.

It also fixes stale CD capacity after swapping between PD and CD media.

Patches 1-3 fix existing bugs in device removal, power management and
quirk matching. Patches 4-5 fix sr's initial block size and handling of
media changes. Patches 6-11 add the multi-LUN support.

Set libata.atapi_max_lun=8 to scan LUNs 0-7 on devices with BLIST_FORCELUN.
The default is 1 (LUN 0 only). A manual scan can restore a deleted LUN.

Changes since v8 (Sashiko's reviews and local review):
- Rebased onto mainline and split out the three upstream fixes as 1-3.
- 4: set sr's initial block size when the medium is unavailable. Check
  for ready media first so 512-byte media keep the correct queue limits.
- 5: retry incomplete revalidation on the next open. If the drive reports
  NOT READY / 04 / 01 during revalidation, fail the blocking open and
  leave revalidation pending for the next attempt.
- 7: release rescan references outside the spinlock, continue scanning
  other LUNs when one needs a retry, and reject invalid LUN numbers.
- 7, 10: use the referenced SCSI device when assigning the OF node.
- 8: preserve CDB byte 1 for LUN 0, check the SCSI-2 LUN limit, and request
  sense from the LUN whose command failed. Allow device removal to find
  the ATA device after error handling changes its class.
- 9: separate the scan flag from bitfields updated during I/O.
- 10: support wildcard and targeted user scans of missing secondary LUNs.

Patches 8 and 10 also fix bugs introduced in earlier versions of this
series. I've kept the review tags on 6 and 11 and removed them from the
revised patches 7-10.

Hardware testing on a COMPAQ PD-1 LF-1195C (firmware A110), i686:
- Boot with PD inserted, replace it with a CD, then mount: successful.
- Reinsert a CD and mount immediately during spin-up: the early mount
  reported no medium; a later mount succeeded without ejecting or
  rescanning, with the correct geometry and readable files.
- CD A -> PD -> CD B: mount succeeded and capacity grew from 262704 to
  1311404 512-byte sectors; logical block size remained 2048 bytes.
- CD B's final logical block (LBA 327850) was read successfully, beyond
  CD A's former capacity.
- CD B -> PD -> CD A: reported capacity returned to 262704 sectors with
  2048-byte logical blocks.

Known limitations:
- Capacity and block size are refreshed when the device is opened. The
  sysfs values can remain stale until then.
- READ CAPACITY failures can still leave stale capacity. The existing
  fallback for audio CDs and older drives is unchanged.

The patches carry Assisted-by: LLM.

v8: https://lore.kernel.org/linux-ide/20260731213503.2379771-1-philpem@philpem.me.uk/

Phil Pemberton (11):
  ata: libata-core: pin SCSI devices during port detach
  ata: libata-zpodd: reference SCSI devices in PM callbacks
  scsi: scsi_devinfo: preserve full-width quirk identifiers
  scsi: sr: initialize logical block size before registering the disk
  scsi: sr: retry unfinished media revalidation on the next open
  ata: libata-scsi: add atapi_max_lun module parameter
  ata: libata-scsi: convert dev->sdev to per-LUN array
  ata: libata-scsi: route non-zero LUN commands for multi-LUN ATAPI
  scsi: add BLIST_NO_LUN_1F blacklist flag
  ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices
  scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk

 drivers/ata/libata-acpi.c   |   9 +-
 drivers/ata/libata-core.c   |  20 ++-
 drivers/ata/libata-eh.c     |  10 +-
 drivers/ata/libata-scsi.c   | 247 ++++++++++++++++++++++++------------
 drivers/ata/libata-zpodd.c  |  55 +++++++-
 drivers/ata/libata.h        |   5 +-
 drivers/scsi/scsi_devinfo.c |  13 +-
 drivers/scsi/scsi_scan.c    |   3 +
 drivers/scsi/sr.c           |  39 ++++--
 drivers/scsi/sr.h           |   2 +
 include/linux/libata.h      |  11 +-
 include/scsi/scsi_device.h  |   4 +-
 include/scsi/scsi_devinfo.h |   6 +-
 13 files changed, 300 insertions(+), 124 deletions(-)


base-commit: 22430ae5d90ab288b0ee2ad99ae941f4a666b694
-- 
2.43.0

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-10-07  2:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-06 23:41 [PATCH v9 00/11] ata: add multi-LUN support for ATAPI devices Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 01/11] ata: libata-core: pin SCSI devices during port detach Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 02/11] ata: libata-zpodd: reference SCSI devices in PM callbacks Phil Pemberton
2026-10-06 23:59   ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 03/11] scsi: scsi_devinfo: preserve full-width quirk identifiers Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 04/11] scsi: sr: initialize logical block size before registering the disk Phil Pemberton
2026-10-06 23:53   ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 05/11] scsi: sr: retry unfinished media revalidation on the next open Phil Pemberton
2026-10-06 23:52   ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 06/11] ata: libata-scsi: add atapi_max_lun module parameter Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 07/11] ata: libata-scsi: convert dev->sdev to per-LUN array Phil Pemberton
2026-10-06 23:58   ` sashiko-bot
2026-10-07  2:38     ` Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 08/11] ata: libata-scsi: route non-zero LUN commands for multi-LUN ATAPI Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 09/11] scsi: add BLIST_NO_LUN_1F blacklist flag Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 10/11] ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 11/11] scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk Phil Pemberton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox