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
6 [ Upstream commit d8649fc1c5e40e691d589ed825998c36a947491c ]
8 When we discover the PHY is empty in sas_rediscover_dev(), the PHY
9 information (like negotiated linkrate) is not updated.
11 As such, for a user examining sysfs for that PHY, they would see
14 root@(none)$ cd /sys/class/sas_phy/phy-0:0:20
15 root@(none)$ more negotiated_linkrate
17 root@(none)$ echo 0 > enable
18 root@(none)$ more negotiated_linkrate
21 So fix this, simply discover the PHY again, even though we know it's empty;
22 in the above example, this gives us:
24 root@(none)$ more negotiated_linkrate
27 We must do this after unregistering the device associated with the PHY
28 (in sas_unregister_devs_sas_addr()).
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>
34 drivers/scsi/libsas/sas_expander.c | 5 +++++
35 1 file changed, 5 insertions(+)
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);
46 + * Even though the PHY is empty, for convenience we discover
47 + * the PHY to update the PHY info, like negotiated linkrate.
49 + sas_ex_phy_discover(dev, phy_id);
51 } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
52 dev_type_flutter(type, phy->attached_dev_type)) {