[PATCH] IB/ipath: removed unused field ipath_kregvirt from struct ipath_devdata
[firefly-linux-kernel-4.4.55.git] / drivers / infiniband / hw / ipath / ipath_driver.c
index 58a94efb0070bb14d658ae1e32f90b2e17b9f3c0..290080b2c8f1eac519a591894d5ebfbf3fee4b42 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2006 QLogic, Inc. All rights reserved.
  * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -52,7 +53,7 @@ const char *ipath_get_unit_name(int unit)
 
 EXPORT_SYMBOL_GPL(ipath_get_unit_name);
 
-#define DRIVER_LOAD_MSG "PathScale " IPATH_DRV_NAME " loaded: "
+#define DRIVER_LOAD_MSG "QLogic " IPATH_DRV_NAME " loaded: "
 #define PFX IPATH_DRV_NAME ": "
 
 /*
@@ -74,8 +75,8 @@ MODULE_PARM_DESC(debug, "mask for debug prints");
 EXPORT_SYMBOL_GPL(ipath_debug);
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("PathScale <support@pathscale.com>");
-MODULE_DESCRIPTION("Pathscale InfiniPath driver");
+MODULE_AUTHOR("QLogic <support@pathscale.com>");
+MODULE_DESCRIPTION("QLogic InfiniPath driver");
 
 const char *ipath_ibcstatus_str[] = {
        "Disabled",
@@ -116,10 +117,9 @@ static int __devinit ipath_init_one(struct pci_dev *,
 #define PCI_DEVICE_ID_INFINIPATH_PE800 0x10
 
 static const struct pci_device_id ipath_pci_tbl[] = {
-       {PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE,
-                   PCI_DEVICE_ID_INFINIPATH_HT)},
-       {PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE,
-                   PCI_DEVICE_ID_INFINIPATH_PE800)},
+       { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_HT) },
+       { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_PE800) },
+       { 0, }
 };
 
 MODULE_DEVICE_TABLE(pci, ipath_pci_tbl);
@@ -418,9 +418,19 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
 
        ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
        if (ret) {
-               dev_info(&pdev->dev, "pci_set_dma_mask unit %u "
-                        "fails: %d\n", dd->ipath_unit, ret);
-               goto bail_regions;
+               /*
+                * if the 64 bit setup fails, try 32 bit.  Some systems
+                * do not setup 64 bit maps on systems with 2GB or less
+                * memory installed.
+                */
+               ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+               if (ret) {
+                       dev_info(&pdev->dev, "pci_set_dma_mask unit %u "
+                                "fails: %d\n", dd->ipath_unit, ret);
+                       goto bail_regions;
+               }
+               else
+                       ipath_dbg("No 64bit DMA mask, used 32 bit mask\n");
        }
 
        pci_set_master(pdev);
@@ -443,7 +453,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
                ipath_init_pe800_funcs(dd);
                break;
        default:
-               ipath_dev_err(dd, "Found unknown PathScale deviceid 0x%x, "
+               ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, "
                              "failing\n", ent->device);
                return -ENODEV;
        }
@@ -451,10 +461,10 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
        for (j = 0; j < 6; j++) {
                if (!pdev->resource[j].start)
                        continue;
-               ipath_cdbg(VERBOSE, "BAR %d start %lx, end %lx, len %lx\n",
-                          j, pdev->resource[j].start,
-                          pdev->resource[j].end,
-                          pci_resource_len(pdev, j));
+               ipath_cdbg(VERBOSE, "BAR %d start %llx, end %llx, len %llx\n",
+                          j, (unsigned long long)pdev->resource[j].start,
+                          (unsigned long long)pdev->resource[j].end,
+                          (unsigned long long)pci_resource_len(pdev, j));
        }
 
        if (!addr) {
@@ -486,10 +496,8 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
                ((void __iomem *)dd->ipath_kregbase + len);
        dd->ipath_physaddr = addr;      /* used for io_remap, etc. */
        /* for user mmap */
-       dd->ipath_kregvirt = (u64 __iomem *) phys_to_virt(addr);
-       ipath_cdbg(VERBOSE, "mapped io addr %llx to kregbase %p "
-                  "kregvirt %p\n", addr, dd->ipath_kregbase,
-                  dd->ipath_kregvirt);
+       ipath_cdbg(VERBOSE, "mapped io addr %llx to kregbase %p\n",
+                  addr, dd->ipath_kregbase);
 
        /*
         * clear ipath_flags here instead of in ipath_init_chip as it is set
@@ -536,6 +544,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
        ipath_device_create_group(&pdev->dev, dd);
        ipathfs_add_device(dd);
        ipath_user_add(dd);
+       ipath_diag_add(dd);
        ipath_layer_add(dd);
 
        goto bail;
@@ -568,8 +577,9 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev)
                return;
 
        dd = pci_get_drvdata(pdev);
-       ipath_layer_del(dd);
-       ipath_user_del(dd);
+       ipath_layer_remove(dd);
+       ipath_diag_remove(dd);
+       ipath_user_remove(dd);
        ipathfs_remove_device(dd);
        ipath_device_remove_group(&pdev->dev, dd);
        ipath_cdbg(VERBOSE, "Releasing pci memory regions, dd %p, "
@@ -1729,7 +1739,7 @@ void ipath_free_pddata(struct ipath_devdata *dd, u32 port, int freehdrq)
        }
 }
 
-int __init infinipath_init(void)
+static int __init infinipath_init(void)
 {
        int ret;
 
@@ -1797,7 +1807,6 @@ static void cleanup_device(struct ipath_devdata *dd)
                         * re-init
                         */
                        dd->ipath_kregbase = NULL;
-                       dd->ipath_kregvirt = NULL;
                        dd->ipath_uregbase = 0;
                        dd->ipath_sregbase = 0;
                        dd->ipath_cregbase = 0;
@@ -1896,19 +1905,19 @@ static void __exit infinipath_cleanup(void)
                        } else
                                ipath_dbg("irq is 0, not doing free_irq "
                                          "for unit %u\n", dd->ipath_unit);
-                       dd->pcidev = NULL;
-               }
 
-               /*
-                * we check for NULL here, because it's outside the kregbase
-                * check, and we need to call it after the free_irq.  Thus
-                * it's possible that the function pointers were never
-                * initialized.
-                */
-               if (dd->ipath_f_cleanup)
-                       /* clean up chip-specific stuff */
-                       dd->ipath_f_cleanup(dd);
+                       /*
+                        * we check for NULL here, because it's outside
+                        * the kregbase check, and we need to call it
+                        * after the free_irq.  Thus it's possible that
+                        * the function pointers were never initialized.
+                        */
+                       if (dd->ipath_f_cleanup)
+                               /* clean up chip-specific stuff */
+                               dd->ipath_f_cleanup(dd);
 
+                       dd->pcidev = NULL;
+               }
                spin_lock_irqsave(&ipath_devs_lock, flags);
        }
 
@@ -1949,7 +1958,7 @@ int ipath_reset_device(int unit)
        }
 
        if (dd->ipath_pd)
-               for (i = 1; i < dd->ipath_portcnt; i++) {
+               for (i = 1; i < dd->ipath_cfgports; i++) {
                        if (dd->ipath_pd[i] && dd->ipath_pd[i]->port_cnt) {
                                ipath_dbg("unit %u port %d is in use "
                                          "(PID %u cmd %s), can't reset\n",