Skip to content

Commit da4853e

Browse files
Martin Wilckgregkh
authored andcommitted
scsi: Revert "scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans"
[ Upstream commit 8c292e8 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 73e35c1 commit da4853e

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
@@ -1848,7 +1848,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
18481848

18491849
return 0;
18501850
}
1851-
EXPORT_SYMBOL(scsi_scan_host_selected);
1851+
18521852
static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
18531853
{
18541854
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;
@@ -1683,22 +1681,6 @@ int scsi_is_sas_rphy(const struct device *dev)
16831681
}
16841682
EXPORT_SYMBOL(scsi_is_sas_rphy);
16851683

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

17031685
/*
17041686
* SCSI scan helper
@@ -1708,41 +1690,23 @@ static int sas_user_scan(struct Scsi_Host *shost, uint channel,
17081690
uint id, u64 lun)
17091691
{
17101692
struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
1711-
int res = 0;
1712-
int i;
1713-
1714-
switch (channel) {
1715-
case 0:
1716-
mutex_lock(&sas_host->lock);
1717-
scan_channel_zero(shost, id, lun);
1718-
mutex_unlock(&sas_host->lock);
1719-
break;
1720-
1721-
case SCAN_WILD_CARD:
1722-
mutex_lock(&sas_host->lock);
1723-
scan_channel_zero(shost, id, lun);
1724-
mutex_unlock(&sas_host->lock);
1693+
struct sas_rphy *rphy;
17251694

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

1734-
default:
1735-
if (channel <= shost->max_channel) {
1736-
res = scsi_scan_host_selected(shost, channel, id, lun,
1737-
SCSI_SCAN_MANUAL);
1738-
} else {
1739-
res = -EINVAL;
1701+
if ((channel == SCAN_WILD_CARD || channel == 0) &&
1702+
(id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {
1703+
scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id,
1704+
lun, SCSI_SCAN_MANUAL);
17401705
}
1741-
break;
17421706
}
1707+
mutex_unlock(&sas_host->lock);
17431708

1744-
exit_scan:
1745-
return res;
1709+
return 0;
17461710
}
17471711

17481712

0 commit comments

Comments
 (0)