diff mbox series

[RFC,v3,08/22] scsi: scsi_transport_sas: Alloc sdev for expander

Message ID 1666693096-180008-9-git-send-email-john.garry@huawei.com
State New
Headers show
Series blk-mq/libata/scsi: SCSI driver tagging improvements Part I | expand

Commit Message

John Garry Oct. 25, 2022, 10:18 a.m. UTC
Allocate a scsi device for an expander for sending SMP commands on the
expander sdev request queue.

Use channel=1 to not conflict with scsi target devices.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/scsi_transport_sas.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 2f88c61216ee..da075dfc7cd0 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -1548,6 +1548,11 @@  int sas_rphy_add(struct sas_rphy *rphy)
 
 		scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun,
 				 SCSI_SCAN_INITIAL);
+	} else if (identify->device_type == SAS_EDGE_EXPANDER_DEVICE ||
+		   identify->device_type == SAS_FANOUT_EXPANDER_DEVICE) {
+
+		if (!scsi_get_dev(&rphy->dev, 1, rphy->scsi_target_id, 0))
+			return -ENODEV;
 	}
 
 	return 0;
@@ -1627,6 +1632,7 @@  sas_rphy_remove(struct sas_rphy *rphy)
 	case SAS_EDGE_EXPANDER_DEVICE:
 	case SAS_FANOUT_EXPANDER_DEVICE:
 		sas_remove_children(dev);
+		scsi_remove_target(dev);
 		break;
 	default:
 		break;