public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] intel-iommu: Fix alloc_coherent for pass-through devices
@ 2009-10-22  3:41 Alex Williamson
  2009-10-22  6:28 ` David Woodhouse
  2009-10-22 15:49 ` David Woodhouse
  0 siblings, 2 replies; 10+ messages in thread
From: Alex Williamson @ 2009-10-22  3:41 UTC (permalink / raw)
  To: dwmw2; +Cc: iommu, linux-kernel, Miller, Mike (OS Dev)

After 19943b0e (intel-iommu: Unify hardware and software passthrough
support) hardware pass-through mode devices make use of intel_dma_ops
rather than swiotlb_dma_ops.  The problem is that intel_alloc_coherent
ignores the device coherent_dma_mask when allocating the page since it
expects to remap the page and provide the device with an iova within the
coherent mask.  This breaks when we use pass-through.

The patch below crudely works around the problem, but I hope we can come
up with something better without reintroducing the dependency on
swiotlb.  The device hitting this problem is an HP smart array
controller on a Proliant G6 system.  It uses a default 32bit coherent
DMA mask, and stalls, presumably waiting on control data to change in
the wrong address space, when it gets a coherent buffer above 4G.  This
device also doesn't exactly play nice when using VT-d in anything other
than pass-through mode, so switching it into mapped mode is not really
an option.

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

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index b1e97e6..7a739ac 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2767,7 +2767,11 @@ static void *intel_alloc_coherent(struct device *hwdev, size_t size,
 
 	size = PAGE_ALIGN(size);
 	order = get_order(size);
-	flags &= ~(GFP_DMA | GFP_DMA32);
+
+	if (iommu_no_mapping(hwdev))
+		flags |= (GFP_DMA | GFP_DMA32);
+	else
+		flags &= ~(GFP_DMA | GFP_DMA32);
 
 	vaddr = (void *)__get_free_pages(flags, order);
 	if (!vaddr)



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-04  4:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22  3:41 [PATCH] intel-iommu: Fix alloc_coherent for pass-through devices Alex Williamson
2009-10-22  6:28 ` David Woodhouse
2009-10-22 12:24   ` Alex Williamson
2009-10-22 14:47     ` David Woodhouse
2009-10-22 15:00       ` FUJITA Tomonori
2009-10-22 15:01       ` Alex Williamson
2009-10-22 15:49         ` David Woodhouse
2009-11-03 23:57           ` Andrew Morton
2009-11-04  4:51             ` Alex Williamson
2009-10-22 15:49 ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox