* [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
@ 2025-06-24 6:16 Ranjan Kumar
2025-07-09 2:03 ` Martin K. Petersen
2025-07-31 4:44 ` Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: Ranjan Kumar @ 2025-06-24 6:16 UTC (permalink / raw)
To: linux-scsi, martin.petersen
Cc: rajsekhar.chundru, sathya.prakash, sumit.saxena,
chandrakanth.patil, prayas.patel, 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.
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.
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
---
drivers/scsi/scsi_scan.c | 2 +-
drivers/scsi/scsi_transport_sas.c | 61 +++++++++++++++++++++++++------
2 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 4833b8fe251b..396fcf194b6b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -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;
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 351b028ef893..42e79eccf05f 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -40,6 +40,8 @@
#include <scsi/scsi_transport_sas.h>
#include "scsi_sas_internal.h"
+#include "scsi_priv.h"
+
struct sas_host_attrs {
struct list_head rphy_list;
struct mutex lock;
@@ -1683,32 +1685,67 @@ int scsi_is_sas_rphy(const struct device *dev)
}
EXPORT_SYMBOL(scsi_is_sas_rphy);
-
-/*
- * SCSI scan helper
- */
-
-static int sas_user_scan(struct Scsi_Host *shost, uint channel,
- uint id, u64 lun)
+static void scan_channel_zero(struct Scsi_Host *shost, uint id, u64 lun)
{
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
struct sas_rphy *rphy;
- mutex_lock(&sas_host->lock);
list_for_each_entry(rphy, &sas_host->rphy_list, list) {
if (rphy->identify.device_type != SAS_END_DEVICE ||
rphy->scsi_target_id == -1)
continue;
- if ((channel == SCAN_WILD_CARD || channel == 0) &&
- (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
+ if (id == SCAN_WILD_CARD || id == rphy->scsi_target_id) {
scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
lun, SCSI_SCAN_MANUAL);
}
}
- mutex_unlock(&sas_host->lock);
+}
- return 0;
+/*
+ * SCSI scan helper
+ */
+
+static int sas_user_scan(struct Scsi_Host *shost, uint channel,
+ uint id, u64 lun)
+{
+ struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
+ int res = 0;
+ int i;
+
+ switch (channel) {
+ case 0:
+ mutex_lock(&sas_host->lock);
+ scan_channel_zero(shost, id, lun);
+ mutex_unlock(&sas_host->lock);
+ break;
+
+ case SCAN_WILD_CARD:
+
+ mutex_lock(&sas_host->lock);
+ scan_channel_zero(shost, id, lun);
+ mutex_unlock(&sas_host->lock);
+
+ for (i = 1; i <= shost->max_channel; i++) {
+ res = scsi_scan_host_selected(shost, i, id, lun,
+ SCSI_SCAN_MANUAL);
+ if (res)
+ goto exit_scan;
+ }
+ break;
+
+ default:
+ if (channel < shost->max_channel) {
+ res = scsi_scan_host_selected(shost, channel, id, lun,
+ SCSI_SCAN_MANUAL);
+ } else {
+ res = -EINVAL;
+ }
+ break;
+ }
+
+exit_scan:
+ return res;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
2025-06-24 6:16 [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans Ranjan Kumar
@ 2025-07-09 2:03 ` Martin K. Petersen
2025-07-15 4:14 ` Sathya Prakash Veerichetty
2025-07-31 4:44 ` Martin K. Petersen
1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2025-07-09 2:03 UTC (permalink / raw)
To: Ranjan Kumar
Cc: linux-scsi, martin.petersen, rajsekhar.chundru, sathya.prakash,
sumit.saxena, chandrakanth.patil, prayas.patel
Hi Ranjan!
> 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?
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
2025-07-09 2:03 ` Martin K. Petersen
@ 2025-07-15 4:14 ` Sathya Prakash Veerichetty
0 siblings, 0 replies; 4+ messages in thread
From: Sathya Prakash Veerichetty @ 2025-07-15 4:14 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Ranjan Kumar, linux-scsi, rajsekhar.chundru, sumit.saxena,
chandrakanth.patil, prayas.patel
[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]
On Tue, Jul 8, 2025 at 8:03 PM Martin K. Petersen
<martin.petersen@oracle.com> wrote:
>
>
> Hi Ranjan!
>
> > 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.
>
> 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.
> --
> Martin K. Petersen
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4214 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
2025-06-24 6:16 [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans Ranjan Kumar
2025-07-09 2:03 ` Martin K. Petersen
@ 2025-07-31 4:44 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-07-31 4:44 UTC (permalink / raw)
To: linux-scsi, Ranjan Kumar
Cc: Martin K . Petersen, rajsekhar.chundru, sathya.prakash,
sumit.saxena, chandrakanth.patil, prayas.patel
On Tue, 24 Jun 2025 11:46:49 +0530, Ranjan Kumar wrote:
> 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.
>
> [...]
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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-31 4:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 6:16 [PATCH v1] scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans Ranjan Kumar
2025-07-09 2:03 ` Martin K. Petersen
2025-07-15 4:14 ` Sathya Prakash Veerichetty
2025-07-31 4:44 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).