Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[sfrench/cifs-2.6.git] / drivers / infiniband / hw / mthca / mthca_main.c
index 6f94b25f3acd2ec15fda43cb337164ecb0ea7ccd..266f347c670767285c138299a554de729b5b3697 100644 (file)
@@ -155,6 +155,13 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
                return -ENODEV;
        }
 
+       if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) {
+               mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than "
+                         "PCI resource 2 size of 0x%lx, aborting.\n",
+                         dev_lim->uar_size, pci_resource_len(mdev->pdev, 2));
+               return -ENODEV;
+       }
+
        mdev->limits.num_ports          = dev_lim->num_ports;
        mdev->limits.vl_cap             = dev_lim->max_vl;
        mdev->limits.mtu_cap            = dev_lim->max_mtu;
@@ -261,6 +268,10 @@ static int __devinit mthca_init_tavor(struct mthca_dev *mdev)
        }
 
        err = mthca_dev_lim(mdev, &dev_lim);
+       if (err) {
+               mthca_err(mdev, "QUERY_DEV_LIM command failed, aborting.\n");
+               goto err_disable;
+       }
 
        profile = default_profile;
        profile.num_uar   = dev_lim.uar_size / PAGE_SIZE;
@@ -924,13 +935,19 @@ enum {
 
 static struct {
        u64 latest_fw;
-       int is_memfree;
-       int is_pcie;
+       u32 flags;
 } mthca_hca_table[] = {
-       [TAVOR]        = { .latest_fw = MTHCA_FW_VER(3, 3, 3), .is_memfree = 0, .is_pcie = 0 },
-       [ARBEL_COMPAT] = { .latest_fw = MTHCA_FW_VER(4, 7, 0), .is_memfree = 0, .is_pcie = 1 },
-       [ARBEL_NATIVE] = { .latest_fw = MTHCA_FW_VER(5, 1, 0), .is_memfree = 1, .is_pcie = 1 },
-       [SINAI]        = { .latest_fw = MTHCA_FW_VER(1, 0, 1), .is_memfree = 1, .is_pcie = 1 }
+       [TAVOR]        = { .latest_fw = MTHCA_FW_VER(3, 4, 0),
+                          .flags     = 0 },
+       [ARBEL_COMPAT] = { .latest_fw = MTHCA_FW_VER(4, 7, 400),
+                          .flags     = MTHCA_FLAG_PCIE },
+       [ARBEL_NATIVE] = { .latest_fw = MTHCA_FW_VER(5, 1, 0),
+                          .flags     = MTHCA_FLAG_MEMFREE |
+                                       MTHCA_FLAG_PCIE },
+       [SINAI]        = { .latest_fw = MTHCA_FW_VER(1, 0, 800),
+                          .flags     = MTHCA_FLAG_MEMFREE |
+                                       MTHCA_FLAG_PCIE    |
+                                       MTHCA_FLAG_SINAI_OPT }
 };
 
 static int __devinit mthca_init_one(struct pci_dev *pdev,
@@ -972,8 +989,7 @@ static int __devinit mthca_init_one(struct pci_dev *pdev,
                err = -ENODEV;
                goto err_disable_pdev;
        }
-       if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM) ||
-           pci_resource_len(pdev, 2) != 1 << 23) {
+       if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
                dev_err(&pdev->dev, "Missing UAR, aborting.\n");
                err = -ENODEV;
                goto err_disable_pdev;
@@ -1021,12 +1037,9 @@ static int __devinit mthca_init_one(struct pci_dev *pdev,
 
        mdev->pdev = pdev;
 
+       mdev->mthca_flags = mthca_hca_table[id->driver_data].flags;
        if (ddr_hidden)
                mdev->mthca_flags |= MTHCA_FLAG_DDR_HIDDEN;
-       if (mthca_hca_table[id->driver_data].is_memfree)
-               mdev->mthca_flags |= MTHCA_FLAG_MEMFREE;
-       if (mthca_hca_table[id->driver_data].is_pcie)
-               mdev->mthca_flags |= MTHCA_FLAG_PCIE;
 
        /*
         * Now reset the HCA before we touch the PCI capabilities or