]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mpt2sas, mpt3sas: Abort initialization if no memory I/O resources detected
authorSreekanth Reddy <sreekanth.reddy@avagotech.com>
Wed, 15 Jul 2015 04:49:56 +0000 (10:19 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 20 Oct 2015 19:23:35 +0000 (15:23 -0400)
Driver crashes if the BIOS do not set up at least one
memory I/O resource. This failure can happen if the device is too
slow to respond during POST and is missed by the BIOS, but Linux
then detects the device later in the boot process.

Based on a patch from Timothy Pearson <tpearson@raptorengineeringinc.com>

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
(cherry picked from commit 5aeeb78aeb4c8607cbda54a7b0dc7315171e214f)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt2sas/mpt2sas_base.c
drivers/scsi/mpt3sas/mpt3sas_base.c

index 60fefcad69e26744c6002b64fc5e260d7bf46793..c167911221e96af131039171ecc7a07e4e34a987 100644 (file)
@@ -1560,7 +1560,8 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
                goto out_fail;
        }
 
-       for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) {
+       for (i = 0, memap_sz = 0, pio_sz = 0; (i < DEVICE_COUNT_RESOURCE) &&
+            (!memap_sz || !pio_sz); i++) {
                if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
                        if (pio_sz)
                                continue;
@@ -1575,16 +1576,17 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
                                chip_phys = (u64)ioc->chip_phys;
                                memap_sz = pci_resource_len(pdev, i);
                                ioc->chip = ioremap(ioc->chip_phys, memap_sz);
-                               if (ioc->chip == NULL) {
-                                       printk(MPT2SAS_ERR_FMT "unable to map "
-                                           "adapter memory!\n", ioc->name);
-                                       r = -EINVAL;
-                                       goto out_fail;
-                               }
                        }
                }
        }
 
+       if (ioc->chip == NULL) {
+               printk(MPT2SAS_ERR_FMT "unable to map adapter memory! "
+                      "or resource not found\n", ioc->name);
+               r = -EINVAL;
+               goto out_fail;
+       }
+
        _base_mask_interrupts(ioc);
 
        r = _base_get_ioc_facts(ioc, CAN_SLEEP);
index 14a781b6b88dad852a40311f86e2b58e0e2a7785..43f87e904b9886a89caab3e0a1560f485f2ee12e 100644 (file)
@@ -1843,7 +1843,8 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
                goto out_fail;
        }
 
-       for (i = 0, memap_sz = 0, pio_sz = 0 ; i < DEVICE_COUNT_RESOURCE; i++) {
+       for (i = 0, memap_sz = 0, pio_sz = 0; (i < DEVICE_COUNT_RESOURCE) &&
+            (!memap_sz || !pio_sz); i++) {
                if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
                        if (pio_sz)
                                continue;
@@ -1856,15 +1857,16 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
                        chip_phys = (u64)ioc->chip_phys;
                        memap_sz = pci_resource_len(pdev, i);
                        ioc->chip = ioremap(ioc->chip_phys, memap_sz);
-                       if (ioc->chip == NULL) {
-                               pr_err(MPT3SAS_FMT "unable to map adapter memory!\n",
-                                       ioc->name);
-                               r = -EINVAL;
-                               goto out_fail;
-                       }
                }
        }
 
+       if (ioc->chip == NULL) {
+               pr_err(MPT3SAS_FMT "unable to map adapter memory! "
+                       " or resource not found\n", ioc->name);
+               r = -EINVAL;
+               goto out_fail;
+       }
+
        _base_mask_interrupts(ioc);
 
        r = _base_get_ioc_facts(ioc, CAN_SLEEP);