Attention is currently required from: Arthur Heymans, Christian Walter, Johnny Lin, Lean Sheng Tan, Patrick Rudolph, Tim Chu.
Shuo Liu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81044?usp=email )
Change subject: soc/intel/xeon_sp: Add utils for VT-d BAR query ......................................................................
soc/intel/xeon_sp: Add utils for VT-d BAR query
Change-Id: Id34760ced330f879a4bb3974202e7f07d409247c Signed-off-by: Shuo Liu shuo.liu@intel.com --- M src/soc/intel/xeon_sp/include/soc/util.h M src/soc/intel/xeon_sp/uncore_acpi.c M src/soc/intel/xeon_sp/util.c 3 files changed, 38 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/81044/1
diff --git a/src/soc/intel/xeon_sp/include/soc/util.h b/src/soc/intel/xeon_sp/include/soc/util.h index 556781b..15b3902 100644 --- a/src/soc/intel/xeon_sp/include/soc/util.h +++ b/src/soc/intel/xeon_sp/include/soc/util.h @@ -4,6 +4,7 @@ #define _XEON_SP_SOC_UTIL_H_
#include <cpu/x86/msr.h> +#include <device/resource.h> #if CONFIG(USE_COREBOOT_SPECIFIC_FSP_HEADERS) #include <hob_iiouds.h> #endif @@ -35,5 +36,7 @@ bool is_ubox_stack_res(const xSTACK_RES *res); bool is_ioat_iio_stack_res(const xSTACK_RES *res); void bios_done_msr(void *unused); +struct resource *get_vtd_bar_from_stack(uint8_t socket, uint8_t stack); +struct resource *get_vtd_bar_from_dev(struct device *dev);
#endif diff --git a/src/soc/intel/xeon_sp/uncore_acpi.c b/src/soc/intel/xeon_sp/uncore_acpi.c index 3e86097..d0241c3 100644 --- a/src/soc/intel/xeon_sp/uncore_acpi.c +++ b/src/soc/intel/xeon_sp/uncore_acpi.c @@ -255,7 +255,7 @@ const xSTACK_RES *ri = &hob->PlatformData.IIO_resource[socket].StackRes[stack]; const uint32_t bus = ri->BusBase; const uint32_t pcie_seg = hob->PlatformData.CpuQpiInfo[socket].PcieSegment; - const uint32_t reg_base = ri->VtdBarAddress; + const uint32_t reg_base = get_vtd_bar_from_stack(socket, stack)->base; printk(BIOS_SPEW, "%s socket: %d, stack: %d, bus: 0x%x, pcie_seg: 0x%x, reg_base: 0x%x\n", __func__, socket, stack, bus, pcie_seg, reg_base);
@@ -404,7 +404,7 @@ if (iio_pci_domain_socket_from_dev(dev) != socket) continue; /* See if there is a resource with the appropriate index. */ - resource = probe_resource(dev, VTD_BAR_CSR); + resource = get_vtd_bar_from_dev(dev); if (!resource) continue; int stack = iio_pci_domain_stack_from_dev(dev); @@ -479,7 +479,7 @@
while ((dev = dev_find_device(PCI_VID_INTEL, MMAP_VTD_CFG_REG_DEVID, dev))) { /* See if there is a resource with the appropriate index. */ - resource = probe_resource(dev, VTD_BAR_CSR); + resource = get_vtd_bar_from_dev(dev); if (!resource) continue;
diff --git a/src/soc/intel/xeon_sp/util.c b/src/soc/intel/xeon_sp/util.c index 7fc903a..1a1e01e 100644 --- a/src/soc/intel/xeon_sp/util.c +++ b/src/soc/intel/xeon_sp/util.c @@ -5,6 +5,7 @@ #include <console/console.h> #include <delay.h> #include <device/device.h> +#include <device/resource.h> #include <device/pci.h> #include <device/pci_ids.h> #include <intelblocks/cfg.h> @@ -253,4 +254,35 @@ /* And finally, take care of the SBSP */ set_bios_init_completion_for_package(sbsp_socket_id); } + +struct resource *get_vtd_bar_from_stack(uint8_t socket, uint8_t stack) +{ + struct device *domain, *dev = NULL; + union xeon_domain_path dn; + struct resource *res; + + while ((dev = dev_find_all_devices_on_socket(socket, PCI_VID_INTEL, + MMAP_VTD_CFG_REG_DEVID, dev))) { + domain = dev_get_pci_domain(dev); + if (!domain) + continue; + dn.domain_path = domain->path.domain.domain; + if (dn.stack != stack) + continue; + res = probe_resource(dev, VTD_BAR_CSR); + if (res) + return res; + } + + return NULL; +} + +struct resource *get_vtd_bar_from_dev(struct device *dev) +{ + if (dev->vendor != PCI_VID_INTEL || + dev->device != MMAP_VTD_STACK_CFG_REG_DEVID) + return NULL; + + return probe_resource(dev, VTD_BAR_CSR); +} #endif