Skip to contentSkip to conversation

scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans

PATCH Applied Ranjan Kumar 3 participants 4 messages Jun 24, 2025 – Jul 31, 2025 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans

sas_user_scan() did not fully process wildcard channel
scans (SCAN_WILD_CARD).When a transport-specific user_scan() callback was present.Only channel 0 would be scanned via user_scan(), while the remaining channels were skipped, potentially missing devices.

user_scan() invoke updated sas_user_scan() for channel 0, and if successful,iteratively scan remaining
channels (1 to shost->max_channel) via scsi_scan_host_selected(). This ensures complete wildcard scanning without afftecting transport-specific scanning behavior.

---
 drivers/scsi/scsi_scan.c          |  2 +-
 drivers/scsi/scsi_transport_sas.c | 61 +++++++++++++++++++++++++------
 2 files changed, 50 insertions(+), 13 deletions(-)
drivers/scsi/scsi_scan.c +1 -1
index 4833b8fe251b..396fcf194b6b 100644
@@ -1899,7 +1899,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
 
 	return 0;
 }
-
+EXPORT_SYMBOL(scsi_scan_host_selected);
 static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
 {
 	struct scsi_device *sdev;
drivers/scsi/scsi_transport_sas.c +49 -12

87 lines not on this page · raw message

Signature · 1 line
2.31.1
#1 lore raw

Hi Ranjan!

Quoted 3 lines

user_scan() invoke updated sas_user_scan() for channel 0, and if successful,iteratively scan remaining channels (1 to shost->max_channel) via scsi_scan_host_selected().

Two questions:

1. Channels? In 2025?

2. Why special-case channel 0?

Signature · 1 line
Martin K. Petersen
#2 lore raw
Quoted 11 lines · Martin K. Petersen

Hi Ranjan!

Quoted 3 lines

user_scan() invoke updated sas_user_scan() for channel 0, and if successful,iteratively scan remaining channels (1 to shost->max_channel) via scsi_scan_host_selected().

Two questions:

1. Channels? In 2025?

The mpt3sas and mpi3mr drivers support both SAS/SATA devices and NVMe drives (Tri-mode support). The NVMe drives are exposed as generic SCSI devices by the controller and they are identified through persistent ID (which is nothing but an target ID) whereas the SAS and SATA devices are exposed through SAS transport to the kernel as they have associated phy/port data structures from the controller and in there the ID assignment is done by the SAS transport layer. Hence if same channel is used for both SAS/SATA and NVMe there will be an ID conflict so both mpt3sas and mpi3mr drivers reserve non-zero channel for NVMe devices.

Quoted 2 lines

2. Why special-case channel 0?

The SAS transport assumes channel 0 for all SAS/SATA devivces, so we do not want to mess with that and use the non-zero channel SCSI type of scanning and let the SAS transport handle channel 0 for SAS transport specific scanning.

Quoted 2 lines

--
Martin K. Petersen

#3 lore raw
In reply to Ranjan Kumar
Quoted 5 lines · Ranjan Kumar

sas_user_scan() did not fully process wildcard channel
scans (SCAN_WILD_CARD).When a transport-specific user_scan() callback was present.Only channel 0 would be scanned via user_scan(), while the remaining channels were skipped, potentially missing devices.

Quoted 7 lines

user_scan() invoke updated sas_user_scan() for channel 0, and if successful,iteratively scan remaining
channels (1 to shost->max_channel) via scsi_scan_host_selected(). This ensures complete wildcard scanning without afftecting transport-specific scanning behavior.

[...]

Applied to 6.17/scsi-queue, thanks!

[1/1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans

      https://git.kernel.org/mkp/scsi/c/37c4e72b0651
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering