]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.111/scsi-hisi_sas-set-phy-linkrate-when-disconnected.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / scsi-hisi_sas-set-phy-linkrate-when-disconnected.patch
CommitLineData
04fd09d4
SL
1From 8fd3320cb345e1f3e3a67c1defe2f3903f28c883 Mon Sep 17 00:00:00 2001
2From: John Garry <john.garry@huawei.com>
3Date: Thu, 28 Feb 2019 22:51:00 +0800
4Subject: scsi: hisi_sas: Set PHY linkrate when disconnected
5
6[ Upstream commit efdcad62e7b8a02fcccc5ccca57806dce1482ac8 ]
7
8When the PHY comes down, we currently do not set the negotiated linkrate:
9
10root@(none)$ pwd
11/sys/class/sas_phy/phy-0:0
12root@(none)$ more enable
131
14root@(none)$ more negotiated_linkrate
1512.0 Gbit
16root@(none)$ echo 0 > enable
17root@(none)$ more negotiated_linkrate
1812.0 Gbit
19root@(none)$
20
21This patch fixes the driver code to set it properly when the PHY comes
22down.
23
24If the PHY had been enabled, then set unknown; otherwise, flag as disabled.
25
26The logical place to set the negotiated linkrate for this scenario is PHY
27down routine, which is called from the PHY down ISR.
28
29However, it is not possible to know if the PHY comes down due to PHY
30disable or loss of link, as sas_phy.enabled member is not set until after
31the transport disable routine is complete, which races with the PHY down
32ISR.
33
34As an imperfect solution, use sas_phy_data.enable as the flag to know if
35the PHY is down due to disable. It's imperfect, as sas_phy_data is internal
36to libsas.
37
38I can't see another way without adding a new field to hisi_sas_phy and
39managing it, or changing SCSI SAS transport.
40
41Signed-off-by: John Garry <john.garry@huawei.com>
42Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
43Signed-off-by: Sasha Levin <sashal@kernel.org>
44---
45 drivers/scsi/hisi_sas/hisi_sas_main.c | 10 ++++++++++
46 1 file changed, 10 insertions(+)
47
48diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
49index 8fa9bb336ad4..b167411580ba 100644
50--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
51+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
52@@ -10,6 +10,7 @@
53 */
54
55 #include "hisi_sas.h"
56+#include "../libsas/sas_internal.h"
57 #define DRV_NAME "hisi_sas"
58
59 #define DEV_IS_GONE(dev) \
60@@ -1508,9 +1509,18 @@ static void hisi_sas_port_formed(struct asd_sas_phy *sas_phy)
61
62 static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
63 {
64+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
65+ struct sas_phy *sphy = sas_phy->phy;
66+ struct sas_phy_data *d = sphy->hostdata;
67+
68 phy->phy_attached = 0;
69 phy->phy_type = 0;
70 phy->port = NULL;
71+
72+ if (d->enable)
73+ sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
74+ else
75+ sphy->negotiated_linkrate = SAS_PHY_DISABLED;
76 }
77
78 void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)
79--
802.19.1
81