diff mbox

[3/3] ses: fix discovery of SATA devices in SAS enclosures

Message ID 1449688495.2226.36.camel@HansenPartnership.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

James Bottomley Dec. 9, 2015, 7:14 p.m. UTC
The current discovery routines use the VPD 0x83 inquiry page to find
the device SAS address and match it to the end point in the enclosure.
This doesn't work for SATA devices because expanders (or hosts) simply
make up an endpoint address for STP and thus the address returned by
the VPD page never matches.  Instead of doing this, for SAS attached
devices, match by the direct endpoint address instead.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 drivers/scsi/ses.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)

Comments

kernel test robot Dec. 9, 2015, 8:38 p.m. UTC | #1
Hi James,

[auto build test ERROR on v4.4-rc4]
[cannot apply to scsi/for-next next-20151209]

url:    https://github.com/0day-ci/linux/commits/James-Bottomley/Fix-the-problem-of-SATA-devices-within-SAS-enclosures/20151210-031802
config: i386-randconfig-b0-12100330 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `ses_match_to_enclosure':
>> ses.c:(.text+0x1c04ad): undefined reference to `is_sas_attached'
>> ses.c:(.text+0x1c0519): undefined reference to `sas_get_address'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
James Bottomley Dec. 9, 2015, 8:52 p.m. UTC | #2
On Thu, 2015-12-10 at 04:38 +0800, kbuild test robot wrote:
> Hi James,
> 
> [auto build test ERROR on v4.4-rc4]
> [cannot apply to scsi/for-next next-20151209]
> 
> url:    https://github.com/0day-ci/linux/commits/James-Bottomley/Fix-the-problem-of-SATA-devices-within-SAS-enclosures/20151210-031802
> config: i386-randconfig-b0-12100330 (attached as .config)
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/built-in.o: In function `ses_match_to_enclosure':
> >> ses.c:(.text+0x1c04ad): undefined reference to `is_sas_attached'
> >> ses.c:(.text+0x1c0519): undefined reference to `sas_get_address'

Oh, that's the perennial file built in but dependencies are modules
problem.  The fix is to add this line to the Kconfig for SCSI_ENCLOSURE

depends on m || SCSI_SAS_ATTRS != m

I'll post a v2 with that added.

James


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

Patch

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 7d9cec5..1736935 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -34,6 +34,8 @@ 
 #include <scsi/scsi_driver.h>
 #include <scsi/scsi_host.h>
 
+#include <scsi/scsi_transport_sas.h>
+
 struct ses_device {
 	unsigned char *page1;
 	unsigned char *page1_types;
@@ -571,31 +573,15 @@  static void ses_enclosure_data_process(struct enclosure_device *edev,
 static void ses_match_to_enclosure(struct enclosure_device *edev,
 				   struct scsi_device *sdev)
 {
-	unsigned char *desc;
 	struct efd efd = {
 		.addr = 0,
 	};
 
 	ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0);
 
-	if (!sdev->vpd_pg83_len)
-		return;
-
-	desc = sdev->vpd_pg83 + 4;
-	while (desc < sdev->vpd_pg83 + sdev->vpd_pg83_len) {
-		enum scsi_protocol proto = desc[0] >> 4;
-		u8 code_set = desc[0] & 0x0f;
-		u8 piv = desc[1] & 0x80;
-		u8 assoc = (desc[1] & 0x30) >> 4;
-		u8 type = desc[1] & 0x0f;
-		u8 len = desc[3];
-
-		if (piv && code_set == 1 && assoc == 1
-		    && proto == SCSI_PROTOCOL_SAS && type == 3 && len == 8)
-			efd.addr = get_unaligned_be64(&desc[4]);
+	if (is_sas_attached(sdev))
+		efd.addr = sas_get_address(sdev);
 
-		desc += len + 4;
-	}
 	if (efd.addr) {
 		efd.dev = &sdev->sdev_gendev;