Author: mav
Date: Tue Dec 15 04:51:50 2015
New Revision: 292249
URL: https://svnweb.freebsd.org/changeset/base/292249

Log:
  Add MSI-X support for 26XX cards.
  
  Unlike previous, this generation does not support regular MSIs any more.

Modified:
  head/sys/dev/isp/isp_pci.c

Modified: head/sys/dev/isp/isp_pci.c
==============================================================================
--- head/sys/dev/isp/isp_pci.c  Tue Dec 15 04:46:48 2015        (r292248)
+++ head/sys/dev/isp/isp_pci.c  Tue Dec 15 04:51:50 2015        (r292249)
@@ -373,11 +373,14 @@ struct isp_pcisoftc {
        ispsoftc_t                      pci_isp;
        device_t                        pci_dev;
        struct resource *               regs;
+       struct resource *               regs1;
        struct resource *               regs2;
        void *                          irq;
        int                             iqd;
        int                             rtp;
        int                             rgd;
+       int                             rtp1;
+       int                             rgd1;
        int                             rtp2;
        int                             rgd2;
        void *                          ih;
@@ -829,6 +832,10 @@ isp_pci_attach(device_t dev)
                pcs->rgd = PCIR_BAR(0);
                pcs->regs = bus_alloc_resource_any(dev, pcs->rtp, &pcs->rgd,
                    RF_ACTIVE);
+               pcs->rtp1 = SYS_RES_MEMORY;
+               pcs->rgd1 = PCIR_BAR(2);
+               pcs->regs1 = bus_alloc_resource_any(dev, pcs->rtp1, &pcs->rgd1,
+                   RF_ACTIVE);
                pcs->rtp2 = SYS_RES_MEMORY;
                pcs->rgd2 = PCIR_BAR(4);
                pcs->regs2 = bus_alloc_resource_any(dev, pcs->rtp2, &pcs->rgd2,
@@ -936,20 +943,28 @@ isp_pci_attach(device_t dev)
        data &= ~1;
        pci_write_config(dev, PCIR_ROMADDR, data, 4);
 
-       /*
-        * Do MSI
-        *
-        * NB: MSI-X needs to be disabled for the 2432 (PCI-Express)
-        */
-       if (IS_24XX(isp) || IS_2322(isp)) {
-               pcs->msicount = pci_msi_count(dev);
-               if (pcs->msicount > 1) {
-                       pcs->msicount = 1;
+       if (IS_26XX(isp)) {
+               /* 26XX chips support only MSI-X, so start from them. */
+               pcs->msicount = imin(pci_msix_count(dev), 1);
+               if (pcs->msicount > 0 &&
+                   (i = pci_alloc_msix(dev, &pcs->msicount)) == 0) {
+                       pcs->iqd = 1;
+               } else {
+                       pcs->msicount = 0;
                }
-               if (pci_alloc_msi(dev, &pcs->msicount) == 0) {
+       }
+       if (pcs->msicount == 0 && (IS_24XX(isp) || IS_2322(isp))) {
+               /*
+                * Older chips support both MSI and MSI-X, but I have
+                * feeling that older firmware may not support MSI-X,
+                * but we have no way to check the firmware flag here.
+                */
+               pcs->msicount = imin(pci_msi_count(dev), 1);
+               if (pcs->msicount > 0 &&
+                   pci_alloc_msi(dev, &pcs->msicount) == 0) {
                        pcs->iqd = 1;
                } else {
-                       pcs->iqd = 0;
+                       pcs->msicount = 0;
                }
        }
        pcs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &pcs->iqd, 
RF_ACTIVE | RF_SHAREABLE);
@@ -1006,6 +1021,8 @@ bad:
        }
        if (pcs->regs)
                (void) bus_release_resource(dev, pcs->rtp, pcs->rgd, pcs->regs);
+       if (pcs->regs1)
+               (void) bus_release_resource(dev, pcs->rtp1, pcs->rgd1, 
pcs->regs1);
        if (pcs->regs2)
                (void) bus_release_resource(dev, pcs->rtp2, pcs->rgd2, 
pcs->regs2);
        if (pcs->pci_isp.isp_param) {
@@ -1046,6 +1063,8 @@ isp_pci_detach(device_t dev)
                pci_release_msi(dev);
        }
        (void) bus_release_resource(dev, pcs->rtp, pcs->rgd, pcs->regs);
+       if (pcs->regs1)
+               (void) bus_release_resource(dev, pcs->rtp1, pcs->rgd1, 
pcs->regs1);
        if (pcs->regs2)
                (void) bus_release_resource(dev, pcs->rtp2, pcs->rgd2, 
pcs->regs2);
        /*
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to