提交 725ea991 编写于 作者: X Xiang Chen 提交者: Zheng Zengkai

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

mainline inclusion
from mainline-v5.17-rc1
commit ae9b69e8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4ZHSV
CVE: NA

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/scsi/hisi_sas?id=ae9b69e85eb7ecb32ddce7c04a10a3c69ad60e52

--------------------------------

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.comAcked-by: NJohn Garry <john.garry@huawei.com>
Signed-off-by: NXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Fujai Ni<nifuijia1@hisilicon.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 976150d3
...@@ -154,6 +154,7 @@ enum hisi_sas_bit_err_type { ...@@ -154,6 +154,7 @@ enum hisi_sas_bit_err_type {
enum hisi_sas_phy_event { enum hisi_sas_phy_event {
HISI_PHYE_PHY_UP = 0U, HISI_PHYE_PHY_UP = 0U,
HISI_PHYE_LINK_RESET, HISI_PHYE_LINK_RESET,
HISI_PHYE_PHY_UP_PM,
HISI_PHYES_NUM, HISI_PHYES_NUM,
}; };
......
...@@ -854,10 +854,11 @@ int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time) ...@@ -854,10 +854,11 @@ int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time)
} }
EXPORT_SYMBOL_GPL(hisi_sas_scan_finished); EXPORT_SYMBOL_GPL(hisi_sas_scan_finished);
static void hisi_sas_phyup_work(struct work_struct *work) static void hisi_sas_phyup_work_common(struct work_struct *work,
enum hisi_sas_phy_event event)
{ {
struct hisi_sas_phy *phy = struct hisi_sas_phy *phy =
container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP]); container_of(work, typeof(*phy), works[event]);
struct hisi_hba *hisi_hba = phy->hisi_hba; struct hisi_hba *hisi_hba = phy->hisi_hba;
struct asd_sas_phy *sas_phy = &phy->sas_phy; struct asd_sas_phy *sas_phy = &phy->sas_phy;
int phy_no = sas_phy->id; int phy_no = sas_phy->id;
...@@ -868,6 +869,11 @@ static void hisi_sas_phyup_work(struct work_struct *work) ...@@ -868,6 +869,11 @@ static void hisi_sas_phyup_work(struct work_struct *work)
hisi_sas_bytes_dmaed(hisi_hba, phy_no, GFP_KERNEL); hisi_sas_bytes_dmaed(hisi_hba, phy_no, GFP_KERNEL);
} }
static void hisi_sas_phyup_work(struct work_struct *work)
{
hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP);
}
static void hisi_sas_linkreset_work(struct work_struct *work) static void hisi_sas_linkreset_work(struct work_struct *work)
{ {
struct hisi_sas_phy *phy = struct hisi_sas_phy *phy =
...@@ -877,9 +883,21 @@ static void hisi_sas_linkreset_work(struct work_struct *work) ...@@ -877,9 +883,21 @@ static void hisi_sas_linkreset_work(struct work_struct *work)
hisi_sas_control_phy(sas_phy, PHY_FUNC_LINK_RESET, NULL); hisi_sas_control_phy(sas_phy, PHY_FUNC_LINK_RESET, NULL);
} }
static void hisi_sas_phyup_pm_work(struct work_struct *work)
{
struct hisi_sas_phy *phy =
container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP_PM]);
struct hisi_hba *hisi_hba = phy->hisi_hba;
struct device *dev = hisi_hba->dev;
hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP_PM);
pm_runtime_put_sync(dev);
}
static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] = { static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] = {
[HISI_PHYE_PHY_UP] = hisi_sas_phyup_work, [HISI_PHYE_PHY_UP] = hisi_sas_phyup_work,
[HISI_PHYE_LINK_RESET] = hisi_sas_linkreset_work, [HISI_PHYE_LINK_RESET] = hisi_sas_linkreset_work,
[HISI_PHYE_PHY_UP_PM] = hisi_sas_phyup_pm_work,
}; };
bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
......
...@@ -1559,7 +1559,9 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) ...@@ -1559,7 +1559,9 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
phy->port_id = port_id; phy->port_id = port_id;
phy->phy_attached = 1; phy->phy_attached = 1;
hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP); /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */
pm_runtime_get_noresume(dev);
hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);
res = IRQ_HANDLED; res = IRQ_HANDLED;
end: end:
if (phy->reset_completion) if (phy->reset_completion)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册