]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86, AMD IOMMU: add pre-allocation of protection domains
authorJoerg Roedel <joerg.roedel@amd.com>
Thu, 26 Jun 2008 19:28:04 +0000 (21:28 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 27 Jun 2008 08:12:20 +0000 (10:12 +0200)
This patch adds a function to pre-allocate protection domains. So we don't have
to allocate it on the first request for a device (which can happen in atomic
mode).

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: Sebastian.Biemueller@amd.com
Cc: robert.richter@amd.com
Cc: joro@8bytes.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/amd_iommu.c

index aab9125ac0b2c23af0adfd4ffca959eb87460957..bed5f820898ddfa68c3c9a8a9d3bbc76b7668b94 100644 (file)
@@ -872,3 +872,37 @@ free_mem:
        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);
+       }
+}
+