[SCSI] hpsa: do not inquire for unsupported ioaccel status vpd page
authorStephen M. Cameron <scameron@beardog.cce.hp.com>
Tue, 18 Feb 2014 19:57:16 +0000 (13:57 -0600)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:07 +0000 (10:19 -0700)
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/hpsa.c
drivers/scsi/hpsa_cmd.h

index 82ae83efae98c72090c57fd7d87de618eddd144b..5d3ce25a2566783d49ad1a4ffad11fd930889b59 100644 (file)
@@ -2064,6 +2064,49 @@ static int hpsa_get_raid_map(struct ctlr_info *h,
        return rc;
 }
 
+static int hpsa_vpd_page_supported(struct ctlr_info *h,
+       unsigned char scsi3addr[], u8 page)
+{
+       int rc;
+       int i;
+       int pages;
+       unsigned char *buf, bufsize;
+
+       buf = kzalloc(256, GFP_KERNEL);
+       if (!buf)
+               return 0;
+
+       /* Get the size of the page list first */
+       rc = hpsa_scsi_do_inquiry(h, scsi3addr,
+                               VPD_PAGE | HPSA_VPD_SUPPORTED_PAGES,
+                               buf, HPSA_VPD_HEADER_SZ);
+       if (rc != 0)
+               goto exit_unsupported;
+       pages = buf[3];
+       if ((pages + HPSA_VPD_HEADER_SZ) <= 255)
+               bufsize = pages + HPSA_VPD_HEADER_SZ;
+       else
+               bufsize = 255;
+
+       /* Get the whole VPD page list */
+       rc = hpsa_scsi_do_inquiry(h, scsi3addr,
+                               VPD_PAGE | HPSA_VPD_SUPPORTED_PAGES,
+                               buf, bufsize);
+       if (rc != 0)
+               goto exit_unsupported;
+
+       pages = buf[3];
+       for (i = 1; i <= pages; i++)
+               if (buf[3 + i] == page)
+                       goto exit_supported;
+exit_unsupported:
+       kfree(buf);
+       return 0;
+exit_supported:
+       kfree(buf);
+       return 1;
+}
+
 static void hpsa_get_ioaccel_status(struct ctlr_info *h,
        unsigned char *scsi3addr, struct hpsa_scsi_dev_t *this_device)
 {
@@ -2077,6 +2120,8 @@ static void hpsa_get_ioaccel_status(struct ctlr_info *h,
        buf = kzalloc(64, GFP_KERNEL);
        if (!buf)
                return;
+       if (!hpsa_vpd_page_supported(h, scsi3addr, HPSA_VPD_LV_IOACCEL_STATUS))
+               goto out;
        rc = hpsa_scsi_do_inquiry(h, scsi3addr,
                        VPD_PAGE | HPSA_VPD_LV_IOACCEL_STATUS, buf, 64);
        if (rc != 0)
index e048167b2d9f5e332098a0239f62c837e5fe8c69..769fd2a0f2550c0e0cf4277db95a1c567f3d043f 100644 (file)
 #define CFGTBL_BusType_Fibre2G  0x00000200l
 
 /* VPD Inquiry types */
+#define HPSA_VPD_SUPPORTED_PAGES        0x00
 #define HPSA_VPD_LV_DEVICE_GEOMETRY     0xC1
 #define HPSA_VPD_LV_IOACCEL_STATUS      0xC2
+#define HPSA_VPD_HEADER_SZ              4
 
 struct vals32 {
        u32   lower;