mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 01:22:07 +00:00
12679a2d7e
Pull more ARM updates from Russell King. This got a fair number of conflicts with the <asm/system.h> split, but also with some other sparse-irq and header file include cleanups. They all looked pretty trivial, though. * 'for-linus' of git://git.linaro.org/people/rmk/linux-arm: (59 commits) ARM: fix Kconfig warning for HAVE_BPF_JIT ARM: 7361/1: provide XIP_VIRT_ADDR for no-MMU builds ARM: 7349/1: integrator: convert to sparse irqs ARM: 7259/3: net: JIT compiler for packet filters ARM: 7334/1: add jump label support ARM: 7333/2: jump label: detect %c support for ARM ARM: 7338/1: add support for early console output via semihosting ARM: use set_current_blocked() and block_sigmask() ARM: exec: remove redundant set_fs(USER_DS) ARM: 7332/1: extract out code patch function from kprobes ARM: 7331/1: extract out insn generation code from ftrace ARM: 7330/1: ftrace: use canonical Thumb-2 wide instruction format ARM: 7351/1: ftrace: remove useless memory checks ARM: 7316/1: kexec: EOI active and mask all interrupts in kexec crash path ARM: Versatile Express: add NO_IOPORT ARM: get rid of asm/irq.h in asm/prom.h ARM: 7319/1: Print debug info for SIGBUS in user faults ARM: 7318/1: gic: refactor irq_start assignment ARM: 7317/1: irq: avoid NULL check in for_each_irq_desc loop ARM: 7315/1: perf: add support for the Cortex-A7 PMU ...
138 lines
3.1 KiB
C
138 lines
3.1 KiB
C
/*
|
|
* arch/arm/mm/highmem.c -- ARM highmem support
|
|
*
|
|
* Author: Nicolas Pitre
|
|
* Created: september 8, 2008
|
|
* Copyright: Marvell Semiconductors Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/interrupt.h>
|
|
#include <asm/fixmap.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/tlbflush.h>
|
|
#include "mm.h"
|
|
|
|
void *kmap(struct page *page)
|
|
{
|
|
might_sleep();
|
|
if (!PageHighMem(page))
|
|
return page_address(page);
|
|
return kmap_high(page);
|
|
}
|
|
EXPORT_SYMBOL(kmap);
|
|
|
|
void kunmap(struct page *page)
|
|
{
|
|
BUG_ON(in_interrupt());
|
|
if (!PageHighMem(page))
|
|
return;
|
|
kunmap_high(page);
|
|
}
|
|
EXPORT_SYMBOL(kunmap);
|
|
|
|
void *kmap_atomic(struct page *page)
|
|
{
|
|
unsigned int idx;
|
|
unsigned long vaddr;
|
|
void *kmap;
|
|
int type;
|
|
|
|
pagefault_disable();
|
|
if (!PageHighMem(page))
|
|
return page_address(page);
|
|
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
|
/*
|
|
* There is no cache coherency issue when non VIVT, so force the
|
|
* dedicated kmap usage for better debugging purposes in that case.
|
|
*/
|
|
if (!cache_is_vivt())
|
|
kmap = NULL;
|
|
else
|
|
#endif
|
|
kmap = kmap_high_get(page);
|
|
if (kmap)
|
|
return kmap;
|
|
|
|
type = kmap_atomic_idx_push();
|
|
|
|
idx = type + KM_TYPE_NR * smp_processor_id();
|
|
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
|
/*
|
|
* With debugging enabled, kunmap_atomic forces that entry to 0.
|
|
* Make sure it was indeed properly unmapped.
|
|
*/
|
|
BUG_ON(!pte_none(get_top_pte(vaddr)));
|
|
#endif
|
|
/*
|
|
* When debugging is off, kunmap_atomic leaves the previous mapping
|
|
* in place, so the contained TLB flush ensures the TLB is updated
|
|
* with the new mapping.
|
|
*/
|
|
set_top_pte(vaddr, mk_pte(page, kmap_prot));
|
|
|
|
return (void *)vaddr;
|
|
}
|
|
EXPORT_SYMBOL(kmap_atomic);
|
|
|
|
void __kunmap_atomic(void *kvaddr)
|
|
{
|
|
unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
|
|
int idx, type;
|
|
|
|
if (kvaddr >= (void *)FIXADDR_START) {
|
|
type = kmap_atomic_idx();
|
|
idx = type + KM_TYPE_NR * smp_processor_id();
|
|
|
|
if (cache_is_vivt())
|
|
__cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
|
BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
|
|
set_top_pte(vaddr, __pte(0));
|
|
#else
|
|
(void) idx; /* to kill a warning */
|
|
#endif
|
|
kmap_atomic_idx_pop();
|
|
} else if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
|
|
/* this address was obtained through kmap_high_get() */
|
|
kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
|
|
}
|
|
pagefault_enable();
|
|
}
|
|
EXPORT_SYMBOL(__kunmap_atomic);
|
|
|
|
void *kmap_atomic_pfn(unsigned long pfn)
|
|
{
|
|
unsigned long vaddr;
|
|
int idx, type;
|
|
|
|
pagefault_disable();
|
|
|
|
type = kmap_atomic_idx_push();
|
|
idx = type + KM_TYPE_NR * smp_processor_id();
|
|
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
|
|
#ifdef CONFIG_DEBUG_HIGHMEM
|
|
BUG_ON(!pte_none(get_top_pte(vaddr)));
|
|
#endif
|
|
set_top_pte(vaddr, pfn_pte(pfn, kmap_prot));
|
|
|
|
return (void *)vaddr;
|
|
}
|
|
|
|
struct page *kmap_atomic_to_page(const void *ptr)
|
|
{
|
|
unsigned long vaddr = (unsigned long)ptr;
|
|
|
|
if (vaddr < FIXADDR_START)
|
|
return virt_to_page(ptr);
|
|
|
|
return pte_page(get_top_pte(vaddr));
|
|
}
|