]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: hisi_sas: tidy host controller reset function a bit
authorXiaofei Tan <tanxiaofei@huawei.com>
Wed, 18 Jul 2018 14:14:28 +0000 (22:14 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 1 Oct 2018 16:23:18 +0000 (18:23 +0200)
BugLink: https://bugs.launchpad.net/bugs/1794166
This patch tidies host controller reset function by putting some code to
two new functions, and exports these two functions out, so that they could
be used by FLR feature to be realised.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 4522204ab218a8c1f4d3901276deb0a61e7ac9c0)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c

index 6f79343b61c6766a4c0fe4ed69ac9f4a9ec81f2f..a236b4a64241140be5445e1659338f5dbaabdc5b 100644 (file)
@@ -323,6 +323,7 @@ struct hisi_hba {
        const struct hisi_sas_hw *hw;   /* Low level hw interface */
        unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)];
        struct work_struct rst_work;
+       u32 phy_state;
 };
 
 /* Generic HW DMA host memory structures */
@@ -484,4 +485,6 @@ extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
                                enum hisi_sas_phy_event event);
 extern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba);
 extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max);
+extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba);
+extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba);
 #endif
index 49c79fc911b02a6254480ccc038df2e04cf98130..facd712b77027ae8644776aa526da662ed64e1a8 100644 (file)
@@ -1318,22 +1318,12 @@ static void hisi_sas_terminate_stp_reject(struct hisi_hba *hisi_hba)
        }
 }
 
-static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
+void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba)
 {
-       struct device *dev = hisi_hba->dev;
        struct Scsi_Host *shost = hisi_hba->shost;
-       u32 old_state, state;
-       int rc;
-
-       if (!hisi_hba->hw->soft_reset)
-               return -1;
-
-       if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
-               return -1;
 
        down(&hisi_hba->sem);
-       dev_info(dev, "controller resetting...\n");
-       old_state = hisi_hba->hw->get_phys_state(hisi_hba);
+       hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba);
 
        scsi_block_requests(shost);
        hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 100, 5000);
@@ -1342,15 +1332,13 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
                del_timer_sync(&hisi_hba->timer);
 
        set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
-       rc = hisi_hba->hw->soft_reset(hisi_hba);
-       if (rc) {
-               dev_warn(dev, "controller reset failed (%d)\n", rc);
-               clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
-               up(&hisi_hba->sem);
-               scsi_unblock_requests(shost);
-               clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
-               return rc;
-       }
+}
+EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_prepare);
+
+void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba)
+{
+       struct Scsi_Host *shost = hisi_hba->shost;
+       u32 state;
 
        /* Init and wait for PHYs to come up and all libsas event finished. */
        hisi_hba->hw->phys_init(hisi_hba);
@@ -1366,7 +1354,36 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
        clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
 
        state = hisi_hba->hw->get_phys_state(hisi_hba);
-       hisi_sas_rescan_topology(hisi_hba, old_state, state);
+       hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state, state);
+}
+EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done);
+
+static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
+{
+       struct device *dev = hisi_hba->dev;
+       struct Scsi_Host *shost = hisi_hba->shost;
+       int rc;
+
+       if (!hisi_hba->hw->soft_reset)
+               return -1;
+
+       if (test_and_set_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags))
+               return -1;
+
+       dev_info(dev, "controller resetting...\n");
+       hisi_sas_controller_reset_prepare(hisi_hba);
+
+       rc = hisi_hba->hw->soft_reset(hisi_hba);
+       if (rc) {
+               dev_warn(dev, "controller reset failed (%d)\n", rc);
+               clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
+               up(&hisi_hba->sem);
+               scsi_unblock_requests(shost);
+               clear_bit(HISI_SAS_RESET_BIT, &hisi_hba->flags);
+               return rc;
+       }
+
+       hisi_sas_controller_reset_done(hisi_hba);
        dev_info(dev, "controller reset complete\n");
 
        return 0;