Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: hisi_sas: Keep controller active between ISR of phyup and the event being processed

It is possible that controller may become suspended between processing a
phyup interrupt and the event being processed by libsas. As such, we can't
ensure the controller is active when processing the phyup event - this may
cause the phyup event to be lost or other issues. To avoid any possible
issues, add pm_runtime_get_noresume() in phyup interrupt handler and
pm_runtime_put_sync() in the work handler exit to ensure that we stay
always active. Since we only want to call pm_runtime_get_noresume() for v3
hw, signal this will a new event, HISI_PHYE_PHY_UP_PM.

Link: https://lore.kernel.org/r/1639999298-244569-14-git-send-email-chenxiang66@hisilicon.com
Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Xiang Chen and committed by
Martin K. Petersen
ae9b69e8 bf19aea4

+24 -3
+1
drivers/scsi/hisi_sas/hisi_sas.h
··· 158 158 enum hisi_sas_phy_event { 159 159 HISI_PHYE_PHY_UP = 0U, 160 160 HISI_PHYE_LINK_RESET, 161 + HISI_PHYE_PHY_UP_PM, 161 162 HISI_PHYES_NUM, 162 163 }; 163 164
+20 -2
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 846 846 } 847 847 EXPORT_SYMBOL_GPL(hisi_sas_scan_finished); 848 848 849 - static void hisi_sas_phyup_work(struct work_struct *work) 849 + static void hisi_sas_phyup_work_common(struct work_struct *work, 850 + enum hisi_sas_phy_event event) 850 851 { 851 852 struct hisi_sas_phy *phy = 852 - container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP]); 853 + container_of(work, typeof(*phy), works[event]); 853 854 struct hisi_hba *hisi_hba = phy->hisi_hba; 854 855 struct asd_sas_phy *sas_phy = &phy->sas_phy; 855 856 int phy_no = sas_phy->id; ··· 859 858 if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP) 860 859 hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no); 861 860 hisi_sas_bytes_dmaed(hisi_hba, phy_no, GFP_KERNEL); 861 + } 862 + 863 + static void hisi_sas_phyup_work(struct work_struct *work) 864 + { 865 + hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP); 862 866 } 863 867 864 868 static void hisi_sas_linkreset_work(struct work_struct *work) ··· 875 869 hisi_sas_control_phy(sas_phy, PHY_FUNC_LINK_RESET, NULL); 876 870 } 877 871 872 + static void hisi_sas_phyup_pm_work(struct work_struct *work) 873 + { 874 + struct hisi_sas_phy *phy = 875 + container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP_PM]); 876 + struct hisi_hba *hisi_hba = phy->hisi_hba; 877 + struct device *dev = hisi_hba->dev; 878 + 879 + hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP_PM); 880 + pm_runtime_put_sync(dev); 881 + } 882 + 878 883 static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] = { 879 884 [HISI_PHYE_PHY_UP] = hisi_sas_phyup_work, 880 885 [HISI_PHYE_LINK_RESET] = hisi_sas_linkreset_work, 886 + [HISI_PHYE_PHY_UP_PM] = hisi_sas_phyup_pm_work, 881 887 }; 882 888 883 889 bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
+3 -1
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 1561 1561 1562 1562 phy->port_id = port_id; 1563 1563 1564 - hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP); 1564 + /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */ 1565 + pm_runtime_get_noresume(dev); 1566 + hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM); 1565 1567 1566 1568 res = IRQ_HANDLED; 1567 1569