/* Functions for global i/dcache invalidation when caching in SMP1*2* Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public Licence7* as published by the Free Software Foundation; either version8* 2 of the Licence, or (at your option) any later version.9*/10#include <linux/mm.h>11#include <asm/cacheflush.h>12#include "cache-smp.h"1314/**15* mn10300_icache_inv - Globally invalidate instruction cache16*17* Invalidate the instruction cache on all CPUs.18*/19void mn10300_icache_inv(void)20{21unsigned long flags;2223flags = smp_lock_cache();24mn10300_local_icache_inv();25smp_cache_call(SMP_ICACHE_INV, 0, 0);26smp_unlock_cache(flags);27}2829/**30* mn10300_icache_inv_page - Globally invalidate a page of instruction cache31* @start: The address of the page of memory to be invalidated.32*33* Invalidate a range of addresses in the instruction cache on all CPUs34* covering the page that includes the given address.35*/36void mn10300_icache_inv_page(unsigned long start)37{38unsigned long flags;3940start &= ~(PAGE_SIZE-1);4142flags = smp_lock_cache();43mn10300_local_icache_inv_page(start);44smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + PAGE_SIZE);45smp_unlock_cache(flags);46}4748/**49* mn10300_icache_inv_range - Globally invalidate range of instruction cache50* @start: The start address of the region to be invalidated.51* @end: The end address of the region to be invalidated.52*53* Invalidate a range of addresses in the instruction cache on all CPUs,54* between start and end-1 inclusive.55*/56void mn10300_icache_inv_range(unsigned long start, unsigned long end)57{58unsigned long flags;5960flags = smp_lock_cache();61mn10300_local_icache_inv_range(start, end);62smp_cache_call(SMP_ICACHE_INV_RANGE, start, end);63smp_unlock_cache(flags);64}6566/**67* mn10300_icache_inv_range2 - Globally invalidate range of instruction cache68* @start: The start address of the region to be invalidated.69* @size: The size of the region to be invalidated.70*71* Invalidate a range of addresses in the instruction cache on all CPUs,72* between start and start+size-1 inclusive.73*/74void mn10300_icache_inv_range2(unsigned long start, unsigned long size)75{76unsigned long flags;7778flags = smp_lock_cache();79mn10300_local_icache_inv_range2(start, size);80smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + size);81smp_unlock_cache(flags);82}8384/**85* mn10300_dcache_inv - Globally invalidate data cache86*87* Invalidate the data cache on all CPUs.88*/89void mn10300_dcache_inv(void)90{91unsigned long flags;9293flags = smp_lock_cache();94mn10300_local_dcache_inv();95smp_cache_call(SMP_DCACHE_INV, 0, 0);96smp_unlock_cache(flags);97}9899/**100* mn10300_dcache_inv_page - Globally invalidate a page of data cache101* @start: The address of the page of memory to be invalidated.102*103* Invalidate a range of addresses in the data cache on all CPUs covering the104* page that includes the given address.105*/106void mn10300_dcache_inv_page(unsigned long start)107{108unsigned long flags;109110start &= ~(PAGE_SIZE-1);111112flags = smp_lock_cache();113mn10300_local_dcache_inv_page(start);114smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + PAGE_SIZE);115smp_unlock_cache(flags);116}117118/**119* mn10300_dcache_inv_range - Globally invalidate range of data cache120* @start: The start address of the region to be invalidated.121* @end: The end address of the region to be invalidated.122*123* Invalidate a range of addresses in the data cache on all CPUs, between start124* and end-1 inclusive.125*/126void mn10300_dcache_inv_range(unsigned long start, unsigned long end)127{128unsigned long flags;129130flags = smp_lock_cache();131mn10300_local_dcache_inv_range(start, end);132smp_cache_call(SMP_DCACHE_INV_RANGE, start, end);133smp_unlock_cache(flags);134}135136/**137* mn10300_dcache_inv_range2 - Globally invalidate range of data cache138* @start: The start address of the region to be invalidated.139* @size: The size of the region to be invalidated.140*141* Invalidate a range of addresses in the data cache on all CPUs, between start142* and start+size-1 inclusive.143*/144void mn10300_dcache_inv_range2(unsigned long start, unsigned long size)145{146unsigned long flags;147148flags = smp_lock_cache();149mn10300_local_dcache_inv_range2(start, size);150smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + size);151smp_unlock_cache(flags);152}153154155