scsi: hisi_sas: Initialise devices in .slave_alloc callback
authorXiang Chen <chenxiang66@hisilicon.com>
Tue, 12 Oct 2021 12:26:25 +0000 (20:26 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 13 Oct 2021 02:46:06 +0000 (22:46 -0400)
Perform driver-specific SCSI device initialization in the designated SCSI
midlayer callback instead of relying on the libsas "device found" callback.

The SCSI midlayer .slave_alloc interface is called prior to sending any I/O
to the device.

Link: https://lore.kernel.org/r/1634041588-74824-2-git-send-email-john.garry@huawei.com
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

index 57be32ba0109f486315b149027b5d50450a38a51..2213a91923a5d082e9bdf8653d022c521650a343 100644 (file)
@@ -649,6 +649,7 @@ extern int hisi_sas_probe(struct platform_device *pdev,
 extern int hisi_sas_remove(struct platform_device *pdev);
 
 extern int hisi_sas_slave_configure(struct scsi_device *sdev);
+extern int hisi_sas_slave_alloc(struct scsi_device *sdev);
 extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time);
 extern void hisi_sas_scan_start(struct Scsi_Host *shost);
 extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type);
index bb1c8ef3a76fe9929dfbd8c115bd08840f790e05..0835ba7c0ac21c1070772256aa29296f34db1eb8 100644 (file)
@@ -756,6 +756,20 @@ static int hisi_sas_init_device(struct domain_device *device)
        return rc;
 }
 
+int hisi_sas_slave_alloc(struct scsi_device *sdev)
+{
+       struct domain_device *ddev;
+       int rc;
+
+       rc = sas_slave_alloc(sdev);
+       if (rc)
+               return rc;
+       ddev = sdev_to_domain_dev(sdev);
+
+       return hisi_sas_init_device(ddev);
+}
+EXPORT_SYMBOL_GPL(hisi_sas_slave_alloc);
+
 static int hisi_sas_dev_found(struct domain_device *device)
 {
        struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
@@ -802,9 +816,6 @@ static int hisi_sas_dev_found(struct domain_device *device)
        dev_info(dev, "dev[%d:%x] found\n",
                sas_dev->device_id, sas_dev->dev_type);
 
-       rc = hisi_sas_init_device(device);
-       if (rc)
-               goto err_out;
        sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
        return 0;
 
index 862f4e8b7eb58e0907f932b256f7ec07b39bfcaa..51e7d12f5053c290edaba01ad0ff112d47f4dd04 100644 (file)
@@ -1771,7 +1771,7 @@ static struct scsi_host_template sht_v1_hw = {
        .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
        .eh_device_reset_handler = sas_eh_device_reset_handler,
        .eh_target_reset_handler = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
+       .slave_alloc            = hisi_sas_slave_alloc,
        .target_destroy         = sas_target_destroy,
        .ioctl                  = sas_ioctl,
 #ifdef CONFIG_COMPAT
index 236cf65c2f97da51cf5538ced54dbf6fee36d5d9..741a62e6bf77d67c4a8596414b54b25f53265489 100644 (file)
@@ -3584,7 +3584,7 @@ static struct scsi_host_template sht_v2_hw = {
        .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
        .eh_device_reset_handler = sas_eh_device_reset_handler,
        .eh_target_reset_handler = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
+       .slave_alloc            = hisi_sas_slave_alloc,
        .target_destroy         = sas_target_destroy,
        .ioctl                  = sas_ioctl,
 #ifdef CONFIG_COMPAT
index f4517f3eb92238c5fb3611868578b155346eb7d1..114a596545252f1605bb284150b0193e044d8797 100644 (file)
@@ -3157,7 +3157,7 @@ static struct scsi_host_template sht_v3_hw = {
        .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
        .eh_device_reset_handler = sas_eh_device_reset_handler,
        .eh_target_reset_handler = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
+       .slave_alloc            = hisi_sas_slave_alloc,
        .target_destroy         = sas_target_destroy,
        .ioctl                  = sas_ioctl,
 #ifdef CONFIG_COMPAT