074-ARM-l2c-avoid-passing-auxiliary-control-register-thr.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. From 5b290ec2074c68b9f4f8f8789fa9b3e1782869e7 Mon Sep 17 00:00:00 2001
  2. From: Russell King <rmk+kernel@arm.linux.org.uk>
  3. Date: Fri, 15 May 2015 12:03:29 +0100
  4. Subject: [PATCH 74/74] ARM: l2c: avoid passing auxiliary control register
  5. through enable method
  6. Avoid passing the auxiliary control register value through the enable
  7. method. In the resume path, we have to read the value stored in
  8. l2x0_saved_regs.aux_ctrl, only to have it immediately written back by
  9. l2c_enable(). We can avoid this if we have __l2c_init() save the value
  10. directly to l2x0_saved_regs.aux_ctrl before calling the specific enable
  11. method.
  12. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  13. ---
  14. arch/arm/mm/cache-l2x0.c | 32 +++++++++++++++++---------------
  15. 1 file changed, 17 insertions(+), 15 deletions(-)
  16. --- a/arch/arm/mm/cache-l2x0.c
  17. +++ b/arch/arm/mm/cache-l2x0.c
  18. @@ -38,7 +38,7 @@ struct l2c_init_data {
  19. unsigned way_size_0;
  20. unsigned num_lock;
  21. void (*of_parse)(const struct device_node *, u32 *, u32 *);
  22. - void (*enable)(void __iomem *, u32, unsigned);
  23. + void (*enable)(void __iomem *, unsigned);
  24. void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
  25. void (*save)(void __iomem *);
  26. void (*configure)(void __iomem *);
  27. @@ -118,12 +118,10 @@ static void l2c_configure(void __iomem *
  28. * Enable the L2 cache controller. This function must only be
  29. * called when the cache controller is known to be disabled.
  30. */
  31. -static void l2c_enable(void __iomem *base, u32 aux, unsigned num_lock)
  32. +static void l2c_enable(void __iomem *base, unsigned num_lock)
  33. {
  34. unsigned long flags;
  35. - l2x0_saved_regs.aux_ctrl = aux;
  36. -
  37. if (outer_cache.configure)
  38. outer_cache.configure(&l2x0_saved_regs);
  39. else
  40. @@ -160,7 +158,7 @@ static void l2c_resume(void)
  41. /* Do not touch the controller if already enabled. */
  42. if (!(readl_relaxed(base + L2X0_CTRL) & L2X0_CTRL_EN))
  43. - l2c_enable(base, l2x0_saved_regs.aux_ctrl, l2x0_data->num_lock);
  44. + l2c_enable(base, l2x0_data->num_lock);
  45. }
  46. /*
  47. @@ -390,16 +388,16 @@ static void l2c220_sync(void)
  48. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  49. }
  50. -static void l2c220_enable(void __iomem *base, u32 aux, unsigned num_lock)
  51. +static void l2c220_enable(void __iomem *base, unsigned num_lock)
  52. {
  53. /*
  54. * Always enable non-secure access to the lockdown registers -
  55. * we write to them as part of the L2C enable sequence so they
  56. * need to be accessible.
  57. */
  58. - aux |= L220_AUX_CTRL_NS_LOCKDOWN;
  59. + l2x0_saved_regs.aux_ctrl |= L220_AUX_CTRL_NS_LOCKDOWN;
  60. - l2c_enable(base, aux, num_lock);
  61. + l2c_enable(base, num_lock);
  62. }
  63. static void l2c220_unlock(void __iomem *base, unsigned num_lock)
  64. @@ -612,10 +610,11 @@ static int l2c310_cpu_enable_flz(struct
  65. return NOTIFY_OK;
  66. }
  67. -static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock)
  68. +static void __init l2c310_enable(void __iomem *base, unsigned num_lock)
  69. {
  70. unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_RTL_MASK;
  71. bool cortex_a9 = read_cpuid_part() == ARM_CPU_PART_CORTEX_A9;
  72. + u32 aux = l2x0_saved_regs.aux_ctrl;
  73. if (rev >= L310_CACHE_ID_RTL_R2P0) {
  74. if (cortex_a9) {
  75. @@ -658,9 +657,9 @@ static void __init l2c310_enable(void __
  76. * we write to them as part of the L2C enable sequence so they
  77. * need to be accessible.
  78. */
  79. - aux |= L310_AUX_CTRL_NS_LOCKDOWN;
  80. + l2x0_saved_regs.aux_ctrl = aux | L310_AUX_CTRL_NS_LOCKDOWN;
  81. - l2c_enable(base, aux, num_lock);
  82. + l2c_enable(base, num_lock);
  83. /* Read back resulting AUX_CTRL value as it could have been altered. */
  84. aux = readl_relaxed(base + L2X0_AUX_CTRL);
  85. @@ -872,8 +871,11 @@ static int __init __l2c_init(const struc
  86. * Check if l2x0 controller is already enabled. If we are booting
  87. * in non-secure mode accessing the below registers will fault.
  88. */
  89. - if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN))
  90. - data->enable(l2x0_base, aux, data->num_lock);
  91. + if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) {
  92. + l2x0_saved_regs.aux_ctrl = aux;
  93. +
  94. + data->enable(l2x0_base, data->num_lock);
  95. + }
  96. outer_cache = fns;
  97. @@ -1388,7 +1390,7 @@ static void aurora_save(void __iomem *ba
  98. * For Aurora cache in no outer mode, enable via the CP15 coprocessor
  99. * broadcasting of cache commands to L2.
  100. */
  101. -static void __init aurora_enable_no_outer(void __iomem *base, u32 aux,
  102. +static void __init aurora_enable_no_outer(void __iomem *base,
  103. unsigned num_lock)
  104. {
  105. u32 u;
  106. @@ -1399,7 +1401,7 @@ static void __init aurora_enable_no_oute
  107. isb();
  108. - l2c_enable(base, aux, num_lock);
  109. + l2c_enable(base, num_lock);
  110. }
  111. static void __init aurora_fixup(void __iomem *base, u32 cache_id,