lkml.org 
[lkml]   [2011]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 2/2] x86 amd_gart_64: Verify we can perform the remapping requested

Recently I had a driver try with a peculiar 2G dma memory limit.
The driver failed in weird and strange ways because the GART remapping
apperture had been allocated above 2G where the driver cound not reach,
and no error was reported when the mappings were setup.

Implement gart_dma_supported to test for this problem case and to return
and error if we can not support the remapping.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
arch/x86/kernel/amd_gart_64.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c
index 8a439d3..66279cb 100644
--- a/arch/x86/kernel/amd_gart_64.c
+++ b/arch/x86/kernel/amd_gart_64.c
@@ -519,6 +519,14 @@ static int gart_mapping_error(struct device *dev, dma_addr_t dma_addr)
return (dma_addr == bad_dma_addr);
}

+static int gart_dma_supported(struct device *dev, u64 mask)
+{
+ unsigned long iommu_max_addr = iommu_bus_base + iommu_size - 1;
+
+ /* Fail if the gart window is too high to fit in the devices dma mask */
+ return iommu_max_addr <= mask;
+}
+
static int no_agp;

static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size)
@@ -703,6 +711,7 @@ static struct dma_map_ops gart_dma_ops = {
.alloc_coherent = gart_alloc_coherent,
.free_coherent = gart_free_coherent,
.mapping_error = gart_mapping_error,
+ .dma_supported = gart_dma_supported,
};

static void gart_iommu_shutdown(void)
--
1.7.2.5


\
 
 \ /
  Last update: 2011-10-19 23:39    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site