提交 7bf64b2b 编写于 作者: L Luo Jiaxing 提交者: Greg Kroah-Hartman

scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G

[ Upstream commit eb44e4d7b5a3090f0114927f42ae575c29664a09 ]

The SAS controller cannot support a programmed minimum linkrate of > 1.5G
(it will always negotiate to 1.5G at least), so just reject it.

This solves a strange situation where the PHY negotiated linkrate may be
less than the programmed minimum linkrate.
Signed-off-by: NLuo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: NJohn Garry <john.garry@huawei.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 e6f44b13
...@@ -886,7 +886,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) ...@@ -886,7 +886,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
return hisi_sas_task_exec(task, gfp_flags, 0, NULL); return hisi_sas_task_exec(task, gfp_flags, 0, NULL);
} }
static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, static int hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,
struct sas_phy_linkrates *r) struct sas_phy_linkrates *r)
{ {
struct sas_phy_linkrates _r; struct sas_phy_linkrates _r;
...@@ -895,6 +895,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, ...@@ -895,6 +895,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,
struct asd_sas_phy *sas_phy = &phy->sas_phy; struct asd_sas_phy *sas_phy = &phy->sas_phy;
enum sas_linkrate min, max; enum sas_linkrate min, max;
if (r->minimum_linkrate > SAS_LINK_RATE_1_5_GBPS)
return -EINVAL;
if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) { if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) {
max = sas_phy->phy->maximum_linkrate; max = sas_phy->phy->maximum_linkrate;
min = r->minimum_linkrate; min = r->minimum_linkrate;
...@@ -902,7 +905,7 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, ...@@ -902,7 +905,7 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,
max = r->maximum_linkrate; max = r->maximum_linkrate;
min = sas_phy->phy->minimum_linkrate; min = sas_phy->phy->minimum_linkrate;
} else } else
return; return -EINVAL;
_r.maximum_linkrate = max; _r.maximum_linkrate = max;
_r.minimum_linkrate = min; _r.minimum_linkrate = min;
...@@ -914,6 +917,8 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, ...@@ -914,6 +917,8 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,
msleep(100); msleep(100);
hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r);
hisi_hba->hw->phy_start(hisi_hba, phy_no); hisi_hba->hw->phy_start(hisi_hba, phy_no);
return 0;
} }
static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
...@@ -939,8 +944,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, ...@@ -939,8 +944,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
break; break;
case PHY_FUNC_SET_LINK_RATE: case PHY_FUNC_SET_LINK_RATE:
hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata); return hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata);
break;
case PHY_FUNC_GET_EVENTS: case PHY_FUNC_GET_EVENTS:
if (hisi_hba->hw->get_events) { if (hisi_hba->hw->get_events) {
hisi_hba->hw->get_events(hisi_hba, phy_no); hisi_hba->hw->get_events(hisi_hba, phy_no);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册