Patchworkβ [2/5] intel-iommu: Use dma_generic_alloc_coherent() for passthrough mappings

login
register
about
Submitter Alex Williamson
Date 2009-10-26 23:25:03
Message ID <20091026232503.9646.88301.stgit@nehalem.aw>
Download mbox | patch
Permalink /patch/56009/
State Not Applicable
Headers show

Comments

Alex Williamson - 2009-10-26 23:25:03
intel_alloc_coherent() needs to follow DMA mapping convention and
make use of the coherent_dma_mask of the device.  Without this,
devices may get buffers they can't use.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
---

 drivers/pci/intel-iommu.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index b1e97e6..40be49a 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2765,6 +2765,10 @@  static void *intel_alloc_coherent(struct device *hwdev, size_t size,
 	void *vaddr;
 	int order;
 
+	if (iommu_no_mapping(hwdev))
+		return dma_generic_alloc_coherent(hwdev, size, dma_handle,
+						  flags);
+
 	size = PAGE_ALIGN(size);
 	order = get_order(size);
 	flags &= ~(GFP_DMA | GFP_DMA32);
@@ -2788,6 +2792,10 @@  static void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr,
 {
 	int order;
 
+	if (iommu_no_mapping(hwdev))
+		return dma_generic_free_coherent(hwdev, size, vaddr,
+						 dma_handle);
+
 	size = PAGE_ALIGN(size);
 	order = get_order(size);