scsi: hisi_sas: Add helper to process bcast events
authorJohn Garry <john.garry@huawei.com>
Mon, 5 Sep 2022 11:48:48 +0000 (19:48 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 7 Sep 2022 02:28:11 +0000 (22:28 -0400)
Add a helper for bcast processing to reduce duplication.

Link: https://lore.kernel.org/r/1662378529-101489-5-git-send-email-john.garry@huawei.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 24c83bc..9aebf4a 100644 (file)
@@ -649,6 +649,7 @@ extern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no,
                                int enable);
 extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy,
                              gfp_t gfp_flags);
+extern void hisi_sas_phy_bcast(struct hisi_sas_phy *phy);
 extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
                                    struct sas_task *task,
                                    struct hisi_sas_slot *slot);
index 2edadd4..32fa775 100644 (file)
@@ -1989,6 +1989,18 @@ void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy,
 }
 EXPORT_SYMBOL_GPL(hisi_sas_phy_down);
 
+void hisi_sas_phy_bcast(struct hisi_sas_phy *phy)
+{
+       struct asd_sas_phy *sas_phy = &phy->sas_phy;
+       struct hisi_hba *hisi_hba = phy->hisi_hba;
+
+       if (test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
+               return;
+
+       sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD, GFP_ATOMIC);
+}
+EXPORT_SYMBOL_GPL(hisi_sas_phy_bcast);
+
 void hisi_sas_sync_irqs(struct hisi_hba *hisi_hba)
 {
        int i;
index 349546b..d643c5a 100644 (file)
@@ -1412,9 +1412,7 @@ static irqreturn_t int_bcast_v1_hw(int irq, void *p)
                goto end;
        }
 
-       if (!test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
-               sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD,
-                                     GFP_ATOMIC);
+       hisi_sas_phy_bcast(phy);
 
 end:
        hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2,
index 70e401f..a9c1642 100644 (file)
@@ -2811,15 +2811,12 @@ static irqreturn_t int_phy_updown_v2_hw(int irq_no, void *p)
 static void phy_bcast_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
        struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
-       struct asd_sas_phy *sas_phy = &phy->sas_phy;
        u32 bcast_status;
 
        hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
        bcast_status = hisi_sas_phy_read32(hisi_hba, phy_no, RX_PRIMS_STATUS);
-       if ((bcast_status & RX_BCAST_CHG_MSK) &&
-           !test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
-               sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD,
-                                     GFP_ATOMIC);
+       if (bcast_status & RX_BCAST_CHG_MSK)
+               hisi_sas_phy_bcast(phy);
        hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
                             CHL_INT0_SL_RX_BCST_ACK_MSK);
        hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);
index 1710f47..10b55ce 100644 (file)
@@ -1626,15 +1626,12 @@ static irqreturn_t phy_down_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
 static irqreturn_t phy_bcast_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
        struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
-       struct asd_sas_phy *sas_phy = &phy->sas_phy;
        u32 bcast_status;
 
        hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
        bcast_status = hisi_sas_phy_read32(hisi_hba, phy_no, RX_PRIMS_STATUS);
-       if ((bcast_status & RX_BCAST_CHG_MSK) &&
-           !test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
-               sas_notify_port_event(sas_phy, PORTE_BROADCAST_RCVD,
-                                     GFP_ATOMIC);
+       if (bcast_status & RX_BCAST_CHG_MSK)
+               hisi_sas_phy_bcast(phy);
        hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
                             CHL_INT0_SL_RX_BCST_ACK_MSK);
        hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);