From f360277f2f931a48c07f9e4ebf84cd712abd83a5 Mon Sep 17 00:00:00 2001 From: liangliang-quan Date: Tue, 18 Feb 2014 10:12:00 +0800 Subject: [PATCH] Create fake ivmd table to make via xhci work on GA-F2A88X-UP4 --- drivers/iommu/amd_iommu_init.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 28b4bea..1c762be 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "amd_iommu_proto.h" #include "amd_iommu_types.h" @@ -1492,6 +1493,9 @@ static int __init init_memory_definitions(struct acpi_table_header *table) { u8 *p = (u8 *)table, *end = (u8 *)table; struct ivmd_header *m; + struct ivmd_header via_xhci; + int map_areas = 0; + int reserved_areas = 0; end += table->length; p += IVRS_HEADER_LENGTH; @@ -1506,6 +1510,35 @@ static int __init init_memory_definitions(struct acpi_table_header *table) p += m->length; } + /* + * Create fake ivmd table for via_xhci. + * VIA XHCI on GA-F2A88X-UP4 directly accesses address of reserved area + * which leads to IOMMU attempts to translate this phy address as + * a virtual address, then IO_PAGE_FAULT occurs. + * This phy address should not be translated by IOMMU, but ACPI + * does not excludes it. + * We create a fake ivmd table to exclude this area. + * Then VIA XHCI can work. + */ + via_xhci.type = ACPI_IVMD_TYPE; + via_xhci.flags = IVMD_FLAG_EXCL_RANGE; + via_xhci.length = 32; + /* device id of VIA XHCI */ + via_xhci.devid = 0x0300; + /* iter all the map areas to find the 3rd reserved area */ + for (map_areas = 0; map_areas < e820_saved.nr_map; map_areas++) { + if (e820_saved.map[map_areas].type == E820_RESERVED) { + reserved_areas++; + } + /* the address varies but always in the 3rd reserved area */ + if (reserved_areas == 3) { + via_xhci.range_start = e820_saved.map[map_areas].addr; + via_xhci.range_length = e820_saved.map[map_areas].size; + init_exclusion_range(&via_xhci); + break; + } + } + return 0; } -- 1.7.9.5