]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/scsi-libsas-do-discovery-on-empty-phy-to-update-phy-.patch
46feb4679afbe5ec98d072d3ce3526ddd6abe3ef
[thirdparty/kernel/stable-queue.git] / queue-4.4 / scsi-libsas-do-discovery-on-empty-phy-to-update-phy-.patch
1 From b7b72a33e073279bcf55cc1d3a0f8550cd9d093b Mon Sep 17 00:00:00 2001
2 From: John Garry <john.garry@huawei.com>
3 Date: Fri, 12 Apr 2019 16:57:56 +0800
4 Subject: scsi: libsas: Do discovery on empty PHY to update PHY info
5
6 [ Upstream commit d8649fc1c5e40e691d589ed825998c36a947491c ]
7
8 When we discover the PHY is empty in sas_rediscover_dev(), the PHY
9 information (like negotiated linkrate) is not updated.
10
11 As such, for a user examining sysfs for that PHY, they would see
12 incorrect values:
13
14 root@(none)$ cd /sys/class/sas_phy/phy-0:0:20
15 root@(none)$ more negotiated_linkrate
16 3.0 Gbit
17 root@(none)$ echo 0 > enable
18 root@(none)$ more negotiated_linkrate
19 3.0 Gbit
20
21 So fix this, simply discover the PHY again, even though we know it's empty;
22 in the above example, this gives us:
23
24 root@(none)$ more negotiated_linkrate
25 Phy disabled
26
27 We must do this after unregistering the device associated with the PHY
28 (in sas_unregister_devs_sas_addr()).
29
30 Signed-off-by: John Garry <john.garry@huawei.com>
31 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
32 Signed-off-by: Sasha Levin <sashal@kernel.org>
33 ---
34 drivers/scsi/libsas/sas_expander.c | 5 +++++
35 1 file changed, 5 insertions(+)
36
37 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
38 index 1a6f65db615e8..ee1f9ee995e53 100644
39 --- a/drivers/scsi/libsas/sas_expander.c
40 +++ b/drivers/scsi/libsas/sas_expander.c
41 @@ -2027,6 +2027,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
42 if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) {
43 phy->phy_state = PHY_EMPTY;
44 sas_unregister_devs_sas_addr(dev, phy_id, last);
45 + /*
46 + * Even though the PHY is empty, for convenience we discover
47 + * the PHY to update the PHY info, like negotiated linkrate.
48 + */
49 + sas_ex_phy_discover(dev, phy_id);
50 return res;
51 } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
52 dev_type_flutter(type, phy->attached_dev_type)) {
53 --
54 2.20.1
55