Linux 4.6-rc6
[linux/fpc-iii.git] / arch / mn10300 / mm / cache-smp-flush.c
blobfd51af5eaf70f51df0113c8c23e5607f708be79f
1 /* Functions for global dcache flush when writeback caching in SMP
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
11 #include <linux/mm.h>
12 #include <asm/cacheflush.h>
13 #include "cache-smp.h"
15 /**
16 * mn10300_dcache_flush - Globally flush data cache
18 * Flush the data cache on all CPUs.
20 void mn10300_dcache_flush(void)
22 unsigned long flags;
24 flags = smp_lock_cache();
25 mn10300_local_dcache_flush();
26 smp_cache_call(SMP_DCACHE_FLUSH, 0, 0);
27 smp_unlock_cache(flags);
30 /**
31 * mn10300_dcache_flush_page - Globally flush a page of data cache
32 * @start: The address of the page of memory to be flushed.
34 * Flush a range of addresses in the data cache on all CPUs covering
35 * the page that includes the given address.
37 void mn10300_dcache_flush_page(unsigned long start)
39 unsigned long flags;
41 start &= ~(PAGE_SIZE-1);
43 flags = smp_lock_cache();
44 mn10300_local_dcache_flush_page(start);
45 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + PAGE_SIZE);
46 smp_unlock_cache(flags);
49 /**
50 * mn10300_dcache_flush_range - Globally flush range of data cache
51 * @start: The start address of the region to be flushed.
52 * @end: The end address of the region to be flushed.
54 * Flush a range of addresses in the data cache on all CPUs, between start and
55 * end-1 inclusive.
57 void mn10300_dcache_flush_range(unsigned long start, unsigned long end)
59 unsigned long flags;
61 flags = smp_lock_cache();
62 mn10300_local_dcache_flush_range(start, end);
63 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, end);
64 smp_unlock_cache(flags);
67 /**
68 * mn10300_dcache_flush_range2 - Globally flush range of data cache
69 * @start: The start address of the region to be flushed.
70 * @size: The size of the region to be flushed.
72 * Flush a range of addresses in the data cache on all CPUs, between start and
73 * start+size-1 inclusive.
75 void mn10300_dcache_flush_range2(unsigned long start, unsigned long size)
77 unsigned long flags;
79 flags = smp_lock_cache();
80 mn10300_local_dcache_flush_range2(start, size);
81 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + size);
82 smp_unlock_cache(flags);
85 /**
86 * mn10300_dcache_flush_inv - Globally flush and invalidate data cache
88 * Flush and invalidate the data cache on all CPUs.
90 void mn10300_dcache_flush_inv(void)
92 unsigned long flags;
94 flags = smp_lock_cache();
95 mn10300_local_dcache_flush_inv();
96 smp_cache_call(SMP_DCACHE_FLUSH_INV, 0, 0);
97 smp_unlock_cache(flags);
101 * mn10300_dcache_flush_inv_page - Globally flush and invalidate a page of data
102 * cache
103 * @start: The address of the page of memory to be flushed and invalidated.
105 * Flush and invalidate a range of addresses in the data cache on all CPUs
106 * covering the page that includes the given address.
108 void mn10300_dcache_flush_inv_page(unsigned long start)
110 unsigned long flags;
112 start &= ~(PAGE_SIZE-1);
114 flags = smp_lock_cache();
115 mn10300_local_dcache_flush_inv_page(start);
116 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + PAGE_SIZE);
117 smp_unlock_cache(flags);
121 * mn10300_dcache_flush_inv_range - Globally flush and invalidate range of data
122 * cache
123 * @start: The start address of the region to be flushed and invalidated.
124 * @end: The end address of the region to be flushed and invalidated.
126 * Flush and invalidate a range of addresses in the data cache on all CPUs,
127 * between start and end-1 inclusive.
129 void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end)
131 unsigned long flags;
133 flags = smp_lock_cache();
134 mn10300_local_dcache_flush_inv_range(start, end);
135 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, end);
136 smp_unlock_cache(flags);
140 * mn10300_dcache_flush_inv_range2 - Globally flush and invalidate range of data
141 * cache
142 * @start: The start address of the region to be flushed and invalidated.
143 * @size: The size of the region to be flushed and invalidated.
145 * Flush and invalidate a range of addresses in the data cache on all CPUs,
146 * between start and start+size-1 inclusive.
148 void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size)
150 unsigned long flags;
152 flags = smp_lock_cache();
153 mn10300_local_dcache_flush_inv_range2(start, size);
154 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + size);
155 smp_unlock_cache(flags);