aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300/mm/cache-smp-inv.c
blob: ff1787358c8e6d3c6d65ae40bbc275e2fce35e94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Functions for global i/dcache invalidation when caching in SMP
 *
 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public Licence
 * as published by the Free Software Foundation; either version
 * 2 of the Licence, or (at your option) any later version.
 */
#include <linux/mm.h>
#include <asm/cacheflush.h>
#include "cache-smp.h"

/**
 * mn10300_icache_inv - Globally invalidate instruction cache
 *
 * Invalidate the instruction cache on all CPUs.
 */
void mn10300_icache_inv(void)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_icache_inv();
	smp_cache_call(SMP_ICACHE_INV, 0, 0);
	smp_unlock_cache(flags);
}

/**
 * mn10300_icache_inv_page - Globally invalidate a page of instruction cache
 * @start: The address of the page of memory to be invalidated.
 *
 * Invalidate a range of addresses in the instruction cache on all CPUs
 * covering the page that includes the given address.
 */
void mn10300_icache_inv_page(unsigned long start)
{
	unsigned long flags;

	start &= ~(PAGE_SIZE-1);

	flags = smp_lock_cache();
	mn10300_local_icache_inv_page(start);
	smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + PAGE_SIZE);
	smp_unlock_cache(flags);
}

/**
 * mn10300_icache_inv_range - Globally invalidate range of instruction cache
 * @start: The start address of the region to be invalidated.
 * @end: The end address of the region to be invalidated.
 *
 * Invalidate a range of addresses in the instruction cache on all CPUs,
 * between start and end-1 inclusive.
 */
void mn10300_icache_inv_range(unsigned long start, unsigned long end)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_icache_inv_range(start, end);
	smp_cache_call(SMP_ICACHE_INV_RANGE, start, end);
	smp_unlock_cache(flags);
}

/**
 * mn10300_icache_inv_range2 - Globally invalidate range of instruction cache
 * @start: The start address of the region to be invalidated.
 * @size: The size of the region to be invalidated.
 *
 * Invalidate a range of addresses in the instruction cache on all CPUs,
 * between start and start+size-1 inclusive.
 */
void mn10300_icache_inv_range2(unsigned long start, unsigned long size)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_icache_inv_range2(start, size);
	smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + size);
	smp_unlock_cache(flags);
}

/**
 * mn10300_dcache_inv - Globally invalidate data cache
 *
 * Invalidate the data cache on all CPUs.
 */
void mn10300_dcache_inv(void)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_dcache_inv();
	smp_cache_call(SMP_DCACHE_INV, 0, 0);
	smp_unlock_cache(flags);
}

/**
 * mn10300_dcache_inv_page - Globally invalidate a page of data cache
 * @start: The address of the page of memory to be invalidated.
 *
 * Invalidate a range of addresses in the data cache on all CPUs covering the
 * page that includes the given address.
 */
void mn10300_dcache_inv_page(unsigned long start)
{
	unsigned long flags;

	start &= ~(PAGE_SIZE-1);

	flags = smp_lock_cache();
	mn10300_local_dcache_inv_page(start);
	smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + PAGE_SIZE);
	smp_unlock_cache(flags);
}

/**
 * mn10300_dcache_inv_range - Globally invalidate range of data cache
 * @start: The start address of the region to be invalidated.
 * @end: The end address of the region to be invalidated.
 *
 * Invalidate a range of addresses in the data cache on all CPUs, between start
 * and end-1 inclusive.
 */
void mn10300_dcache_inv_range(unsigned long start, unsigned long end)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_dcache_inv_range(start, end);
	smp_cache_call(SMP_DCACHE_INV_RANGE, start, end);
	smp_unlock_cache(flags);
}

/**
 * mn10300_dcache_inv_range2 - Globally invalidate range of data cache
 * @start: The start address of the region to be invalidated.
 * @size: The size of the region to be invalidated.
 *
 * Invalidate a range of addresses in the data cache on all CPUs, between start
 * and start+size-1 inclusive.
 */
void mn10300_dcache_inv_range2(unsigned long start, unsigned long size)
{
	unsigned long flags;

	flags = smp_lock_cache();
	mn10300_local_dcache_inv_range2(start, size);
	smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + size);
	smp_unlock_cache(flags);
}