]>
Commit | Line | Data |
---|---|---|
04fd09d4 SL |
1 | From 8fd3320cb345e1f3e3a67c1defe2f3903f28c883 Mon Sep 17 00:00:00 2001 |
2 | From: John Garry <john.garry@huawei.com> | |
3 | Date: Thu, 28 Feb 2019 22:51:00 +0800 | |
4 | Subject: scsi: hisi_sas: Set PHY linkrate when disconnected | |
5 | ||
6 | [ Upstream commit efdcad62e7b8a02fcccc5ccca57806dce1482ac8 ] | |
7 | ||
8 | When the PHY comes down, we currently do not set the negotiated linkrate: | |
9 | ||
10 | root@(none)$ pwd | |
11 | /sys/class/sas_phy/phy-0:0 | |
12 | root@(none)$ more enable | |
13 | 1 | |
14 | root@(none)$ more negotiated_linkrate | |
15 | 12.0 Gbit | |
16 | root@(none)$ echo 0 > enable | |
17 | root@(none)$ more negotiated_linkrate | |
18 | 12.0 Gbit | |
19 | root@(none)$ | |
20 | ||
21 | This patch fixes the driver code to set it properly when the PHY comes | |
22 | down. | |
23 | ||
24 | If the PHY had been enabled, then set unknown; otherwise, flag as disabled. | |
25 | ||
26 | The logical place to set the negotiated linkrate for this scenario is PHY | |
27 | down routine, which is called from the PHY down ISR. | |
28 | ||
29 | However, it is not possible to know if the PHY comes down due to PHY | |
30 | disable or loss of link, as sas_phy.enabled member is not set until after | |
31 | the transport disable routine is complete, which races with the PHY down | |
32 | ISR. | |
33 | ||
34 | As an imperfect solution, use sas_phy_data.enable as the flag to know if | |
35 | the PHY is down due to disable. It's imperfect, as sas_phy_data is internal | |
36 | to libsas. | |
37 | ||
38 | I can't see another way without adding a new field to hisi_sas_phy and | |
39 | managing it, or changing SCSI SAS transport. | |
40 | ||
41 | Signed-off-by: John Garry <john.garry@huawei.com> | |
42 | Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> | |
43 | Signed-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 | ||
48 | diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c | |
49 | index 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 | -- | |
80 | 2.19.1 | |
81 |