提交 d9ead78c 编写于 作者: Q Qi Liu 提交者: Zheng Zengkai

scsi: hisi_sas: Prevent parallel controller reset and control phy command

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

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=20c634932ae8

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

A user may issue a control phy command from sysfs at any time, even if the
controller is resetting.

If a phy is disabled by hardreset/linkreset command before calling
get_phys_state() in the reset path, the saved phy state may be incorrect.

To avoid incorrectly recording the phy state, use hisi_hba.sem to ensure
that the controller reset may not run at the same time as when the phy
control function is running.

Link: https://lore.kernel.org/r/1639579061-179473-6-git-send-email-john.garry@huawei.comSigned-off-by: NQi Liu <liuqi115@huawei.com>
Signed-off-by: NJohn Garry <john.garry@huawei.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Nxiabing <xiabing12@h-partners.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Reviewed-by: NXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 28b77426
...@@ -1168,6 +1168,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, ...@@ -1168,6 +1168,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
u8 sts = phy->phy_attached; u8 sts = phy->phy_attached;
int ret = 0; int ret = 0;
down(&hisi_hba->sem);
phy->reset_completion = &completion; phy->reset_completion = &completion;
switch (func) { switch (func) {
...@@ -1211,6 +1212,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, ...@@ -1211,6 +1212,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
out: out:
phy->reset_completion = NULL; phy->reset_completion = NULL;
up(&hisi_hba->sem);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册