077-ARM-l2c-Add-support-for-the-arm-shared-override-prop.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From 1bc7c02e7f37ddfa09cb0db330ee8cd4034d6410 Mon Sep 17 00:00:00 2001
  2. From: Geert Uytterhoeven <geert+renesas@glider.be>
  3. Date: Thu, 7 May 2015 11:27:11 +0200
  4. Subject: [PATCH 1/4] ARM: l2c: Add support for the "arm, shared-override"
  5. property
  6. "CoreLink Level 2 Cache Controller L2C-310", p. 2-15, section 2.3.2
  7. Shareable attribute" states:
  8. "The default behavior of the cache controller with respect to the
  9. shareable attribute is to transform Normal Memory Non-cacheable
  10. transactions into:
  11. - cacheable no allocate for reads
  12. - write through no write allocate for writes."
  13. Depending on the system architecture, this may cause memory corruption
  14. in the presence of bus mastering devices (e.g. OHCI). To avoid such
  15. corruption, the default behavior can be disabled by setting the Shared
  16. Override bit in the Auxiliary Control register.
  17. Currently the Shared Override bit can be set only using C code:
  18. - by calling l2x0_init() directly, which is deprecated,
  19. - by setting/clearing the bit in the machine_desc.l2c_aux_val/mask
  20. fields, but using values differing from 0/~0 is also deprecated.
  21. Hence add support for an "arm,shared-override" device tree property for
  22. the l2c device node. By specifying this property, affected systems can
  23. indicate that non-cacheable transactions must not be transformed.
  24. Then, it's up to the OS to decide. The current behavior is to set the
  25. "shared attribute override enable" bit, as there may exist kernel linear
  26. mappings and cacheable aliases for the DMA buffers, even if CMA is
  27. enabled.
  28. See also commit 1a8e41cd672f894b ("ARM: 6395/1: VExpress: Set bit 22 in
  29. the PL310 (cache controller) AuxCtlr register"):
  30. "Clearing bit 22 in the PL310 Auxiliary Control register (shared
  31. attribute override enable) has the side effect of transforming
  32. Normal Shared Non-cacheable reads into Cacheable no-allocate reads.
  33. Coherent DMA buffers in Linux always have a Cacheable alias via the
  34. kernel linear mapping and the processor can speculatively load
  35. cache lines into the PL310 controller. With bit 22 cleared,
  36. Non-cacheable reads would unexpectedly hit such cache lines leading
  37. to buffer corruption."
  38. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
  39. ---
  40. Documentation/devicetree/bindings/arm/l2cc.txt | 6 ++++++
  41. arch/arm/mm/cache-l2x0.c | 5 +++++
  42. 2 files changed, 11 insertions(+)
  43. --- a/Documentation/devicetree/bindings/arm/l2cc.txt
  44. +++ b/Documentation/devicetree/bindings/arm/l2cc.txt
  45. @@ -72,6 +72,12 @@ Optional properties:
  46. - prefetch-instr : Instruction prefetch. Value: <0> (forcibly disable),
  47. <1> (forcibly enable), property absent (retain settings set by
  48. firmware)
  49. +- arm,shared-override : The default behavior of the pl310 cache controller with
  50. + respect to the shareable attribute is to transform "normal memory
  51. + non-cacheable transactions" into "cacheable no allocate" (for reads) or
  52. + "write through no write allocate" (for writes).
  53. + On systems where this may cause DMA buffer corruption, this property must be
  54. + specified to indicate that such transforms are precluded.
  55. Example:
  56. --- a/arch/arm/mm/cache-l2x0.c
  57. +++ b/arch/arm/mm/cache-l2x0.c
  58. @@ -1171,6 +1171,11 @@ static void __init l2c310_of_parse(const
  59. }
  60. }
  61. + if (of_property_read_bool(np, "arm,shared-override")) {
  62. + *aux_val |= L2C_AUX_CTRL_SHARED_OVERRIDE;
  63. + *aux_mask &= ~L2C_AUX_CTRL_SHARED_OVERRIDE;
  64. + }
  65. +
  66. prefetch = l2x0_saved_regs.prefetch_ctrl;
  67. ret = of_property_read_u32(np, "arm,double-linefill", &val);