David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 1 | /* MN10300 TLB flushing functions |
| 2 | * |
| 3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | #ifndef _ASM_TLBFLUSH_H |
| 12 | #define _ASM_TLBFLUSH_H |
| 13 | |
| 14 | #include <asm/processor.h> |
| 15 | |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 16 | /** |
| 17 | * local_flush_tlb - Flush the current MM's entries from the local CPU's TLBs |
| 18 | */ |
| 19 | static inline void local_flush_tlb(void) |
| 20 | { |
| 21 | int w; |
| 22 | asm volatile( |
| 23 | " mov %1,%0 \n" |
| 24 | " or %2,%0 \n" |
| 25 | " mov %0,%1 \n" |
| 26 | : "=d"(w) |
| 27 | : "m"(MMUCTR), "i"(MMUCTR_IIV|MMUCTR_DIV) |
| 28 | : "cc", "memory"); |
| 29 | } |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 30 | |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 31 | /** |
| 32 | * local_flush_tlb_all - Flush all entries from the local CPU's TLBs |
| 33 | */ |
| 34 | #define local_flush_tlb_all() local_flush_tlb() |
| 35 | |
| 36 | /** |
| 37 | * local_flush_tlb_one - Flush one entry from the local CPU's TLBs |
| 38 | */ |
| 39 | #define local_flush_tlb_one(addr) local_flush_tlb() |
| 40 | |
| 41 | /** |
| 42 | * local_flush_tlb_page - Flush a page's entry from the local CPU's TLBs |
| 43 | * @mm: The MM to flush for |
| 44 | * @addr: The address of the target page in RAM (not its page struct) |
| 45 | */ |
| 46 | extern void local_flush_tlb_page(struct mm_struct *mm, unsigned long addr); |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 47 | |
| 48 | |
| 49 | /* |
| 50 | * TLB flushing: |
| 51 | * |
| 52 | * - flush_tlb() flushes the current mm struct TLBs |
| 53 | * - flush_tlb_all() flushes all processes TLBs |
| 54 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's |
| 55 | * - flush_tlb_page(vma, vmaddr) flushes one page |
| 56 | * - flush_tlb_range(mm, start, end) flushes a range of pages |
| 57 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables |
| 58 | */ |
| 59 | #define flush_tlb_all() \ |
| 60 | do { \ |
| 61 | preempt_disable(); \ |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 62 | local_flush_tlb_all(); \ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 63 | preempt_enable(); \ |
| 64 | } while (0) |
| 65 | |
| 66 | #define flush_tlb_mm(mm) \ |
| 67 | do { \ |
| 68 | preempt_disable(); \ |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 69 | local_flush_tlb_all(); \ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 70 | preempt_enable(); \ |
| 71 | } while (0) |
| 72 | |
| 73 | #define flush_tlb_range(vma, start, end) \ |
| 74 | do { \ |
| 75 | unsigned long __s __attribute__((unused)) = (start); \ |
| 76 | unsigned long __e __attribute__((unused)) = (end); \ |
| 77 | preempt_disable(); \ |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 78 | local_flush_tlb_all(); \ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 79 | preempt_enable(); \ |
| 80 | } while (0) |
| 81 | |
David Howells | 492e675 | 2010-10-27 17:28:49 +0100 | [diff] [blame^] | 82 | #define flush_tlb_page(vma, addr) local_flush_tlb_page((vma)->vm_mm, addr) |
| 83 | #define flush_tlb() flush_tlb_all() |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 84 | |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 85 | #define flush_tlb_kernel_range(start, end) \ |
| 86 | do { \ |
| 87 | unsigned long __s __attribute__((unused)) = (start); \ |
| 88 | unsigned long __e __attribute__((unused)) = (end); \ |
| 89 | flush_tlb_all(); \ |
| 90 | } while (0) |
| 91 | |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 92 | #define flush_tlb_pgtables(mm, start, end) do {} while (0) |
| 93 | |
| 94 | #endif /* _ASM_TLBFLUSH_H */ |