Date: Thu, 15 Aug 2013 21:06:38 +0000 (UTC) From: Jack F Vogel <jfv@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254383 - in stable/9/sys/dev: e1000 ixgbe Message-ID: <201308152106.r7FL6c2x014271@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jfv Date: Thu Aug 15 21:06:38 2013 New Revision: 254383 URL: http://svnweb.freebsd.org/changeset/base/254383 Log: MFC r254262 Further improve the msix setup, make sure pci_alloc_msix() gives us the vectors we requested, and fall back to MSI when not, also release any allocated resources before the fallback. Modified: stable/9/sys/dev/e1000/if_em.c stable/9/sys/dev/e1000/if_igb.c stable/9/sys/dev/ixgbe/ixgbe.c stable/9/sys/dev/ixgbe/ixv.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) Modified: stable/9/sys/dev/e1000/if_em.c ============================================================================== --- stable/9/sys/dev/e1000/if_em.c Thu Aug 15 20:33:17 2013 (r254382) +++ stable/9/sys/dev/e1000/if_em.c Thu Aug 15 21:06:38 2013 (r254383) @@ -2277,7 +2277,7 @@ em_local_timer(void *arg) /* Mask to use in the irq trigger */ if (adapter->msix_mem) - trigger = rxr->ims; /* RX for 82574 */ + trigger = rxr->ims; else trigger = E1000_ICS_RXDMT0; @@ -2767,23 +2767,30 @@ em_setup_msix(struct adapter *adapter) if (val >= 3) val = 3; else { - bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(EM_MSIX_BAR), adapter->msix_mem); - adapter->msix_mem = NULL; device_printf(adapter->dev, - "MSIX: incorrect vectors, using MSI\n"); + "MSIX: insufficient vectors, using MSI\n"); goto msi; } - if (pci_alloc_msix(dev, &val) == 0) { + if ((pci_alloc_msix(dev, &val) == 0) && (val == 3)) { device_printf(adapter->dev, "Using MSIX interrupts " "with %d vectors\n", val); return (val); } - /* Fall through to MSI */ + + /* + ** If MSIX alloc failed or provided us with + ** less than needed, free and fall through to MSI + */ + pci_release_msi(dev); } msi: + if (adapter->msix_mem != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + PCIR_BAR(EM_MSIX_BAR), adapter->msix_mem); + adapter->msix_mem = NULL; + } val = 1; if (pci_alloc_msi(dev, &val) == 0) { device_printf(adapter->dev,"Using an MSI interrupt\n"); Modified: stable/9/sys/dev/e1000/if_igb.c ============================================================================== --- stable/9/sys/dev/e1000/if_igb.c Thu Aug 15 20:33:17 2013 (r254382) +++ stable/9/sys/dev/e1000/if_igb.c Thu Aug 15 21:06:38 2013 (r254383) @@ -2891,13 +2891,18 @@ igb_setup_msix(struct adapter *adapter) msgs, want); goto msi; } - if (pci_alloc_msix(dev, &msgs) == 0) { + if ((pci_alloc_msix(dev, &msgs) == 0) && (msgs == want)) { device_printf(adapter->dev, "Using MSIX interrupts with %d vectors\n", msgs); adapter->num_queues = queues; return (msgs); } - /* Fallback to MSI configuration */ + /* + ** If MSIX alloc failed or provided us with + ** less than needed, free and fall through to MSI + */ + pci_release_msi(dev); + msi: if (adapter->msix_mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, @@ -2906,10 +2911,10 @@ msi: } msgs = 1; if (pci_alloc_msi(dev, &msgs) == 0) { - device_printf(adapter->dev," Using MSI interrupt\n"); + device_printf(adapter->dev," Using an MSI interrupt\n"); return (msgs); } - /* Default to a legacy interrupt */ + device_printf(adapter->dev," Using a Legacy interrupt\n"); return (0); } Modified: stable/9/sys/dev/ixgbe/ixgbe.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe.c Thu Aug 15 20:33:17 2013 (r254382) +++ stable/9/sys/dev/ixgbe/ixgbe.c Thu Aug 15 21:06:38 2013 (r254383) @@ -2456,12 +2456,18 @@ ixgbe_setup_msix(struct adapter *adapter msgs, want); goto msi; } - if (pci_alloc_msix(dev, &msgs) == 0) { + if ((pci_alloc_msix(dev, &msgs) == 0) && (msgs == want)) { device_printf(adapter->dev, "Using MSIX interrupts with %d vectors\n", msgs); adapter->num_queues = queues; return (msgs); } + /* + ** If MSIX alloc failed or provided us with + ** less than needed, free and fall through to MSI + */ + pci_release_msi(dev); + msi: if (adapter->msix_mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, Modified: stable/9/sys/dev/ixgbe/ixv.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixv.c Thu Aug 15 20:33:17 2013 (r254382) +++ stable/9/sys/dev/ixgbe/ixv.c Thu Aug 15 21:06:38 2013 (r254383) @@ -1698,11 +1698,13 @@ ixv_setup_msix(struct adapter *adapter) ** plus an additional for mailbox. */ want = 2; - if (pci_alloc_msix(dev, &want) == 0) { + if ((pci_alloc_msix(dev, &want) == 0) && (want == 2)) { device_printf(adapter->dev, "Using MSIX interrupts with %d vectors\n", want); return (want); } + /* Release in case alloc was insufficient */ + pci_release_msi(dev); out: if (adapter->msix_mem != NULL) { bus_release_resource(dev, SYS_RES_MEMORY,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308152106.r7FL6c2x014271>