Author: mmel
Date: Wed Dec 16 14:39:24 2020
New Revision: 368698
URL: https://svnweb.freebsd.org/changeset/base/368698

Log:
  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

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_em.h

Modified: head/sys/dev/e1000/if_em.c
==============================================================================
--- head/sys/dev/e1000/if_em.c  Wed Dec 16 14:36:57 2020        (r368697)
+++ head/sys/dev/e1000/if_em.c  Wed Dec 16 14:39:24 2020        (r368698)
@@ -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;

Modified: head/sys/dev/e1000/if_em.h
==============================================================================
--- head/sys/dev/e1000/if_em.h  Wed Dec 16 14:36:57 2020        (r368697)
+++ head/sys/dev/e1000/if_em.h  Wed Dec 16 14:39:24 2020        (r368698)
@@ -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
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to