From 8a5016f99c167fe177dcc2d830cbee4ee551566e Mon Sep 17 00:00:00 2001 From: Joerg Roedel Date: Thu, 26 Jun 2008 21:28:04 +0200 Subject: [PATCH] --- yaml --- r: 99627 b: refs/heads/master c: c432f3df8ea740e2ecb27da88bd6b5a254714959 h: refs/heads/master i: 99625: 9fa7a59baedf6131b67c2d21d0a339d51c7d70a1 99623: e10fb9630b2cd4c0a5c72ea194193479055ef888 v: v3 --- [refs] | 2 +- trunk/arch/x86/kernel/amd_iommu.c | 34 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 74cbd4cf8f14..46cfbfb4c907 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5d8b53cf3f8762b2230fb3d5b4e2ff78c5e701d8 +refs/heads/master: c432f3df8ea740e2ecb27da88bd6b5a254714959 diff --git a/trunk/arch/x86/kernel/amd_iommu.c b/trunk/arch/x86/kernel/amd_iommu.c index aab9125ac0b2..bed5f820898d 100644 --- a/trunk/arch/x86/kernel/amd_iommu.c +++ b/trunk/arch/x86/kernel/amd_iommu.c @@ -872,3 +872,37 @@ static void free_coherent(struct device *dev, size_t size, free_pages((unsigned long)virt_addr, get_order(size)); } +/* + * If the driver core informs the DMA layer if a driver grabs a device + * we don't need to preallocate the protection domains anymore. + * For now we have to. + */ +void prealloc_protection_domains(void) +{ + struct pci_dev *dev = NULL; + struct dma_ops_domain *dma_dom; + struct amd_iommu *iommu; + int order = amd_iommu_aperture_order; + u16 devid; + + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + devid = (dev->bus->number << 8) | dev->devfn; + if (devid >= amd_iommu_last_bdf) + continue; + devid = amd_iommu_alias_table[devid]; + if (domain_for_device(devid)) + continue; + iommu = amd_iommu_rlookup_table[devid]; + if (!iommu) + continue; + dma_dom = dma_ops_domain_alloc(iommu, order); + if (!dma_dom) + continue; + init_unity_mappings_for_device(dma_dom, devid); + set_device_domain(iommu, &dma_dom->domain, devid); + printk(KERN_INFO "AMD IOMMU: Allocated domain %d for device ", + dma_dom->domain.id); + print_devid(devid, 1); + } +} +