Check for the IORT before adding the ITS driver

Before adding the ITS interrupt controller driver to handle MSI/MSI-X
interrupts check if it is present in the IO Remapping Table (IORT).
If not don't attach as devices expect to use this table to find the
correct MSI interrupt controller.

Sponsored by: Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D37772
This commit is contained in:
Andrew Turner 2022-12-19 14:19:26 +00:00
parent 8de48df35c
commit 03d6e03851

View File

@ -1,5 +1,6 @@
/*-
* Copyright (c) 2016 The FreeBSD Foundation
* Copyright (c) 2022 Arm Ltd
*
* This software was developed by Andrew Turner under
* the sponsorship of the FreeBSD Foundation.
@ -393,23 +394,25 @@ gic_v3_add_children(ACPI_SUBTABLE_HEADER *entry, void *arg)
dev = arg;
sc = device_get_softc(dev);
child = device_add_child(dev, "its", -1);
if (child == NULL)
return;
di = malloc(sizeof(*di), M_GIC_V3, M_WAITOK | M_ZERO);
err = acpi_iort_its_lookup(gict->TranslationId, &xref, &pxm);
if (err != 0) {
free(di, M_GIC_V3);
return;
}
child = device_add_child(dev, "its", -1);
if (child == NULL) {
free(di, M_GIC_V3);
return;
}
di->di_gic_dinfo.gic_domain = pxm;
di->di_gic_dinfo.msi_xref = xref;
resource_list_init(&di->di_rl);
resource_list_add(&di->di_rl, SYS_RES_MEMORY, 0,
gict->BaseAddress, gict->BaseAddress + 128 * 1024 - 1,
128 * 1024);
err = acpi_iort_its_lookup(gict->TranslationId, &xref, &pxm);
if (err == 0) {
di->di_gic_dinfo.gic_domain = pxm;
di->di_gic_dinfo.msi_xref = xref;
} else {
di->di_gic_dinfo.gic_domain = -1;
di->di_gic_dinfo.msi_xref = ACPI_MSI_XREF;
}
sc->gic_nchildren++;
device_set_ivars(child, di);
}