Arthur Heymans has uploaded this change for review.

View Change

soc/intel/xeon_sp/cpx/acpi: Align MADT IO APIC ID's with DMAR

In MADT loop over each stack and compare it against the same IO APIC
ID table as during the DMAR table generation.

This fixes Linux (5.8) warning:
"DMAR-IR: [Firmware Bug]: ioapic 12 has no mapping iommu, interrupt
remapping will be disabled"

Change-Id: I32caf9036f0d548520b30b82324265cd4d0c3b8f
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
M src/soc/intel/xeon_sp/cpx/acpi.c
1 file changed, 42 insertions(+), 35 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/46503/1
diff --git a/src/soc/intel/xeon_sp/cpx/acpi.c b/src/soc/intel/xeon_sp/cpx/acpi.c
index a1ebc4a..c7172b2 100644
--- a/src/soc/intel/xeon_sp/cpx/acpi.c
+++ b/src/soc/intel/xeon_sp/cpx/acpi.c
@@ -78,49 +78,56 @@

unsigned long acpi_fill_madt(unsigned long current)
{
- int cur_index;
- struct iiostack_resource stack_info = {0};
+ int cur_index = 0;
+ size_t hob_size;
+ const uint8_t uds_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID;
+ const IIO_UDS *hob = fsp_find_extension_hob_by_guid(uds_guid, &hob_size);

/* With CPX-SP FSP, PCH IOAPIC is allocated with first 120 GSIs. */
- int gsi_bases[] = { 0, 0x78, 0x80, 0x88, 0x90, 0x98, 0xA0, 0xA8, 0xB0 };
- int ioapic_ids[] = { 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0x10, 0x11, 0x12 };
+ const int gsi_bases[] = { 0, 0x78, 0x80, 0x88, 0x90, 0x98, 0xA0, 0xA8, 0xB0 };
+ const int IoApicID[] = {
+ // socket 0
+ PC00_IOAPIC_ID, PC01_IOAPIC_ID, PC02_IOAPIC_ID, PC03_IOAPIC_ID,
+ PC04_IOAPIC_ID, PC05_IOAPIC_ID,
+ // socket 1
+ PC06_IOAPIC_ID, PC07_IOAPIC_ID, PC08_IOAPIC_ID, PC09_IOAPIC_ID,
+ PC10_IOAPIC_ID, PC11_IOAPIC_ID,
+ };
+
+ assert(hob != NULL && hob_size != 0);

/* Local APICs */
current = xeonsp_acpi_create_madt_lapics(current);

- cur_index = 0;
- get_iiostack_info(&stack_info);
+ /*
+ * Stack 0 has non-PCH IOAPIC and PCH IOAPIC.
+ * Add entry for PCH IOAPIC.
+ */
+ {
+ const STACK_RES *ri = &hob->PlatformData.IIO_resource[0].StackRes[0];
+ const int gsi_base = gsi_bases[cur_index];
+ printk(BIOS_DEBUG, "Adding MADT IOAPIC for PCH: ioapic_id: 0x%x, "
+ "ioapic_base: 0x%x, gsi_base: 0x%x\n",
+ PCH_IOAPIC_ID, ri->IoApicBase, gsi_base);
+ current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, PCH_IOAPIC_ID,
+ ri->IoApicBase, gsi_base);
+ cur_index++;
+ }

- for (int stack = 0; stack < stack_info.no_of_stacks; ++stack) {
- const STACK_RES *ri = &stack_info.res[stack];
- assert(cur_index < ARRAY_SIZE(ioapic_ids));
- assert(cur_index < ARRAY_SIZE(gsi_bases));
- int ioapic_id = ioapic_ids[cur_index];
- int gsi_base = gsi_bases[cur_index];
- printk(BIOS_DEBUG, "Adding MADT IOAPIC for stack: %d, ioapic_id: 0x%x, "
- "ioapic_base: 0x%x, gsi_base: 0x%x\n",
- stack, ioapic_id, ri->IoApicBase, gsi_base);
- current += acpi_create_madt_ioapic(
- (acpi_madt_ioapic_t *)current,
- ioapic_id, ri->IoApicBase, gsi_base);
- ++cur_index;

- /*
- * Stack 0 has non-PCH IOAPIC and PCH IOAPIC.
- * Add entry for PCH IOAPIC.
- */
- if (stack == 0) { /* PCH IOAPIC */
- assert(cur_index < ARRAY_SIZE(ioapic_ids));
- assert(cur_index < ARRAY_SIZE(gsi_bases));
- ioapic_id = ioapic_ids[cur_index];
- gsi_base = gsi_bases[cur_index];
- printk(BIOS_DEBUG, "Adding MADT IOAPIC for stack: %d, ioapic_id: 0x%x, "
- "ioapic_base: 0x%x, gsi_base: 0x%x\n",
- stack, ioapic_id,
- ri->IoApicBase + 0x1000, gsi_base);
- current += acpi_create_madt_ioapic(
- (acpi_madt_ioapic_t *)current,
- ioapic_id, ri->IoApicBase + 0x1000, gsi_base);
+ // DRHD
+ for (int iio = 0; iio < hob->PlatformData.numofIIO; ++iio) {
+ for (int stack = 0; stack < MAX_IIO_STACK; stack++) {
+ const STACK_RES *ri = &hob->PlatformData.IIO_resource[iio].StackRes[stack];
+ if (ri->Personality != TYPE_UBOX_IIO)
+ continue;
+ const int ioapic_id = IoApicID[(iio * MAX_IIO_STACK) + stack];
+ const int gsi_base = gsi_bases[cur_index];
+ uint32_t apic_base = ri->IoApicBase;
+ if (iio == 0 && stack == 0)
+ apic_base += 0x1000;
+ current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current,
+ ioapic_id, apic_base, gsi_base);
++cur_index;
}
}

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I32caf9036f0d548520b30b82324265cd4d0c3b8f
Gerrit-Change-Number: 46503
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange