]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
AMD IOMMU: add dma_supported callback
authorJoerg Roedel <joerg.roedel@amd.com>
Tue, 9 Sep 2008 16:40:46 +0000 (18:40 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 19 Sep 2008 10:59:20 +0000 (12:59 +0200)
This function determines if the AMD IOMMU implementation is responsible
for a given device. So the DMA layer can get this information from the
driver.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/amd_iommu.c

index 0cb8fd2359f52c3bda9e66df92b793ca363bcd78..a6a6f8ed1cf588661b911bc25b40bf34dee7cad2 100644 (file)
@@ -1204,6 +1204,30 @@ free_mem:
        free_pages((unsigned long)virt_addr, get_order(size));
 }
 
+/*
+ * This function is called by the DMA layer to find out if we can handle a
+ * particular device. It is part of the dma_ops.
+ */
+static int amd_iommu_dma_supported(struct device *dev, u64 mask)
+{
+       u16 bdf;
+       struct pci_dev *pcidev;
+
+       /* No device or no PCI device */
+       if (!dev || dev->bus != &pci_bus_type)
+               return 0;
+
+       pcidev = to_pci_dev(dev);
+
+       bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
+
+       /* Out of our scope? */
+       if (bdf > amd_iommu_last_bdf)
+               return 0;
+
+       return 1;
+}
+
 /*
  * The function for pre-allocating protection domains.
  *
@@ -1247,6 +1271,7 @@ static struct dma_mapping_ops amd_iommu_dma_ops = {
        .unmap_single = unmap_single,
        .map_sg = map_sg,
        .unmap_sg = unmap_sg,
+       .dma_supported = amd_iommu_dma_supported,
 };
 
 /*