All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86: unify kmap_atomic_pfn() and iomap_atomic_prot_pfn()
@ 2009-03-11 14:33 Akinobu Mita
  2009-03-11 14:34 ` [PATCH 2/2] x86: debug check for kmap_atomic_pfn " Akinobu Mita
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Akinobu Mita @ 2009-03-11 14:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86

kmap_atomic_pfn() and iomap_atomic_prot_pfn() are almost same except
pgprot. This patch removes the code duplication for these two functions.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
---
 arch/x86/include/asm/highmem.h |    1 +
 arch/x86/mm/highmem_32.c       |   17 +++++++++++------
 arch/x86/mm/iomap_32.c         |   13 ++-----------
 3 files changed, 14 insertions(+), 17 deletions(-)

Index: 2.6-mmotm/arch/x86/include/asm/highmem.h
===================================================================
--- 2.6-mmotm.orig/arch/x86/include/asm/highmem.h
+++ 2.6-mmotm/arch/x86/include/asm/highmem.h
@@ -63,6 +63,7 @@ void *kmap_atomic_prot(struct page *page
 void *kmap_atomic(struct page *page, enum km_type type);
 void kunmap_atomic(void *kvaddr, enum km_type type);
 void *kmap_atomic_pfn(unsigned long pfn, enum km_type type);
+void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot);
 struct page *kmap_atomic_to_page(void *ptr);
 
 #ifndef CONFIG_PARAVIRT
Index: 2.6-mmotm/arch/x86/mm/highmem_32.c
===================================================================
--- 2.6-mmotm.orig/arch/x86/mm/highmem_32.c
+++ 2.6-mmotm/arch/x86/mm/highmem_32.c
@@ -121,23 +121,28 @@ void kunmap_atomic(void *kvaddr, enum km
 	pagefault_enable();
 }
 
-/* This is the same as kmap_atomic() but can map memory that doesn't
- * have a struct page associated with it.
- */
-void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
 {
 	enum fixed_addresses idx;
 	unsigned long vaddr;
 
 	pagefault_disable();
 
-	idx = type + KM_TYPE_NR*smp_processor_id();
+	idx = type + KM_TYPE_NR * smp_processor_id();
 	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-	set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot));
+	set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
 	arch_flush_lazy_mmu_mode();
 
 	return (void*) vaddr;
 }
+
+/* This is the same as kmap_atomic() but can map memory that doesn't
+ * have a struct page associated with it.
+ */
+void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+{
+	return kmap_atomic_prot_pfn(pfn, type, kmap_prot);
+}
 EXPORT_SYMBOL_GPL(kmap_atomic_pfn); /* temporarily in use by i915 GEM until vmap */
 
 struct page *kmap_atomic_to_page(void *ptr)
Index: 2.6-mmotm/arch/x86/mm/iomap_32.c
===================================================================
--- 2.6-mmotm.orig/arch/x86/mm/iomap_32.c
+++ 2.6-mmotm/arch/x86/mm/iomap_32.c
@@ -18,6 +18,7 @@
 
 #include <asm/iomap.h>
 #include <asm/pat.h>
+#include <asm/highmem.h>
 #include <linux/module.h>
 
 int is_io_mapping_possible(resource_size_t base, unsigned long size)
@@ -36,11 +37,6 @@ EXPORT_SYMBOL_GPL(is_io_mapping_possible
 void *
 iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
 {
-	enum fixed_addresses idx;
-	unsigned long vaddr;
-
-	pagefault_disable();
-
 	/*
 	 * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS.
 	 * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the
@@ -50,12 +46,7 @@ iomap_atomic_prot_pfn(unsigned long pfn,
 	if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC))
 		prot = PAGE_KERNEL_UC_MINUS;
 
-	idx = type + KM_TYPE_NR*smp_processor_id();
-	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-	set_pte(kmap_pte-idx, pfn_pte(pfn, prot));
-	arch_flush_lazy_mmu_mode();
-
-	return (void*) vaddr;
+	return kmap_atomic_prot_pfn(pfn, type, prot);
 }
 EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn);
 

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

end of thread, other threads:[~2009-03-24  6:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-11 14:33 [PATCH 1/2] x86: unify kmap_atomic_pfn() and iomap_atomic_prot_pfn() Akinobu Mita
2009-03-11 14:34 ` [PATCH 2/2] x86: debug check for kmap_atomic_pfn " Akinobu Mita
2009-03-11 16:54   ` [tip:x86/mm] " Akinobu Mita
2009-03-11 15:08 ` [PATCH 1/2] x86: unify kmap_atomic_pfn() " Thomas Gleixner
2009-03-11 15:25   ` Akinobu Mita
2009-03-11 16:52     ` Ingo Molnar
2009-03-12  0:28       ` Akinobu Mita
2009-03-12 12:24         ` Ingo Molnar
2009-03-12 12:27           ` Ingo Molnar
2009-03-11 16:54 ` [tip:x86/mm] " Akinobu Mita
2009-03-13  1:39 ` [tip:x86/mm] x86: unify kmap_atomic_pfn() and iomap_atomic_prot_pfn(), fix Ingo Molnar
2009-03-14  4:19   ` [PATCH -tip 1/2] mm: introduce debug_kmap_atomic Akinobu Mita
2009-03-14  4:20     ` [PATCH -tip 2/2] mm: use debug_kmap_atomic Akinobu Mita
2009-03-14 13:15     ` [PATCH -tip 1/2] mm: introduce debug_kmap_atomic Ingo Molnar
2009-03-15 15:15       ` Akinobu Mita
2009-03-15 20:45         ` [tip:x86/mm] x86, mm: remove unnecessary include file from iomap_32.c Akinobu Mita
2009-03-23  0:23       ` [PATCH -tip 1/2] mm: introduce debug_kmap_atomic Andrew Morton
2009-03-24  6:21         ` Akinobu Mita

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.