Skip to content

Commit 8c292e8

Browse files
Martin Wilckmartinkpetersen
authored andcommitted
scsi: Revert "scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans"
This reverts commit 37c4e72. Said commit causes excessive resource usage and even system freeze with some controllers, e.g. smartpqi and hisi_sas. The justification provided by the patch authors [1] was supporting a special mode of the mpi3mr and mpt3sas, so-called "Tri-mode", in which NVMe drives are exposed as SCSI devices on a separate channel. While that's useful for these drivers, it seems wrong to cause major breakage for other drivers for the sake of this feature. [1] https://lore.kernel.org/linux-scsi/CAFdVvOwjy+2ORJ6uJkspiLTPF05481U7gcS4QohFOFGPqAs8ig@mail.gmail.com/ Fixes: 37c4e72 ("scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans") Signed-off-by: Martin Wilck <martin.wilck@suse.com> Cc: Don Brace <don.brace@microchip.com> Cc: storagedev@microchip.com Cc: Ranjan Kumar <ranjan.kumar@broadcom.com> Cc: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com> Cc: Kashyap Desai <kashyap.desai@broadcom.com> Cc: Sumit Saxena <sumit.saxena@broadcom.com> Cc: mpi3mr-linuxdrv.pdl@broadcom.com Cc: MPT-FusionLinux.pdl@broadcom.com Cc: Yihang Li <liyihang9@h-partners.c> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260513174236.430465-3-mwilck@suse.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 57db130 commit 8c292e8

2 files changed

Lines changed: 13 additions & 49 deletions

File tree

drivers/scsi/scsi_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
19211921

19221922
return 0;
19231923
}
1924-
EXPORT_SYMBOL(scsi_scan_host_selected);
1924+
19251925
static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
19261926
{
19271927
struct scsi_device *sdev;

drivers/scsi/scsi_transport_sas.c

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#include <scsi/scsi_transport_sas.h>
4141

4242
#include "scsi_sas_internal.h"
43-
#include "scsi_priv.h"
44-
4543
struct sas_host_attrs {
4644
struct list_head rphy_list;
4745
struct mutex lock;
@@ -1685,22 +1683,6 @@ int scsi_is_sas_rphy(const struct device *dev)
16851683
}
16861684
EXPORT_SYMBOL(scsi_is_sas_rphy);
16871685

1688-
static void scan_channel_zero(struct Scsi_Host *shost, uint id, u64 lun)
1689-
{
1690-
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
1691-
struct sas_rphy *rphy;
1692-
1693-
list_for_each_entry(rphy, &sas_host->rphy_list, list) {
1694-
if (rphy->identify.device_type != SAS_END_DEVICE ||
1695-
rphy->scsi_target_id == -1)
1696-
continue;
1697-
1698-
if (id == SCAN_WILD_CARD || id == rphy->scsi_target_id) {
1699-
scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
1700-
lun, SCSI_SCAN_MANUAL);
1701-
}
1702-
}
1703-
}
17041686

17051687
/*
17061688
* SCSI scan helper
@@ -1710,41 +1692,23 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,
17101692
uint id, u64 lun)
17111693
{
17121694
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
1713-
int res = 0;
1714-
int i;
1715-
1716-
switch (channel) {
1717-
case 0:
1718-
mutex_lock(&sas_host->lock);
1719-
scan_channel_zero(shost, id, lun);
1720-
mutex_unlock(&sas_host->lock);
1721-
break;
1722-
1723-
case SCAN_WILD_CARD:
1724-
mutex_lock(&sas_host->lock);
1725-
scan_channel_zero(shost, id, lun);
1726-
mutex_unlock(&sas_host->lock);
1695+
struct sas_rphy *rphy;
17271696

1728-
for (i = 1; i <= shost->max_channel; i++) {
1729-
res = scsi_scan_host_selected(shost, i, id, lun,
1730-
SCSI_SCAN_MANUAL);
1731-
if (res)
1732-
goto exit_scan;
1733-
}
1734-
break;
1697+
mutex_lock(&sas_host->lock);
1698+
list_for_each_entry(rphy, &sas_host->rphy_list, list) {
1699+
if (rphy->identify.device_type != SAS_END_DEVICE ||
1700+
rphy->scsi_target_id == -1)
1701+
continue;
17351702

1736-
default:
1737-
if (channel <= shost->max_channel) {
1738-
res = scsi_scan_host_selected(shost, channel, id, lun,
1739-
SCSI_SCAN_MANUAL);
1740-
} else {
1741-
res = -EINVAL;
1703+
if ((channel == SCAN_WILD_CARD || channel == 0) &&
1704+
(id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
1705+
scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
1706+
lun, SCSI_SCAN_MANUAL);
17421707
}
1743-
break;
17441708
}
1709+
mutex_unlock(&sas_host->lock);
17451710

1746-
exit_scan:
1747-
return res;
1711+
return 0;
17481712
}
17491713

17501714

0 commit comments

Comments
 (0)