[PATCH v2 1/7] scsi: libsas: reset the negotiated_linkrate when phy is down
From: Jason Yan
Date: Wed Jan 30 2019 - 03:25:56 EST
If the device is unplugged or disconnected, the negotiated_linkrate
still can be seen from the userspace by sysfs. This makes people
confused and leaks information of the device last used. So let's reset
the negotiated_linkrate after the phy is down.
Signed-off-by: Jason Yan <yanaijie@xxxxxxxxxx>
CC: John Garry <john.garry@xxxxxxxxxx>
CC: Johannes Thumshirn <jthumshirn@xxxxxxx>
CC: Ewan Milne <emilne@xxxxxxxxxx>
CC: Christoph Hellwig <hch@xxxxxx>
CC: Tomas Henzl <thenzl@xxxxxxxxxx>
CC: Dan Williams <dan.j.williams@xxxxxxxxx>
CC: Hannes Reinecke <hare@xxxxxxxx>
---
drivers/scsi/libsas/sas_expander.c | 2 ++
include/scsi/libsas.h | 3 +++
2 files changed, 5 insertions(+)
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 17eb4185f29d..7b0e6dcef6e6 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1904,6 +1904,8 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
&parent->port->sas_port_del_list);
phy->port = NULL;
}
+ if (phy->phy)
+ phy->phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
}
static int sas_discover_bfs_by_root_level(struct domain_device *root,
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 3de3b10da19a..420156cea3ee 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -448,6 +448,9 @@ static inline void sas_phy_disconnected(struct asd_sas_phy *phy)
{
phy->oob_mode = OOB_NOT_CONNECTED;
phy->linkrate = SAS_LINK_RATE_UNKNOWN;
+
+ if (phy->phy)
+ phy->phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
}
static inline unsigned int to_sas_gpio_od(int device, int bit)
--
2.14.4