aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/cache-l2x0.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2015-05-15 06:51:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-05-15 15:30:12 -0400
commite946a8cbe4a47a7c2615ffb0d45712e72c7d0f3a (patch)
tree22d4cf07324179939951ed6c08fb8e7118a87962 /arch/arm/mm/cache-l2x0.c
parent50beefde30224888d6d63224405ace4bdd4b32a0 (diff)
ARM: l2c: only unlock caches if NS_LOCKDOWN bit is set
Some L2C caches have a bit which allows non-secure software to control the cache lockdown. Some platforms are unable to set this bit. To avoid receiving an abort while trying to unlock the cache lines, check the state of this bit before unlocking. We do this by providing a new method in the l2c_init_data to perform the unlocking. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/cache-l2x0.c')
-rw-r--r--arch/arm/mm/cache-l2x0.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 2864a7bcc24b..95f33620353b 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -42,6 +42,7 @@ struct l2c_init_data {
42 void (*fixup)(void __iomem *, u32, struct outer_cache_fns *); 42 void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
43 void (*save)(void __iomem *); 43 void (*save)(void __iomem *);
44 void (*configure)(void __iomem *); 44 void (*configure)(void __iomem *);
45 void (*unlock)(void __iomem *, unsigned);
45 struct outer_cache_fns outer_cache; 46 struct outer_cache_fns outer_cache;
46}; 47};
47 48
@@ -128,7 +129,7 @@ static void l2c_enable(void __iomem *base, u32 aux, unsigned num_lock)
128 else 129 else
129 l2x0_data->configure(base); 130 l2x0_data->configure(base);
130 131
131 l2c_unlock(base, num_lock); 132 l2x0_data->unlock(base, num_lock);
132 133
133 local_irq_save(flags); 134 local_irq_save(flags);
134 __l2c_op_way(base + L2X0_INV_WAY); 135 __l2c_op_way(base + L2X0_INV_WAY);
@@ -249,6 +250,7 @@ static const struct l2c_init_data l2c210_data __initconst = {
249 .enable = l2c_enable, 250 .enable = l2c_enable,
250 .save = l2c_save, 251 .save = l2c_save,
251 .configure = l2c_configure, 252 .configure = l2c_configure,
253 .unlock = l2c_unlock,
252 .outer_cache = { 254 .outer_cache = {
253 .inv_range = l2c210_inv_range, 255 .inv_range = l2c210_inv_range,
254 .clean_range = l2c210_clean_range, 256 .clean_range = l2c210_clean_range,
@@ -400,6 +402,12 @@ static void l2c220_enable(void __iomem *base, u32 aux, unsigned num_lock)
400 l2c_enable(base, aux, num_lock); 402 l2c_enable(base, aux, num_lock);
401} 403}
402 404
405static void l2c220_unlock(void __iomem *base, unsigned num_lock)
406{
407 if (readl_relaxed(base + L2X0_AUX_CTRL) & L220_AUX_CTRL_NS_LOCKDOWN)
408 l2c_unlock(base, num_lock);
409}
410
403static const struct l2c_init_data l2c220_data = { 411static const struct l2c_init_data l2c220_data = {
404 .type = "L2C-220", 412 .type = "L2C-220",
405 .way_size_0 = SZ_8K, 413 .way_size_0 = SZ_8K,
@@ -407,6 +415,7 @@ static const struct l2c_init_data l2c220_data = {
407 .enable = l2c220_enable, 415 .enable = l2c220_enable,
408 .save = l2c_save, 416 .save = l2c_save,
409 .configure = l2c_configure, 417 .configure = l2c_configure,
418 .unlock = l2c220_unlock,
410 .outer_cache = { 419 .outer_cache = {
411 .inv_range = l2c220_inv_range, 420 .inv_range = l2c220_inv_range,
412 .clean_range = l2c220_clean_range, 421 .clean_range = l2c220_clean_range,
@@ -755,6 +764,12 @@ static void l2c310_resume(void)
755 set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1)); 764 set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
756} 765}
757 766
767static void l2c310_unlock(void __iomem *base, unsigned num_lock)
768{
769 if (readl_relaxed(base + L2X0_AUX_CTRL) & L310_AUX_CTRL_NS_LOCKDOWN)
770 l2c_unlock(base, num_lock);
771}
772
758static const struct l2c_init_data l2c310_init_fns __initconst = { 773static const struct l2c_init_data l2c310_init_fns __initconst = {
759 .type = "L2C-310", 774 .type = "L2C-310",
760 .way_size_0 = SZ_8K, 775 .way_size_0 = SZ_8K,
@@ -763,6 +778,7 @@ static const struct l2c_init_data l2c310_init_fns __initconst = {
763 .fixup = l2c310_fixup, 778 .fixup = l2c310_fixup,
764 .save = l2c310_save, 779 .save = l2c310_save,
765 .configure = l2c310_configure, 780 .configure = l2c310_configure,
781 .unlock = l2c310_unlock,
766 .outer_cache = { 782 .outer_cache = {
767 .inv_range = l2c210_inv_range, 783 .inv_range = l2c210_inv_range,
768 .clean_range = l2c210_clean_range, 784 .clean_range = l2c210_clean_range,
@@ -1067,6 +1083,7 @@ static const struct l2c_init_data of_l2c210_data __initconst = {
1067 .enable = l2c_enable, 1083 .enable = l2c_enable,
1068 .save = l2c_save, 1084 .save = l2c_save,
1069 .configure = l2c_configure, 1085 .configure = l2c_configure,
1086 .unlock = l2c_unlock,
1070 .outer_cache = { 1087 .outer_cache = {
1071 .inv_range = l2c210_inv_range, 1088 .inv_range = l2c210_inv_range,
1072 .clean_range = l2c210_clean_range, 1089 .clean_range = l2c210_clean_range,
@@ -1086,6 +1103,7 @@ static const struct l2c_init_data of_l2c220_data __initconst = {
1086 .enable = l2c220_enable, 1103 .enable = l2c220_enable,
1087 .save = l2c_save, 1104 .save = l2c_save,
1088 .configure = l2c_configure, 1105 .configure = l2c_configure,
1106 .unlock = l2c220_unlock,
1089 .outer_cache = { 1107 .outer_cache = {
1090 .inv_range = l2c220_inv_range, 1108 .inv_range = l2c220_inv_range,
1091 .clean_range = l2c220_clean_range, 1109 .clean_range = l2c220_clean_range,
@@ -1213,6 +1231,7 @@ static const struct l2c_init_data of_l2c310_data __initconst = {
1213 .fixup = l2c310_fixup, 1231 .fixup = l2c310_fixup,
1214 .save = l2c310_save, 1232 .save = l2c310_save,
1215 .configure = l2c310_configure, 1233 .configure = l2c310_configure,
1234 .unlock = l2c310_unlock,
1216 .outer_cache = { 1235 .outer_cache = {
1217 .inv_range = l2c210_inv_range, 1236 .inv_range = l2c210_inv_range,
1218 .clean_range = l2c210_clean_range, 1237 .clean_range = l2c210_clean_range,
@@ -1242,6 +1261,7 @@ static const struct l2c_init_data of_l2c310_coherent_data __initconst = {
1242 .fixup = l2c310_fixup, 1261 .fixup = l2c310_fixup,
1243 .save = l2c310_save, 1262 .save = l2c310_save,
1244 .configure = l2c310_configure, 1263 .configure = l2c310_configure,
1264 .unlock = l2c310_unlock,
1245 .outer_cache = { 1265 .outer_cache = {
1246 .inv_range = l2c210_inv_range, 1266 .inv_range = l2c210_inv_range,
1247 .clean_range = l2c210_clean_range, 1267 .clean_range = l2c210_clean_range,
@@ -1419,6 +1439,7 @@ static const struct l2c_init_data of_aurora_with_outer_data __initconst = {
1419 .fixup = aurora_fixup, 1439 .fixup = aurora_fixup,
1420 .save = aurora_save, 1440 .save = aurora_save,
1421 .configure = l2c_configure, 1441 .configure = l2c_configure,
1442 .unlock = l2c_unlock,
1422 .outer_cache = { 1443 .outer_cache = {
1423 .inv_range = aurora_inv_range, 1444 .inv_range = aurora_inv_range,
1424 .clean_range = aurora_clean_range, 1445 .clean_range = aurora_clean_range,
@@ -1439,6 +1460,7 @@ static const struct l2c_init_data of_aurora_no_outer_data __initconst = {
1439 .fixup = aurora_fixup, 1460 .fixup = aurora_fixup,
1440 .save = aurora_save, 1461 .save = aurora_save,
1441 .configure = l2c_configure, 1462 .configure = l2c_configure,
1463 .unlock = l2c_unlock,
1442 .outer_cache = { 1464 .outer_cache = {
1443 .resume = l2c_resume, 1465 .resume = l2c_resume,
1444 }, 1466 },
@@ -1589,6 +1611,7 @@ static const struct l2c_init_data of_bcm_l2x0_data __initconst = {
1589 .enable = l2c310_enable, 1611 .enable = l2c310_enable,
1590 .save = l2c310_save, 1612 .save = l2c310_save,
1591 .configure = l2c310_configure, 1613 .configure = l2c310_configure,
1614 .unlock = l2c310_unlock,
1592 .outer_cache = { 1615 .outer_cache = {
1593 .inv_range = bcm_inv_range, 1616 .inv_range = bcm_inv_range,
1594 .clean_range = bcm_clean_range, 1617 .clean_range = bcm_clean_range,
@@ -1626,6 +1649,7 @@ static const struct l2c_init_data of_tauros3_data __initconst = {
1626 .enable = l2c_enable, 1649 .enable = l2c_enable,
1627 .save = tauros3_save, 1650 .save = tauros3_save,
1628 .configure = tauros3_configure, 1651 .configure = tauros3_configure,
1652 .unlock = l2c_unlock,
1629 /* Tauros3 broadcasts L1 cache operations to L2 */ 1653 /* Tauros3 broadcasts L1 cache operations to L2 */
1630 .outer_cache = { 1654 .outer_cache = {
1631 .resume = l2c_resume, 1655 .resume = l2c_resume,