[PATCH v2 09/18] pci: Add config for Enhanced Allocation

Andrew Scull ascull at google.com
Tue Mar 29 18:58:51 CEST 2022


Add a config to control whether Enhanced Allocation is supported by the
driver.

Signed-off-by: Andrew Scull <ascull at google.com>
---
 drivers/pci/Kconfig      |  7 +++++++
 drivers/pci/pci-uclass.c | 25 +++++++++++++++----------
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 47cd074aa1..fd2203420c 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -67,6 +67,13 @@ config PCI_SRIOV
 	  if available on a PCI Physical Function device and probe for
 	  applicable drivers.
 
+config PCI_ENHANCED_ALLOCATION
+	bool "Enable support for Enhanced Allocation of resources"
+	default y
+	help
+	  Enable support for Enhanced Allocation which can be used by supported
+	  devices in place of traditional BARS for allocation of resources.
+
 config PCI_ARID
         bool "Enable Alternate Routing-ID support for PCI"
         help
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 8bbeb62f2e..719656eb3a 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -645,7 +645,11 @@ int dm_pci_hose_probe_bus(struct udevice *bus)
 		return log_msg_ret("probe", -EINVAL);
 	}
 
-	ea_pos = dm_pci_find_capability(bus, PCI_CAP_ID_EA);
+	if (IS_ENABLED(CONFIG_PCI_ENHANCED_ALLOCATION))
+		ea_pos = dm_pci_find_capability(bus, PCI_CAP_ID_EA);
+	else
+		ea_pos = 0;
+
 	if (ea_pos) {
 		dm_pci_read_config8(bus, ea_pos + sizeof(u32) + sizeof(u8),
 				    &reg);
@@ -1600,15 +1604,16 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, unsigned long flags)
 			udev = pdata->pfdev;
 	}
 
-	/*
-	 * if the function supports Enhanced Allocation use that instead of
-	 * BARs
-	 * Incase of virtual functions, pdata will help read VF BEI
-	 * and EA entry size.
-	 */
-	ea_off = dm_pci_find_capability(udev, PCI_CAP_ID_EA);
-	if (ea_off)
-		return dm_pci_map_ea_bar(udev, bar, ea_off, pdata);
+	if (IS_ENABLED(CONFIG_PCI_ENHANCED_ALLOCATION)) {
+		/*
+		 * If the function supports Enhanced Allocation use that
+		 * instead of BARs. Incase of virtual functions, pdata will
+		 * help read VF BEI and EA entry size.
+		 */
+		ea_off = dm_pci_find_capability(udev, PCI_CAP_ID_EA);
+		if (ea_off)
+			return dm_pci_map_ea_bar(udev, bar, ea_off, pdata);
+	}
 
 	/* read BAR address */
 	dm_pci_read_config32(udev, bar, &bar_response);
-- 
2.35.1.1021.g381101b075-goog



More information about the U-Boot mailing list