From 120fda08b4ef4ca2af7f9f38a8972c595b6aabc7 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 18 Jan 2017 17:09:04 +0800 Subject: [PATCH] em/emx: Retry interrupt allocation with MSI Reported-by: jh32 --- sys/dev/netif/em/if_em.c | 13 ++++++++++--- sys/dev/netif/emx/if_emx.c | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sys/dev/netif/em/if_em.c b/sys/dev/netif/em/if_em.c index ec22e8650d..6c5a755d94 100644 --- a/sys/dev/netif/em/if_em.c +++ b/sys/dev/netif/em/if_em.c @@ -2334,7 +2334,7 @@ em_alloc_pci_res(struct adapter *adapter) adapter->hw.mac.type == e1000_82571 || adapter->hw.mac.type == e1000_82572)) msi_enable = 0; - +again: adapter->intr_type = pci_alloc_1intr(dev, msi_enable, &adapter->intr_rid, &intr_flags); @@ -2356,8 +2356,15 @@ em_alloc_pci_res(struct adapter *adapter) adapter->intr_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &adapter->intr_rid, intr_flags); if (adapter->intr_res == NULL) { - device_printf(dev, "Unable to allocate bus resource: " - "interrupt\n"); + device_printf(dev, "Unable to allocate bus resource: %s\n", + adapter->intr_type == PCI_INTR_TYPE_MSI ? + "MSI" : "legacy intr"); + if (!msi_enable) { + /* Retry with MSI. */ + msi_enable = 1; + adapter->flags &= ~EM_FLAG_SHARED_INTR; + goto again; + } return (ENXIO); } diff --git a/sys/dev/netif/emx/if_emx.c b/sys/dev/netif/emx/if_emx.c index 41f95d9adc..187081e3d2 100644 --- a/sys/dev/netif/emx/if_emx.c +++ b/sys/dev/netif/emx/if_emx.c @@ -538,7 +538,7 @@ emx_attach(device_t dev) (sc->hw.mac.type == e1000_82571 || sc->hw.mac.type == e1000_82572)) msi_enable = 0; - +again: /* * Allocate interrupt */ @@ -563,8 +563,14 @@ emx_attach(device_t dev) sc->intr_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->intr_rid, intr_flags); if (sc->intr_res == NULL) { - device_printf(dev, "Unable to allocate bus resource: " - "interrupt\n"); + device_printf(dev, "Unable to allocate bus resource: %s\n", + sc->intr_type == PCI_INTR_TYPE_MSI ? "MSI" : "legacy intr"); + if (!msi_enable) { + /* Retry with MSI. */ + msi_enable = 1; + sc->flags &= ~EMX_FLAG_SHARED_INTR; + goto again; + } error = ENXIO; goto fail; } -- 2.41.0