xtensa: support aliasing cache in k[un]map_atomic
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 14 Jul 2014 22:51:49 +0000 (02:51 +0400)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 14 Aug 2014 07:59:21 +0000 (11:59 +0400)
Map high memory pages at virtual addresses with color that match color
of their physical address. Existing cache alias management mechanisms
may be used with such pages.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/include/asm/fixmap.h
arch/xtensa/include/asm/page.h
arch/xtensa/mm/highmem.c

index a43cd5265556a948bb21c9deaa4f977664467ee0..62b507deea9da136cc26cf32388a5a3358efa251 100644 (file)
@@ -38,7 +38,8 @@ enum fixed_addresses {
 #ifdef CONFIG_HIGHMEM
        /* reserved pte's for temporary kernel mappings */
        FIX_KMAP_BEGIN,
-       FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
+       FIX_KMAP_END = FIX_KMAP_BEGIN +
+               (KM_TYPE_NR * NR_CPUS * DCACHE_N_COLORS) - 1,
 #endif
        __end_of_fixed_addresses
 };
index 11721ccd7f238e5426cf4669d1bae1adee1be23e..abe24c6f8b2f06f112f9e9933306bcdd5a924d4d 100644 (file)
@@ -78,7 +78,9 @@
 # define DCACHE_ALIAS_EQ(a,b)  ((((a) ^ (b)) & DCACHE_ALIAS_MASK) == 0)
 #else
 # define DCACHE_ALIAS_ORDER    0
+# define DCACHE_ALIAS(a)       ((void)(a), 0)
 #endif
+#define DCACHE_N_COLORS                (1 << DCACHE_ALIAS_ORDER)
 
 #if ICACHE_WAY_SIZE > PAGE_SIZE
 # define ICACHE_ALIAS_ORDER    (ICACHE_WAY_SHIFT - PAGE_SHIFT)
index 2e95a7665bf352de668f102baf5e9070fac9efb3..466abaed53828da5ff35ef5f741eeec25621b517 100644 (file)
 
 static pte_t *kmap_pte;
 
+static inline enum fixed_addresses kmap_idx(int type, unsigned long color)
+{
+       return (type + KM_TYPE_NR * smp_processor_id()) * DCACHE_N_COLORS +
+               color;
+}
+
 void *kmap_atomic(struct page *page)
 {
        enum fixed_addresses idx;
        unsigned long vaddr;
-       int type;
 
        pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
 
-       type = kmap_atomic_idx_push();
-       idx = type + KM_TYPE_NR * smp_processor_id();
+       idx = kmap_idx(kmap_atomic_idx_push(),
+                      DCACHE_ALIAS(page_to_phys(page)));
        vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 #ifdef CONFIG_DEBUG_HIGHMEM
        BUG_ON(!pte_none(*(kmap_pte + idx)));
@@ -38,12 +43,10 @@ EXPORT_SYMBOL(kmap_atomic);
 
 void __kunmap_atomic(void *kvaddr)
 {
-       int idx, type;
-
        if (kvaddr >= (void *)FIXADDR_START &&
            kvaddr < (void *)FIXADDR_TOP) {
-               type = kmap_atomic_idx();
-               idx = type + KM_TYPE_NR * smp_processor_id();
+               int idx = kmap_idx(kmap_atomic_idx(),
+                                  DCACHE_ALIAS((unsigned long)kvaddr));
 
                /*
                 * Force other mappings to Oops if they'll try to access this
This page took 0.028346 seconds and 5 git commands to generate.