Skip to content

Commit efdcad6

Browse files
John Garrymartinkpetersen
authored andcommitted
scsi: hisi_sas: Set PHY linkrate when disconnected
When the PHY comes down, we currently do not set the negotiated linkrate: root@(none)$ pwd /sys/class/sas_phy/phy-0:0 root@(none)$ more enable 1 root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$ echo 0 > enable root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$ This patch fixes the driver code to set it properly when the PHY comes down. If the PHY had been enabled, then set unknown; otherwise, flag as disabled. The logical place to set the negotiated linkrate for this scenario is PHY down routine, which is called from the PHY down ISR. However, it is not possible to know if the PHY comes down due to PHY disable or loss of link, as sas_phy.enabled member is not set until after the transport disable routine is complete, which races with the PHY down ISR. As an imperfect solution, use sas_phy_data.enable as the flag to know if the PHY is down due to disable. It's imperfect, as sas_phy_data is internal to libsas. I can't see another way without adding a new field to hisi_sas_phy and managing it, or changing SCSI SAS transport. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent aaeb823 commit efdcad6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include "hisi_sas.h"
13+
#include "../libsas/sas_internal.h"
1314
#define DRV_NAME "hisi_sas"
1415

1516
#define DEV_IS_GONE(dev) \
@@ -2126,9 +2127,18 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type,
21262127

21272128
static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy)
21282129
{
2130+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
2131+
struct sas_phy *sphy = sas_phy->phy;
2132+
struct sas_phy_data *d = sphy->hostdata;
2133+
21292134
phy->phy_attached = 0;
21302135
phy->phy_type = 0;
21312136
phy->port = NULL;
2137+
2138+
if (d->enable)
2139+
sphy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
2140+
else
2141+
sphy->negotiated_linkrate = SAS_PHY_DISABLED;
21322142
}
21332143

21342144
void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy)

0 commit comments

Comments
 (0)