diff mbox

[v3,3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER

Message ID 20180104130433.42813-4-yanaijie@huawei.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jason Yan Jan. 4, 2018, 1:04 p.m. UTC
From: chenxiang <chenxiang66@hisilicon.com>

The status of SAS PHY is in sas_phy->enabled. There is an issue that the
status of a remote SAS PHY may be initialized incorrectly: if disable remote
SAS PHY through sysfs interface (such as echo 0 > /sys/class/sas_phy/phy-1:0:0/enable),
then reboot the system, and we will find the status of remote SAS PHY which is
disabled before is 1 (cat /sys/class/sas_phy/phy-1:0:0/enable). But actually
the status of remote SAS PHY is disabled and the device attached is not found.

In SAS protocol, NEGOTIATED LOGICAL LINK RATE field of DISCOVER response is 0x1
when remote SAS PHY is disabled. So initialize sas_phy->enabled according to
the value of NEGOTIATED LOGICAL LINK RATE field.

Signed-off-by: chenxiang <chenxiang66@hisilicon.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 drivers/scsi/libsas/sas_expander.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Christoph Hellwig Jan. 4, 2018, 1:11 p.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Hannes Reinecke Jan. 8, 2018, 9:05 a.m. UTC | #2
On 01/04/2018 02:04 PM, Jason Yan wrote:
> From: chenxiang <chenxiang66@hisilicon.com>
> 
> The status of SAS PHY is in sas_phy->enabled. There is an issue that the
> status of a remote SAS PHY may be initialized incorrectly: if disable remote
> SAS PHY through sysfs interface (such as echo 0 > /sys/class/sas_phy/phy-1:0:0/enable),
> then reboot the system, and we will find the status of remote SAS PHY which is
> disabled before is 1 (cat /sys/class/sas_phy/phy-1:0:0/enable). But actually
> the status of remote SAS PHY is disabled and the device attached is not found.
> 
> In SAS protocol, NEGOTIATED LOGICAL LINK RATE field of DISCOVER response is 0x1
> when remote SAS PHY is disabled. So initialize sas_phy->enabled according to
> the value of NEGOTIATED LOGICAL LINK RATE field.
> 
> Signed-off-by: chenxiang <chenxiang66@hisilicon.com>
> Reviewed-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> ---
>  drivers/scsi/libsas/sas_expander.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index 6eab487..c79cfd1 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -293,6 +293,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
>  	phy->phy->minimum_linkrate = dr->pmin_linkrate;
>  	phy->phy->maximum_linkrate = dr->pmax_linkrate;
>  	phy->phy->negotiated_linkrate = phy->linkrate;
> +	phy->phy->enabled = (phy->linkrate != SAS_PHY_DISABLED);
>  
>   skip:
>  	if (new_phy)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
diff mbox

Patch

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 6eab487..c79cfd1 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -293,6 +293,7 @@  static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
 	phy->phy->minimum_linkrate = dr->pmin_linkrate;
 	phy->phy->maximum_linkrate = dr->pmax_linkrate;
 	phy->phy->negotiated_linkrate = phy->linkrate;
+	phy->phy->enabled = (phy->linkrate != SAS_PHY_DISABLED);
 
  skip:
 	if (new_phy)