Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2020 14:39:25 +0000 (UTC)
From:      Michal Meloun <mmel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368698 - head/sys/dev/e1000
Message-ID:  <202012161439.0BGEdPue078228@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012161439.0BGEdPue078228>