x86/amd-iommu: attach devices to pre-allocated domains early
authorJoerg Roedel <joerg.roedel@amd.com>
Mon, 23 Nov 2009 11:50:00 +0000 (12:50 +0100)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 23 Nov 2009 11:54:17 +0000 (12:54 +0100)
For some devices the ACPI table may define unity map
requirements which must me met when the IOMMU is enabled. So
we need to attach devices to their domains as early as
possible so that these mappings are in place when needed.
This patch assigns the domains right after they are
allocated. Otherwise this can result in I/O page faults
before a driver binds to a device and BIOS is still using
it.

Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
arch/x86/kernel/amd_iommu.c

index 093bd526c94951b676032d0ea84bcbd063b50e42..b74b212475843f251e09ed9a213076d3fd5a7d88 100644 (file)
@@ -2047,10 +2047,10 @@ static void prealloc_protection_domains(void)
        struct pci_dev *dev = NULL;
        struct dma_ops_domain *dma_dom;
        struct amd_iommu *iommu;
-       u16 devid;
+       u16 devid, __devid;
 
        while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-               devid = calc_devid(dev->bus->number, dev->devfn);
+               __devid = devid = calc_devid(dev->bus->number, dev->devfn);
                if (devid > amd_iommu_last_bdf)
                        continue;
                devid = amd_iommu_alias_table[devid];
@@ -2065,6 +2065,10 @@ static void prealloc_protection_domains(void)
                init_unity_mappings_for_device(dma_dom, devid);
                dma_dom->target_dev = devid;
 
+               attach_device(iommu, &dma_dom->domain, devid);
+               if (__devid != devid)
+                       attach_device(iommu, &dma_dom->domain, __devid);
+
                list_add_tail(&dma_dom->list, &iommu_pd_list);
        }
 }
This page took 0.02639 seconds and 5 git commands to generate.