Patchwork [11/12] libsas: fix false positive 'device attached' conditions

login
register
mail settings
Submitter Dan Williams
Date April 13, 2012, 11:37 p.m.
Message ID <20120413233747.8025.13302.stgit@dwillia2-linux.jf.intel.com>
Download mbox | patch
Permalink /patch/152450/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Dan Williams - April 13, 2012, 11:37 p.m.
Normalize phy->attached_sas_addr to return a zero-address in the case
when device-type == NO_DEVICE or the linkrate is invalid to handle
expanders that put non-zero sas addresses in the discovery response:

 sas: ex 5001b4da000f903f phy02:U:0 attached: 0100000000000000 (no device)
 sas: ex 5001b4da000f903f phy01:U:0 attached: 0100000000000000 (no device)
 sas: ex 5001b4da000f903f phy03:U:0 attached: 0100000000000000 (no device)
 sas: ex 5001b4da000f903f phy00:U:0 attached: 0100000000000000 (no device)

Reported-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/scsi/libsas/sas_expander.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Bottomley - April 22, 2012, 10:53 a.m.
On Fri, 2012-04-13 at 16:37 -0700, Dan Williams wrote:
> Normalize phy->attached_sas_addr to return a zero-address in the case
> when device-type == NO_DEVICE or the linkrate is invalid to handle
> expanders that put non-zero sas addresses in the discovery response:
> 
>  sas: ex 5001b4da000f903f phy02:U:0 attached: 0100000000000000 (no device)
>  sas: ex 5001b4da000f903f phy01:U:0 attached: 0100000000000000 (no device)
>  sas: ex 5001b4da000f903f phy03:U:0 attached: 0100000000000000 (no device)
>  sas: ex 5001b4da000f903f phy00:U:0 attached: 0100000000000000 (no device)
> 
> Reported-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

This should be flagged for stable, shouldn't it?

James


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Williams - April 22, 2012, 3:56 p.m.
On Sun, Apr 22, 2012 at 3:53 AM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Fri, 2012-04-13 at 16:37 -0700, Dan Williams wrote:
>> Normalize phy->attached_sas_addr to return a zero-address in the case
>> when device-type == NO_DEVICE or the linkrate is invalid to handle
>> expanders that put non-zero sas addresses in the discovery response:
>>
>>  sas: ex 5001b4da000f903f phy02:U:0 attached: 0100000000000000 (no device)
>>  sas: ex 5001b4da000f903f phy01:U:0 attached: 0100000000000000 (no device)
>>  sas: ex 5001b4da000f903f phy03:U:0 attached: 0100000000000000 (no device)
>>  sas: ex 5001b4da000f903f phy00:U:0 attached: 0100000000000000 (no device)
>>
>> Reported-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>
> This should be flagged for stable, shouldn't it?

Probably should yes... would be nice to not need to rebase to append a
Cc:.  So far I have the impression we could handle the review comments
with appending a new commit or two.  So If I can keep the commit ids
stable I'll just flag this one to stable@ once it goes upstream.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 75247a1..caa0525 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -245,7 +245,14 @@  static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
 	phy->attached_sata_ps   = dr->attached_sata_ps;
 	phy->attached_iproto = dr->iproto << 1;
 	phy->attached_tproto = dr->tproto << 1;
-	memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
+	/* help some expanders that fail to zero sas_address in the 'no
+	 * device' case
+	 */
+	if (phy->attached_dev_type == NO_DEVICE ||
+	    phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
+		memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
+	else
+		memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
 	phy->attached_phy_id = dr->attached_phy_id;
 	phy->phy_change_count = dr->change_count;
 	phy->routing_attr = dr->routing_attr;