From 63d973c3e94cb253d61fb82679a8497dbb955230 Mon Sep 17 00:00:00 2001 From: Michal Meloun Date: Wed, 16 Dec 2020 14:39:24 +0000 Subject: [PATCH] Use the standard method for localizing of MSI-X table bar. Current way, hardcoded value plus heuristic is not conform to the PCI(e) specification and it fails on systems where MSI-X bar is not initialized by BIOS/ACPI (many arm or arm64 systems for example). Instead, use the standard PCI(e) capability for determining of MSIX table bar address. MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D27265 --- sys/dev/e1000/if_em.c | 6 ++---- sys/dev/e1000/if_em.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 25eea74631d..185dbc84e87 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -847,9 +847,7 @@ em_if_attach_pre(if_ctx_t ctx) ** use a different BAR, so we need to keep ** track of which is used. */ - scctx->isc_msix_bar = PCIR_BAR(EM_MSIX_BAR); - if (pci_read_config(dev, scctx->isc_msix_bar, 4) == 0) - scctx->isc_msix_bar += 4; + scctx->isc_msix_bar = pci_msix_table_bar(dev); } else if (adapter->hw.mac.type >= em_mac_min) { scctx->isc_txqsizes[0] = roundup2(scctx->isc_ntxd[0]* sizeof(struct e1000_tx_desc), EM_DBA_ALIGN); scctx->isc_rxqsizes[0] = roundup2(scctx->isc_nrxd[0] * sizeof(union e1000_rx_desc_extended), EM_DBA_ALIGN); @@ -883,7 +881,7 @@ em_if_attach_pre(if_ctx_t ctx) * that it shall give MSI at least a try with other devices. */ if (adapter->hw.mac.type == e1000_82574) { - scctx->isc_msix_bar = PCIR_BAR(EM_MSIX_BAR); + scctx->isc_msix_bar = pci_msix_table_bar(dev);; } else { scctx->isc_msix_bar = -1; scctx->isc_disable_msix = 1; diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index edcab167816..d685b4aedc2 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -316,7 +316,6 @@ #define EM_BAR_MEM_TYPE_MASK 0x00000006 #define EM_BAR_MEM_TYPE_32BIT 0x00000000 #define EM_BAR_MEM_TYPE_64BIT 0x00000004 -#define EM_MSIX_BAR 3 /* On 82575 */ /* More backward compatibility */ #if __FreeBSD_version < 900000 -- 2.45.0