aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>2009-02-24 17:35:14 -0800
committerIngo Molnar <mingo@elte.hu>2009-02-25 13:09:52 +0100
commit17581ad812a9abb0182260374ef2e52d4a808a64 (patch)
treed105f3b5bffb879c57516d7a477e787104183d52 /arch/x86/mm
parentgpu/drm, x86, PAT: routine to keep identity map in sync (diff)
downloadlinux-dev-17581ad812a9abb0182260374ef2e52d4a808a64.tar.xz
linux-dev-17581ad812a9abb0182260374ef2e52d4a808a64.zip
gpu/drm, x86, PAT: PAT support for io_mapping_*
Make io_mapping_create_wc and io_mapping_free go through PAT to make sure that there are no memory type aliases. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Eric Anholt <eric@anholt.net> Cc: Keith Packard <keithp@keithp.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r--arch/x86/mm/iomap_32.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
index 6c2b1af16926..94596f794b1b 100644
--- a/arch/x86/mm/iomap_32.c
+++ b/arch/x86/mm/iomap_32.c
@@ -21,13 +21,13 @@
#include <linux/module.h>
#ifdef CONFIG_X86_PAE
-int
+static int
is_io_mapping_possible(resource_size_t base, unsigned long size)
{
return 1;
}
#else
-int
+static int
is_io_mapping_possible(resource_size_t base, unsigned long size)
{
/* There is no way to map greater than 1 << 32 address without PAE */
@@ -38,6 +38,44 @@ is_io_mapping_possible(resource_size_t base, unsigned long size)
}
#endif
+int
+reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot)
+{
+ unsigned long ret_flag;
+
+ if (!is_io_mapping_possible(base, size))
+ goto out_err;
+
+ if (!pat_enabled) {
+ *prot = pgprot_noncached(PAGE_KERNEL);
+ return 0;
+ }
+
+ if (reserve_memtype(base, base + size, _PAGE_CACHE_WC, &ret_flag))
+ goto out_err;
+
+ if (ret_flag == _PAGE_CACHE_WB)
+ goto out_free;
+
+ if (kernel_map_sync_memtype(base, size, ret_flag))
+ goto out_free;
+
+ *prot = __pgprot(__PAGE_KERNEL | ret_flag);
+ return 0;
+
+out_free:
+ free_memtype(base, base + size);
+out_err:
+ return -EINVAL;
+}
+
+void
+free_io_memtype(u64 base, unsigned long size)
+{
+ if (pat_enabled)
+ free_memtype(base, base + size);
+}
+
/* Map 'pfn' using fixed map 'type' and protections 'prot'
*/
void *