1/* Functions for global i/dcache invalidation when caching in SMP 2 * 3 * Copyright (C) 2010 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#include <linux/mm.h> 12#include <asm/cacheflush.h> 13#include "cache-smp.h" 14 15/** 16 * mn10300_icache_inv - Globally invalidate instruction cache 17 * 18 * Invalidate the instruction cache on all CPUs. 19 */ 20void mn10300_icache_inv(void) 21{ 22 unsigned long flags; 23 24 flags = smp_lock_cache(); 25 mn10300_local_icache_inv(); 26 smp_cache_call(SMP_ICACHE_INV, 0, 0); 27 smp_unlock_cache(flags); 28} 29 30/** 31 * mn10300_icache_inv_page - Globally invalidate a page of instruction cache 32 * @start: The address of the page of memory to be invalidated. 33 * 34 * Invalidate a range of addresses in the instruction cache on all CPUs 35 * covering the page that includes the given address. 36 */ 37void mn10300_icache_inv_page(unsigned long start) 38{ 39 unsigned long flags; 40 41 start &= ~(PAGE_SIZE-1); 42 43 flags = smp_lock_cache(); 44 mn10300_local_icache_inv_page(start); 45 smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + PAGE_SIZE); 46 smp_unlock_cache(flags); 47} 48 49/** 50 * mn10300_icache_inv_range - Globally invalidate range of instruction cache 51 * @start: The start address of the region to be invalidated. 52 * @end: The end address of the region to be invalidated. 53 * 54 * Invalidate a range of addresses in the instruction cache on all CPUs, 55 * between start and end-1 inclusive. 56 */ 57void mn10300_icache_inv_range(unsigned long start, unsigned long end) 58{ 59 unsigned long flags; 60 61 flags = smp_lock_cache(); 62 mn10300_local_icache_inv_range(start, end); 63 smp_cache_call(SMP_ICACHE_INV_RANGE, start, end); 64 smp_unlock_cache(flags); 65} 66 67/** 68 * mn10300_icache_inv_range2 - Globally invalidate range of instruction cache 69 * @start: The start address of the region to be invalidated. 70 * @size: The size of the region to be invalidated. 71 * 72 * Invalidate a range of addresses in the instruction cache on all CPUs, 73 * between start and start+size-1 inclusive. 74 */ 75void mn10300_icache_inv_range2(unsigned long start, unsigned long size) 76{ 77 unsigned long flags; 78 79 flags = smp_lock_cache(); 80 mn10300_local_icache_inv_range2(start, size); 81 smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + size); 82 smp_unlock_cache(flags); 83} 84 85/** 86 * mn10300_dcache_inv - Globally invalidate data cache 87 * 88 * Invalidate the data cache on all CPUs. 89 */ 90void mn10300_dcache_inv(void) 91{ 92 unsigned long flags; 93 94 flags = smp_lock_cache(); 95 mn10300_local_dcache_inv(); 96 smp_cache_call(SMP_DCACHE_INV, 0, 0); 97 smp_unlock_cache(flags); 98} 99 100/** 101 * mn10300_dcache_inv_page - Globally invalidate a page of data cache 102 * @start: The address of the page of memory to be invalidated. 103 * 104 * Invalidate a range of addresses in the data cache on all CPUs covering the 105 * page that includes the given address. 106 */ 107void mn10300_dcache_inv_page(unsigned long start) 108{ 109 unsigned long flags; 110 111 start &= ~(PAGE_SIZE-1); 112 113 flags = smp_lock_cache(); 114 mn10300_local_dcache_inv_page(start); 115 smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + PAGE_SIZE); 116 smp_unlock_cache(flags); 117} 118 119/** 120 * mn10300_dcache_inv_range - Globally invalidate range of data cache 121 * @start: The start address of the region to be invalidated. 122 * @end: The end address of the region to be invalidated. 123 * 124 * Invalidate a range of addresses in the data cache on all CPUs, between start 125 * and end-1 inclusive. 126 */ 127void mn10300_dcache_inv_range(unsigned long start, unsigned long end) 128{ 129 unsigned long flags; 130 131 flags = smp_lock_cache(); 132 mn10300_local_dcache_inv_range(start, end); 133 smp_cache_call(SMP_DCACHE_INV_RANGE, start, end); 134 smp_unlock_cache(flags); 135} 136 137/** 138 * mn10300_dcache_inv_range2 - Globally invalidate range of data cache 139 * @start: The start address of the region to be invalidated. 140 * @size: The size of the region to be invalidated. 141 * 142 * Invalidate a range of addresses in the data cache on all CPUs, between start 143 * and start+size-1 inclusive. 144 */ 145void mn10300_dcache_inv_range2(unsigned long start, unsigned long size) 146{ 147 unsigned long flags; 148 149 flags = smp_lock_cache(); 150 mn10300_local_dcache_inv_range2(start, size); 151 smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + size); 152 smp_unlock_cache(flags); 153} 154