OSDN Git Service

scsi: hisi_sas: Add device link between SCSI devices and hisi_hba
authorXiang Chen <chenxiang66@hisilicon.com>
Fri, 2 Oct 2020 14:30:36 +0000 (22:30 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 7 Oct 2020 00:47:06 +0000 (20:47 -0400)
Runtime PM of SCSI devices is already supported in SCSI layer, we can
suspend/resume every SCSI device separately. But if there is no link
between hisi_hba and SCSI devices or SCSI targets it will cause issues if
the controller is suspended while SCSI devices are still resuming.  Only
when all the SCSI devices under the controller are suspended, the
controller can be suspended. Add the device link between SCSI devices
and the controller.

Link: https://lore.kernel.org/r/1601649038-25534-6-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_v3_hw.c

index da2c429..dfabfb4 100644 (file)
@@ -2758,6 +2758,33 @@ static ssize_t intr_coal_count_v3_hw_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(intr_coal_count_v3_hw);
 
+static int slave_configure_v3_hw(struct scsi_device *sdev)
+{
+       struct Scsi_Host *shost = dev_to_shost(&sdev->sdev_gendev);
+       struct domain_device *ddev = sdev_to_domain_dev(sdev);
+       struct hisi_hba *hisi_hba = shost_priv(shost);
+       struct device *dev = hisi_hba->dev;
+       int ret = sas_slave_configure(sdev);
+
+       if (ret)
+               return ret;
+       if (!dev_is_sata(ddev))
+               sas_change_queue_depth(sdev, 64);
+
+       if (sdev->type == TYPE_ENCLOSURE)
+               return 0;
+
+       if (!device_link_add(&sdev->sdev_gendev, dev,
+                            DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)) {
+               if (pm_runtime_enabled(dev)) {
+                       dev_info(dev, "add device link failed, disable runtime PM for the host\n");
+                       pm_runtime_disable(dev);
+               }
+       }
+
+       return 0;
+}
+
 static struct device_attribute *host_attrs_v3_hw[] = {
        &dev_attr_phy_event_threshold,
        &dev_attr_intr_conv_v3_hw,
@@ -3114,7 +3141,7 @@ static struct scsi_host_template sht_v3_hw = {
        .queuecommand           = sas_queuecommand,
        .dma_need_drain         = ata_scsi_dma_need_drain,
        .target_alloc           = sas_target_alloc,
-       .slave_configure        = hisi_sas_slave_configure,
+       .slave_configure        = slave_configure_v3_hw,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
        .change_queue_depth     = sas_change_queue_depth,