1 From e946a8cbe4a47a7c2615ffb0d45712e72c7d0f3a Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@arm.linux.org.uk>
3 Date: Fri, 15 May 2015 11:51:51 +0100
4 Subject: [PATCH 73/74] ARM: l2c: only unlock caches if NS_LOCKDOWN bit is set
6 Some L2C caches have a bit which allows non-secure software to control
7 the cache lockdown. Some platforms are unable to set this bit. To
8 avoid receiving an abort while trying to unlock the cache lines, check
9 the state of this bit before unlocking. We do this by providing a new
10 method in the l2c_init_data to perform the unlocking.
12 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
14 arch/arm/mm/cache-l2x0.c | 26 +++++++++++++++++++++++++-
15 1 file changed, 25 insertions(+), 1 deletion(-)
17 --- a/arch/arm/mm/cache-l2x0.c
18 +++ b/arch/arm/mm/cache-l2x0.c
19 @@ -42,6 +42,7 @@ struct l2c_init_data {
20 void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
21 void (*save)(void __iomem *);
22 void (*configure)(void __iomem *);
23 + void (*unlock)(void __iomem *, unsigned);
24 struct outer_cache_fns outer_cache;
27 @@ -128,7 +129,7 @@ static void l2c_enable(void __iomem *bas
29 l2x0_data->configure(base);
31 - l2c_unlock(base, num_lock);
32 + l2x0_data->unlock(base, num_lock);
34 local_irq_save(flags);
35 __l2c_op_way(base + L2X0_INV_WAY);
36 @@ -249,6 +250,7 @@ static const struct l2c_init_data l2c210
39 .configure = l2c_configure,
40 + .unlock = l2c_unlock,
42 .inv_range = l2c210_inv_range,
43 .clean_range = l2c210_clean_range,
44 @@ -400,6 +402,12 @@ static void l2c220_enable(void __iomem *
45 l2c_enable(base, aux, num_lock);
48 +static void l2c220_unlock(void __iomem *base, unsigned num_lock)
50 + if (readl_relaxed(base + L2X0_AUX_CTRL) & L220_AUX_CTRL_NS_LOCKDOWN)
51 + l2c_unlock(base, num_lock);
54 static const struct l2c_init_data l2c220_data = {
57 @@ -407,6 +415,7 @@ static const struct l2c_init_data l2c220
58 .enable = l2c220_enable,
60 .configure = l2c_configure,
61 + .unlock = l2c220_unlock,
63 .inv_range = l2c220_inv_range,
64 .clean_range = l2c220_clean_range,
65 @@ -755,6 +764,12 @@ static void l2c310_resume(void)
66 set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
69 +static void l2c310_unlock(void __iomem *base, unsigned num_lock)
71 + if (readl_relaxed(base + L2X0_AUX_CTRL) & L310_AUX_CTRL_NS_LOCKDOWN)
72 + l2c_unlock(base, num_lock);
75 static const struct l2c_init_data l2c310_init_fns __initconst = {
78 @@ -763,6 +778,7 @@ static const struct l2c_init_data l2c310
79 .fixup = l2c310_fixup,
81 .configure = l2c310_configure,
82 + .unlock = l2c310_unlock,
84 .inv_range = l2c210_inv_range,
85 .clean_range = l2c210_clean_range,
86 @@ -1067,6 +1083,7 @@ static const struct l2c_init_data of_l2c
89 .configure = l2c_configure,
90 + .unlock = l2c_unlock,
92 .inv_range = l2c210_inv_range,
93 .clean_range = l2c210_clean_range,
94 @@ -1086,6 +1103,7 @@ static const struct l2c_init_data of_l2c
95 .enable = l2c220_enable,
97 .configure = l2c_configure,
98 + .unlock = l2c220_unlock,
100 .inv_range = l2c220_inv_range,
101 .clean_range = l2c220_clean_range,
102 @@ -1213,6 +1231,7 @@ static const struct l2c_init_data of_l2c
103 .fixup = l2c310_fixup,
105 .configure = l2c310_configure,
106 + .unlock = l2c310_unlock,
108 .inv_range = l2c210_inv_range,
109 .clean_range = l2c210_clean_range,
110 @@ -1242,6 +1261,7 @@ static const struct l2c_init_data of_l2c
111 .fixup = l2c310_fixup,
113 .configure = l2c310_configure,
114 + .unlock = l2c310_unlock,
116 .inv_range = l2c210_inv_range,
117 .clean_range = l2c210_clean_range,
118 @@ -1419,6 +1439,7 @@ static const struct l2c_init_data of_aur
119 .fixup = aurora_fixup,
121 .configure = l2c_configure,
122 + .unlock = l2c_unlock,
124 .inv_range = aurora_inv_range,
125 .clean_range = aurora_clean_range,
126 @@ -1439,6 +1460,7 @@ static const struct l2c_init_data of_aur
127 .fixup = aurora_fixup,
129 .configure = l2c_configure,
130 + .unlock = l2c_unlock,
132 .resume = l2c_resume,
134 @@ -1589,6 +1611,7 @@ static const struct l2c_init_data of_bcm
135 .enable = l2c310_enable,
137 .configure = l2c310_configure,
138 + .unlock = l2c310_unlock,
140 .inv_range = bcm_inv_range,
141 .clean_range = bcm_clean_range,
142 @@ -1626,6 +1649,7 @@ static const struct l2c_init_data of_tau
143 .enable = l2c_enable,
144 .save = tauros3_save,
145 .configure = tauros3_configure,
146 + .unlock = l2c_unlock,
147 /* Tauros3 broadcasts L1 cache operations to L2 */
149 .resume = l2c_resume,