diff options
-rw-r--r-- | sys/x86/iommu/intel_drv.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index b21c8460e830..dd2a3d1a631f 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -160,6 +160,27 @@ dmar_count_iter(ACPI_DMAR_HEADER *dmarh, void *arg) return (1); } +/* Remapping Hardware Static Affinity Structure lookup */ +struct rhsa_iter_arg { + uint64_t base; + u_int proxim_dom; +}; + +static int +dmar_rhsa_iter(ACPI_DMAR_HEADER *dmarh, void *arg) +{ + struct rhsa_iter_arg *ria; + ACPI_DMAR_RHSA *adr; + + if (dmarh->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) { + ria = arg; + adr = (ACPI_DMAR_RHSA *)dmarh; + if (adr->BaseAddress == ria->base) + ria->proxim_dom = adr->ProximityDomain; + } + return (1); +} + int dmar_rmrr_enable = 1; static int dmar_enable = 0; @@ -168,6 +189,7 @@ dmar_identify(driver_t *driver, device_t parent) { ACPI_TABLE_DMAR *dmartbl; ACPI_DMAR_HARDWARE_UNIT *dmarh; + struct rhsa_iter_arg ria; ACPI_STATUS status; int i, error; @@ -217,7 +239,15 @@ dmar_identify(driver_t *driver, device_t parent) i, (uintmax_t)dmarh->Address, error); device_delete_child(parent, dmar_devs[i]); dmar_devs[i] = NULL; + continue; } + + ria.base = dmarh->Address; + ria.proxim_dom = -1; + dmar_iterate_tbl(dmar_rhsa_iter, &ria); + acpi_set_domain(dmar_devs[i], ria.proxim_dom == -1 ? + ACPI_DEV_DOMAIN_UNKNOWN : + acpi_map_pxm_to_vm_domainid(ria.proxim_dom)); } } @@ -326,34 +356,12 @@ dmar_print_caps(device_t dev, struct dmar_unit *unit, DMAR_ECAP_IRO(unit->hw_ecap)); } -/* Remapping Hardware Static Affinity Structure lookup */ -struct rhsa_iter_arg { - uint64_t base; - u_int proxim_dom; -}; - -static int -dmar_rhsa_iter(ACPI_DMAR_HEADER *dmarh, void *arg) -{ - struct rhsa_iter_arg *ria; - ACPI_DMAR_RHSA *adr; - - if (dmarh->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) { - ria = arg; - adr = (ACPI_DMAR_RHSA *)dmarh; - if (adr->BaseAddress == ria->base) - ria->proxim_dom = adr->ProximityDomain; - } - return (1); -} - static int dmar_attach(device_t dev) { struct dmar_unit *unit; ACPI_DMAR_HARDWARE_UNIT *dmaru; struct iommu_msi_data *dmd; - struct rhsa_iter_arg ria; uint64_t timeout; int disable_pmr; int i, error; @@ -381,13 +389,7 @@ dmar_attach(device_t dev) if (bootverbose) dmar_print_caps(dev, unit, dmaru); dmar_quirks_post_ident(unit); - unit->memdomain = -1; - ria.base = unit->base; - ria.proxim_dom = -1; - dmar_iterate_tbl(dmar_rhsa_iter, &ria); - if (ria.proxim_dom != -1) - unit->memdomain = acpi_map_pxm_to_vm_domainid(ria.proxim_dom); - + unit->memdomain = acpi_get_domain(dev); timeout = dmar_get_timeout(); TUNABLE_UINT64_FETCH("hw.iommu.dmar.timeout", &timeout); dmar_update_timeout(timeout); |