Patrick Rudolph has uploaded this change for review.

View Change

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>
---
M src/device/device_util.c
M src/include/device/device.h
2 files changed, 19 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/80090/1
diff --git a/src/device/device_util.c b/src/device/device_util.c
index ac2d33c..c17b4c5 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -257,6 +257,24 @@
return buffer;
}

+/* Returns the PCI domain for the given PCI device */
+struct device *dev_get_pci_domain(struct device *dev)
+{
+ if (!dev)
+ return NULL;
+
+ /* Walk up the tree up to the PCI domain */
+ while (dev->bus) {
+ dev = dev->bus->dev;
+ if (!dev)
+ break;
+ 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 50307e6..860d110 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -190,6 +190,7 @@
const char *dev_path(const struct device *dev);
u32 dev_path_encode(const struct device *dev);
const char *bus_path(struct bus *bus);
+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: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph@9elements.com>
Gerrit-MessageType: newchange