Revert "soc/intel/xeon_sp: Rewrite acpi_create_drhd"

This reverts commit 6995efbd1b986d0426ca513fd2e56771dd489f16.

Reason for revert: Submitted out of order and broke the coreboot build:

src/soc/intel/xeon_sp/uncore_acpi.c:275:6: error: call to undeclared function 'is_dev_on_domain0'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  275 |         if (is_dev_on_domain0(iommu)) {
      |             ^
src/soc/intel/xeon_sp/uncore_acpi.c:343:35: error: call to undeclared function 'is_dev_on_ioat_domain'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  343 |         if (CONFIG(HAVE_IOAT_DOMAINS) && is_dev_on_ioat_domain(iommu)) {
      |                                          ^
src/soc/intel/xeon_sp/uncore_acpi.c:423:4: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
  423 |                         assert(vtd_mmio_cap != 0xffffffffffffffff);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^~~~~~~~~~~~~~~~~
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^~~~~~~~~~~~~~~~~~~~~~
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^~~~~~~~~~~~~~~~
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^~~~~~~~~~~~~~~~~~~~~
src/soc/intel/xeon_sp/uncore_acpi.c:423:4: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^
src/soc/intel/xeon_sp/uncore_acpi.c:455:3: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
  455 |                 assert(ptr);
      |                 ^~~~~~~~~~~
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^~~~~~~~~~~~~~~~~
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^~~~~~~~~~~~~~~~~~~~~~
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^~~~~~~~~~~~~~~~
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^~~~~~~~~~~~~~~~~~~~~
src/soc/intel/xeon_sp/uncore_acpi.c:455:3: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^
src/soc/intel/xeon_sp/uncore_acpi.c:540:7: error: call to undeclared function 'is_domain0'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  540 |                 if (is_domain0(dev_get_pci_domain(dev))) {
      |                     ^
src/soc/intel/xeon_sp/uncore_acpi.c:546:2: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
  546 |         assert(iommu0);
      |         ^~~~~~~~~~~~~~
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^~~~~~~~~~~~~~~~~
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^~~~~~~~~~~~~~~~~~~~~~
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^~~~~~~~~~~~~~~~
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^~~~~~~~~~~~~~~~~~~~~
src/soc/intel/xeon_sp/uncore_acpi.c:546:2: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
src/include/assert.h:85:27: note: expanded from macro 'assert'
   85 | #define assert(statement)       ASSERT(statement)
      |                                 ^
src/include/assert.h:56:7: note: expanded from macro 'ASSERT'
   56 |         if (!__build_time_assert(x) && !(x)) {                          \
      |              ^
src/include/assert.h:27:40: note: expanded from macro '__build_time_assert'
   27 |         (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
      |                                               ^
src/include/assert.h:105:2: note: expanded from macro 'dead_code_t'
  105 |         *(type *)(uintptr_t)0; \
      |         ^

Change-Id: I8b66177119ea5f55913a16aae06a3dcb807c2c64
Signed-off-by: Martin Roth <gaumless@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81233
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Martin L Roth 2024-03-13 17:03:13 +00:00
parent 014ec7c704
commit 092a1398f6

View File

@ -215,12 +215,6 @@ static unsigned long acpi_fill_slit(unsigned long current)
}
#endif
static struct device *dev_find_iommu_on_stack(uint8_t socket, uint8_t stack)
{
return dev_find_all_devices_on_stack(socket, stack, PCI_VID_INTEL,
MMAP_VTD_CFG_REG_DEVID, NULL);
}
/*
* This function adds PCIe bridge device entry in DMAR table. If it is called
* in the context of ATSR subtable, it adds ATSR subtable when it is first called.
@ -258,29 +252,20 @@ static unsigned long acpi_create_drhd(unsigned long current, int socket,
int stack, const IIO_UDS *hob)
{
unsigned long tmp = current;
struct device *iommu = dev_find_iommu_on_stack(socket, stack);
if (!iommu)
return current;
struct resource *resource;
resource = probe_resource(iommu, VTD_BAR_CSR);
if (!resource)
return current;
uint32_t reg_base = resource->base;
if (!reg_base)
return current;
const uint32_t bus = iommu->upstream->secondary;
uint32_t pcie_seg = iommu->upstream->segment_group;
const STACK_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;
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);
/* Do not generate DRHD for non-PCIe stack */
if (!reg_base)
return current;
// Add DRHD Hardware Unit
if (is_stack0(socket, stack)) {
if (socket == 0 && stack == IioStack0) {
printk(BIOS_DEBUG, "[Hardware Unit Definition] Flags: 0x%x, PCI Segment Number: 0x%x, "
"Register Base Address: 0x%x\n",
DRHD_INCLUDE_PCI_ALL, pcie_seg, reg_base);
@ -293,7 +278,7 @@ static unsigned long acpi_create_drhd(unsigned long current, int socket,
}
// Add PCH IOAPIC
if (is_stack0(socket, stack)) {
if (socket == 0 && stack == IioStack0) {
union p2sb_bdf ioapic_bdf = p2sb_get_ioapic_bdf();
printk(BIOS_DEBUG, " [IOAPIC Device] Enumeration ID: 0x%x, PCI Bus Number: 0x%x, "
"PCI Path: 0x%x, 0x%x\n", get_ioapic_id(IO_APIC_ADDR), ioapic_bdf.bus,
@ -325,15 +310,17 @@ static unsigned long acpi_create_drhd(unsigned long current, int socket,
#endif
// Add PCIe Ports
if (!is_stack0(socket, stack)) {
struct device *domain = dev_get_pci_domain(iommu);
struct device *dev = NULL;
while ((dev = dev_bus_each_child(domain->downstream, dev)))
if (socket != 0 || stack != IioStack0) {
struct device *dev = pcidev_path_on_bus(bus, PCI_DEVFN(0, 0));
while (dev) {
if ((dev->hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE)
current +=
acpi_create_dmar_ds_pci_br_for_port(
current, dev, pcie_seg, false, NULL);
dev = dev->sibling;
}
#if CONFIG(SOC_INTEL_SKYLAKE_SP) || CONFIG(SOC_INTEL_COOPERLAKE_SP)
// Add VMD
if (hob->PlatformData.VMDStackEnable[socket][stack] &&
@ -348,16 +335,15 @@ static unsigned long acpi_create_drhd(unsigned long current, int socket,
}
// Add IOAT End Points (with memory resources. We don't report every End Point device.)
if (CONFIG(HAVE_IOAT_DOMAINS) && is_dev_on_ioat_domain(iommu)) {
struct device *dev = NULL;
while ((dev = dev_find_all_devices_on_stack(socket, stack,
XEONSP_VENDOR_MAX, XEONSP_DEVICE_MAX, dev)))
if (CONFIG(HAVE_IOAT_DOMAINS) && is_ioat_iio_stack_res(ri)) {
for (int b = ri->BusBase; b <= ri->BusLimit; ++b) {
struct device *dev = pcidev_path_on_bus(b, PCI_DEVFN(0, 0));
while (dev) {
/* This may also require a check for IORESOURCE_PREFETCH,
* but that would not include the FPU (4942/0) */
if ((dev->resource_list->flags &
(IORESOURCE_MEM | IORESOURCE_PCI64 | IORESOURCE_ASSIGNED)) ==
(IORESOURCE_MEM | IORESOURCE_PCI64 | IORESOURCE_ASSIGNED)) {
const uint32_t b = dev->upstream->secondary;
const uint32_t d = PCI_SLOT(dev->path.pci.devfn);
const uint32_t f = PCI_FUNC(dev->path.pci.devfn);
printk(BIOS_DEBUG, " [PCIE Endpoint Device] "
@ -365,10 +351,13 @@ static unsigned long acpi_create_drhd(unsigned long current, int socket,
" PCI Path: 0x%x, 0x%x\n", 0, b, d, f);
current += acpi_create_dmar_ds_pci(current, b, d, f);
}
dev = dev->sibling;
}
}
}
// Add HPET
if (is_stack0(socket, stack)) {
if (socket == 0 && stack == IioStack0) {
uint16_t hpet_capid = read16p(HPET_BASE_ADDRESS);
uint16_t num_hpets = (hpet_capid >> 0x08) & 0x1F; // Bits [8:12] has hpet count
printk(BIOS_SPEW, "%s hpet_capid: 0x%x, num_hpets: 0x%x\n",