mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00

Patch series "Remove duplicated kmap code", v3. The kmap infrastructure has been copied almost verbatim to every architecture. This series consolidates obvious duplicated code by defining core functions which call into the architectures only when needed. Some of the k[un]map_atomic() implementations have some similarities but the similarities were not sufficient to warrant further changes. In addition we remove a duplicate implementation of kmap() in DRM. This patch (of 15): Replace the use of BUG_ON(in_interrupt()) in the kmap() and kunmap() in favor of might_sleep(). Besides the benefits of might_sleep(), this normalizes the implementations such that they can be made generic in subsequent patches. Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian König <christian.koenig@amd.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: Helge Deller <deller@gmx.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Chris Zankel <chris@zankel.net> Cc: Max Filippov <jcmvbkbc@gmail.com> Link: http://lkml.kernel.org/r/20200507150004.1423069-1-ira.weiny@intel.com Link: http://lkml.kernel.org/r/20200507150004.1423069-2-ira.weiny@intel.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
/*
|
|
* include/asm-xtensa/highmem.h
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
* Public License. See the file "COPYING" in the main directory of
|
|
* this archive for more details.
|
|
*
|
|
* Copyright (C) 2003 - 2005 Tensilica Inc.
|
|
* Copyright (C) 2014 Cadence Design Systems Inc.
|
|
*/
|
|
|
|
#ifndef _XTENSA_HIGHMEM_H
|
|
#define _XTENSA_HIGHMEM_H
|
|
|
|
#include <linux/wait.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/fixmap.h>
|
|
#include <asm/kmap_types.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
#define PKMAP_BASE ((FIXADDR_START - \
|
|
(LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
|
|
#define LAST_PKMAP (PTRS_PER_PTE * DCACHE_N_COLORS)
|
|
#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
|
|
#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
|
|
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
|
|
|
|
#define kmap_prot PAGE_KERNEL_EXEC
|
|
|
|
#if DCACHE_WAY_SIZE > PAGE_SIZE
|
|
#define get_pkmap_color get_pkmap_color
|
|
static inline int get_pkmap_color(struct page *page)
|
|
{
|
|
return DCACHE_ALIAS(page_to_phys(page));
|
|
}
|
|
|
|
extern unsigned int last_pkmap_nr_arr[];
|
|
|
|
static inline unsigned int get_next_pkmap_nr(unsigned int color)
|
|
{
|
|
last_pkmap_nr_arr[color] =
|
|
(last_pkmap_nr_arr[color] + DCACHE_N_COLORS) & LAST_PKMAP_MASK;
|
|
return last_pkmap_nr_arr[color] + color;
|
|
}
|
|
|
|
static inline int no_more_pkmaps(unsigned int pkmap_nr, unsigned int color)
|
|
{
|
|
return pkmap_nr < DCACHE_N_COLORS;
|
|
}
|
|
|
|
static inline int get_pkmap_entries_count(unsigned int color)
|
|
{
|
|
return LAST_PKMAP / DCACHE_N_COLORS;
|
|
}
|
|
|
|
extern wait_queue_head_t pkmap_map_wait_arr[];
|
|
|
|
static inline wait_queue_head_t *get_pkmap_wait_queue_head(unsigned int color)
|
|
{
|
|
return pkmap_map_wait_arr + color;
|
|
}
|
|
#endif
|
|
|
|
extern pte_t *pkmap_page_table;
|
|
|
|
void *kmap_high(struct page *page);
|
|
void kunmap_high(struct page *page);
|
|
|
|
static inline void *kmap(struct page *page)
|
|
{
|
|
/* Check if this memory layout is broken because PKMAP overlaps
|
|
* page table.
|
|
*/
|
|
BUILD_BUG_ON(PKMAP_BASE <
|
|
TLBTEMP_BASE_1 + TLBTEMP_SIZE);
|
|
might_sleep();
|
|
if (!PageHighMem(page))
|
|
return page_address(page);
|
|
return kmap_high(page);
|
|
}
|
|
|
|
static inline void kunmap(struct page *page)
|
|
{
|
|
might_sleep();
|
|
if (!PageHighMem(page))
|
|
return;
|
|
kunmap_high(page);
|
|
}
|
|
|
|
static inline void flush_cache_kmaps(void)
|
|
{
|
|
flush_cache_all();
|
|
}
|
|
|
|
void *kmap_atomic(struct page *page);
|
|
void __kunmap_atomic(void *kvaddr);
|
|
|
|
void kmap_init(void);
|
|
|
|
#endif
|