When we failed to discover the device, the phy address is still kept
in ex_phy. So when the next time we revalidate this phy the
address and device type is the same, it will be considered as flutter
and will not be discovered again. So the device will not be brought up.

Fix this by reset the phy address to the initial value. Then
in the next revalidation the device will be discovered agian.

Tested-by: Chen Liangfei <chenliangf...@huawei.com>
Signed-off-by: Jason Yan <yanai...@huawei.com>
CC: Xiaofei Tan <tanxiao...@huawei.com>
CC: John Garry <john.ga...@huawei.com>
CC: Johannes Thumshirn <jthumsh...@suse.de>
CC: Ewan Milne <emi...@redhat.com>
CC: Christoph Hellwig <h...@lst.de>
CC: Tomas Henzl <the...@redhat.com>
CC: Dan Williams <dan.j.willi...@intel.com>
CC: Hannes Reinecke <h...@suse.com>
---
 drivers/scsi/libsas/sas_expander.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 6e56ebdc2148..e781941a7088 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1100,6 +1100,13 @@ static int sas_ex_discover_dev(struct domain_device 
*dev, int phy_id)
                                                 i, 
SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
                        }
                }
+       } else {
+               /* if we failed to discover this device, we have to
+                * reset the expander phy attached address so that we
+                * will not treat the phy as flutter in the next
+                * revalidation
+                */
+               memset(ex_phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
        }
 
        return res;
-- 
2.14.4

Reply via email to