scsi: mpt3sas: Fix removal and addition of vSES device during host reset
authorSreekanth Reddy <sreekanth.reddy@broadcom.com>
Tue, 10 Oct 2017 13:11:17 +0000 (18:41 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 11 Oct 2017 18:08:07 +0000 (14:08 -0400)
For Dev Handles whose value is less than HBA's phys count number, driver
would return HBA's SAS address value. As a result, for a Virtual SES
device the driver was returning the HBA's SAS address. Updated the
driver to return Virtual SES' SAS address.

[mkp: clarified commit message]

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_scsih.c

index 597fbecf001dbfa204508bcc47bf4fe6be653be2..dd2d63b16c7c92f81772fa00be0b1ea9f65b4dd3 100644 (file)
@@ -406,11 +406,6 @@ _scsih_get_sas_address(struct MPT3SAS_ADAPTER *ioc, u16 handle,
 
        *sas_address = 0;
 
-       if (handle <= ioc->sas_hba.num_phys) {
-               *sas_address = ioc->sas_hba.sas_address;
-               return 0;
-       }
-
        if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
            MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
                pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", ioc->name,
@@ -420,7 +415,15 @@ _scsih_get_sas_address(struct MPT3SAS_ADAPTER *ioc, u16 handle,
 
        ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
        if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
-               *sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
+               /* For HBA, vSES doesn't return HBA SAS address. Instead return
+                * vSES's sas address.
+                */
+               if ((handle <= ioc->sas_hba.num_phys) &&
+                  (!(le32_to_cpu(sas_device_pg0.DeviceInfo) &
+                  MPI2_SAS_DEVICE_INFO_SEP)))
+                       *sas_address = ioc->sas_hba.sas_address;
+               else
+                       *sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
                return 0;
        }