scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM
authorYihang Li <liyihang9@huawei.com>
Thu, 14 Dec 2023 03:45:12 +0000 (11:45 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 14 Dec 2023 04:24:54 +0000 (23:24 -0500)
Currently in directly attached scenario, the phyup event
HISI_PHYE_PHY_UP_PM is notified before .phy_attached is set - this may
cause the phyup work hisi_sas_bytes_dmaed() execution failed and the
attached device will not be found.

To fix it, set .phy_attached before notifing phyup event.

Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Link: https://lore.kernel.org/r/1702525516-51258-2-git-send-email-chenxiang66@hisilicon.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

index d8437a98037b96874c0d7a5544ba457a5384e83f..f3eb5cd5260235cdf530cba3321b3979f6d7c9cc 100644 (file)
@@ -1605,6 +1605,11 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
        }
 
        phy->port_id = port_id;
+       spin_lock(&phy->lock);
+       /* Delete timer and set phy_attached atomically */
+       del_timer(&phy->timer);
+       phy->phy_attached = 1;
+       spin_unlock(&phy->lock);
 
        /*
         * Call pm_runtime_get_noresume() which pairs with
@@ -1618,11 +1623,6 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
 
        res = IRQ_HANDLED;
 
-       spin_lock(&phy->lock);
-       /* Delete timer and set phy_attached atomically */
-       del_timer(&phy->timer);
-       phy->phy_attached = 1;
-       spin_unlock(&phy->lock);
 end:
        if (phy->reset_completion)
                complete(phy->reset_completion);