Lean Sheng Tan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, but someone else must approve Lean Sheng Tan: Looks good to me, approved
device/device_util: Add method to retrieve the domain

Add a function to return the PCI domain device for the specified
device. On multi PCI domain platforms this function allows to
determine which domain and thus which socket the PCI device
belongs to.

Change-Id: I0068b82e139fe7a35e6b1b91b7d386b750c80748
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/80090
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
---
M src/device/device_util.c
M src/include/device/device.h
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/device/device_util.c b/src/device/device_util.c
index edf053d..260c9b4 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -249,6 +249,19 @@
return "unknown";
}

+/* Returns the PCI domain for the given PCI device */
+struct device *dev_get_pci_domain(struct device *dev)
+{
+ /* Walk up the tree up to the PCI domain */
+ while (dev && dev->bus && !is_root_device(dev)) {
+ dev = dev->bus->dev;
+ if (dev->path.type == DEVICE_PATH_DOMAIN)
+ return dev;
+ }
+
+ return NULL;
+}
+
/**
* Allocate 64 more resources to the free list.
*
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 863299c..83588d4 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -188,6 +188,7 @@
const char *dev_name(const struct device *dev);
const char *dev_path(const struct device *dev);
u32 dev_path_encode(const struct device *dev);
+struct device *dev_get_pci_domain(struct device *dev);
void dev_set_enabled(struct device *dev, int enable);
void disable_children(struct bus *bus);
bool dev_is_active_bridge(struct device *dev);

To view, visit change 80090. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I0068b82e139fe7a35e6b1b91b7d386b750c80748
Gerrit-Change-Number: 80090
Gerrit-PatchSet: 3
Gerrit-Owner: Patrick Rudolph <patrick.rudolph@9elements.com>
Gerrit-Reviewer: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-Reviewer: Felix Held <felix-coreboot@felixheld.de>
Gerrit-Reviewer: Lean Sheng Tan <sheng.tan@9elements.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Shuo Liu <shuo.liu@intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged