Skip to contentSkip to conversation

ARM: bcm281xx: Add L2 support for Rev A2 chips

PATCH Superseded Christian Daudt 2 participants 3 messages Apr 30, 2013 – May 1, 2013

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: bcm281xx: Add L2 support for Rev A2 chips

Rev A2 SoCs have an unorthodox memory re-mapping and this needs to be reflected in the cache operations.
This patch adds new outer cache functions for the l2x0 driver to support this SoC revision. It also adds a new compatible value for the cache to enable this functionality.

Documentation/devicetree/bindings/arm/l2cc.txt +3 -0
index cbef09b..69ddf9f 100644
@@ -16,6 +16,9 @@ Required properties:
      performs the same operation).
 	"marvell,"aurora-outer-cache: Marvell Controller designed to be
 	 compatible with the ARM one with outer cache mode.
+	"bcm,bcm11351-a2-pl310-cache": For Broadcom bcm11351 chipset where an
+	offset needs to be added to the address before passing down to the L2
+	cache controller
 - cache-unified : Specifies the cache is a unified cache.
 - cache-level : Should be set to 2 for a level 2 cache.
 - reg : Physical base address and size of cache controller's memory mapped
arch/arm/boot/dts/bcm11351.dtsi +4 -4
index 41b2c6c..5e48c85 100644
@@ -47,10 +47,10 @@
 	};
 
 	L2: l2-cache {
-		    compatible = "arm,pl310-cache";
-		    reg = <0x3ff20000 0x1000>;
-		    cache-unified;
-		    cache-level = <2>;
+		compatible = "bcm,bcm11351-a2-pl310-cache";
+		reg = <0x3ff20000 0x1000>;
+		cache-unified;
+		cache-level = <2>;
 	};
 
 	timer at 35006000 {
arch/arm/mm/cache-l2x0.c +173 -0

191 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

Hi Christian,

Thanks for CC'ing me.

Quoted 5 lines · Christian Daudt

Rev A2 SoCs have an unorthodox memory re-mapping and this needs to be reflected in the cache operations.
This patch adds new outer cache functions for the l2x0 driver to support this SoC revision. It also adds a new compatible value for the cache to enable this functionality.

This is a pretty weird thing you've managed to build here...

Quoted 7 lines
arch/arm/mm/cache-l2x0.c +0 -0
index c465fac..6edba13 100644
@@ -523,6 +523,162 @@ static void aurora_flush_range(unsigned long start, unsigned long end)
 	}
 }

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 534

Quoted 10 lines
arch/arm/mm/cache-l2x0.c +9 -0
 
+/*
+ * For certain Broadcom SoCs, depending on the address range, different offsets
+ * need to be added to the address before passing it to L2 for
+ * invalidation/clean/flush
+ *
+ * Section Address Range              Offset        EMI
+ *   1     0x00000000 - 0x3FFFFFFF    0x80000000    VC
+ *   2     0x40000000 - 0xBFFFFFFF    0x40000000    SYS
+ *   3     0xC0000000 - 0xFFFFFFFF    0x80000000    VC

Hmm, so am I right in thinking that the `Broadcom addresses' for section 1 and 2 overlap? It would also be worth describing which physical addresses Linux actually wants to use; where is the memory in the physical memory map for devices with this L2 controller?

Quoted 12 lines
arch/arm/mm/cache-l2x0.c +12 -0
+ * When the start and end addresses have crossed two different sections, we
+ * need to break the L2 operation into two, each within its own section.
+ * For example, if we need to invalidate addresses starts at 0xBFFF0000 and
+ * ends at 0xC0001000, we need do invalidate 1) 0xBFFF0000 - 0xBFFFFFFF and 2)
+ * 0xC0000000 - 0xC0001000
+ *
+ * Note 1:
+ * By breaking a single L2 operation into two, we may potentially suffer some
+ * performance hit, but keep in mind the cross section case is very rare
+ *
+ * Note 2:
+ * We do not need to handle the case when the start address is in

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 557

Quoted 10 lines
arch/arm/mm/cache-l2x0.c +10 -0
+ * Section 1 and the end address is in Section 3, since it is not a valid use
+ * case
+ */
+
+#define BCM_VC_EMI_SEC1_START_ADDR    0x00000000UL
+#define BCM_VC_EMI_SEC1_END_ADDR      0x3FFFFFFFUL
+#define BCM_SYS_EMI_START_ADDR        0x40000000UL
+#define BCM_SYS_EMI_END_ADDR          0xBFFFFFFFUL
+#define BCM_VC_EMI_SEC3_START_ADDR    0xC0000000UL
+#define BCM_VC_EMI_SEC3_END_ADDR      0xFFFFFFFFUL

Seems a bit odd defining the END_ADDRs here, I'd just use strict '<' against the start of the next section in your code.

Quoted 20 lines
arch/arm/mm/cache-l2x0.c +20 -0
+#define BCM_SYS_EMI_OFFSET            0x40000000UL
+#define BCM_VC_EMI_OFFSET             0x80000000UL
+
+static inline int bcm_addr_is_sys_emi(unsigned long addr)
+{
+	return (addr >= BCM_SYS_EMI_START_ADDR) &&
+		(addr <= BCM_SYS_EMI_END_ADDR);
+}
+
+static inline unsigned long bcm_l2_phys_addr(unsigned long addr)
+{
+	if (bcm_addr_is_sys_emi(addr))
+		return addr + BCM_SYS_EMI_OFFSET;
+	else
+		return addr + BCM_VC_EMI_OFFSET;
+}
+
+static void bcm_inv_range(unsigned long start, unsigned long end)
+{
+	unsigned long new_start, new_end;

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 588

Quoted 10 lines
arch/arm/mm/cache-l2x0.c +10 -0
+
+	if (unlikely(end <= start))
+		return;
+
+	new_start = bcm_l2_phys_addr(start);
+	new_end = bcm_l2_phys_addr(end);
+
+	/* normal case, no cross section between start and end */
+	if (likely((bcm_addr_is_sys_emi(start) && bcm_addr_is_sys_emi(end)) ||
+		(!bcm_addr_is_sys_emi(start) && !bcm_addr_is_sys_emi(end)))) {

You could avoid evaluating bcm_addr_is_sys_emi twice for each address. In fact, you know start < end, so you just need to check start >= EMI_START and end < EMI_END.

Will

#2 lore raw

Hi Will,
Thanks for your feedback. See below for answers.

Quoted 11 lines · Will Deacon

Hi Christian,

Thanks for CC'ing me.

Quoted 5 lines · Christian Daudt

Rev A2 SoCs have an unorthodox memory re-mapping and this needs to be reflected in the cache operations.
This patch adds new outer cache functions for the l2x0 driver to support this SoC revision. It also adds a new compatible value for the cache to enable this functionality.

This is a pretty weird thing you've managed to build here...

No argument here.

Quoted 8 lines
Quoted 8 lines
arch/arm/mm/cache-l2x0.c +0 -0
index c465fac..6edba13 100644
@@ -523,6 +523,162 @@ static void aurora_flush_range(unsigned long start, unsigned long end)
  	}
  }
 
Quoted 13 lines

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 534

Quoted 9 lines
arch/arm/mm/cache-l2x0.c +9 -0
+/*
+ * For certain Broadcom SoCs, depending on the address range, different offsets
+ * need to be added to the address before passing it to L2 for
+ * invalidation/clean/flush
+ *
+ * Section Address Range              Offset        EMI
+ *   1     0x00000000 - 0x3FFFFFFF    0x80000000    VC
+ *   2     0x40000000 - 0xBFFFFFFF    0x40000000    SYS
+ *   3     0xC0000000 - 0xFFFFFFFF    0x80000000    VC

Hmm, so am I right in thinking that the `Broadcom addresses' for section 1 and 2 overlap? It would also be worth describing which physical addresses Linux actually wants to use; where is the memory in the physical memory map for devices with this L2 controller?

I've clarified this internally. Yes, there is an overlap, and because of that section 1 can't actually be used. I'm going to clear up the patch to remove the section one calculations to simplify it.

Quoted 16 lines
Quoted 16 lines
arch/arm/mm/cache-l2x0.c +16 -0
+ * When the start and end addresses have crossed two different sections, we
+ * need to break the L2 operation into two, each within its own section.
+ * For example, if we need to invalidate addresses starts at 0xBFFF0000 and
+ * ends at 0xC0001000, we need do invalidate 1) 0xBFFF0000 - 0xBFFFFFFF and 2)
+ * 0xC0000000 - 0xC0001000
+ *
+ * Note 1:
+ * By breaking a single L2 operation into two, we may potentially suffer some
+ * performance hit, but keep in mind the cross section case is very rare
+ *
+ * Note 2:
+ * We do not need to handle the case when the start address is in
+ * Section 1 and the end address is in Section 3, since it is not a valid use
+ * case
+ */
+
Quoted 8 lines

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 557

Quoted 6 lines
arch/arm/mm/cache-l2x0.c +6 -0
+#define BCM_VC_EMI_SEC1_START_ADDR    0x00000000UL
+#define BCM_VC_EMI_SEC1_END_ADDR      0x3FFFFFFFUL
+#define BCM_SYS_EMI_START_ADDR        0x40000000UL
+#define BCM_SYS_EMI_END_ADDR          0xBFFFFFFFUL
+#define BCM_VC_EMI_SEC3_START_ADDR    0xC0000000UL
+#define BCM_VC_EMI_SEC3_END_ADDR      0xFFFFFFFFUL

Seems a bit odd defining the END_ADDRs here, I'd just use strict '<' against the start of the next section in your code.

Makes sense. Removed.

Quoted 25 lines
Quoted 25 lines
arch/arm/mm/cache-l2x0.c +25 -0
+#define BCM_SYS_EMI_OFFSET            0x40000000UL
+#define BCM_VC_EMI_OFFSET             0x80000000UL
+
+static inline int bcm_addr_is_sys_emi(unsigned long addr)
+{
+	return (addr >= BCM_SYS_EMI_START_ADDR) &&
+		(addr <= BCM_SYS_EMI_END_ADDR);
+}
+
+static inline unsigned long bcm_l2_phys_addr(unsigned long addr)
+{
+	if (bcm_addr_is_sys_emi(addr))
+		return addr + BCM_SYS_EMI_OFFSET;
+	else
+		return addr + BCM_VC_EMI_OFFSET;
+}
+
+static void bcm_inv_range(unsigned long start, unsigned long end)
+{
+	unsigned long new_start, new_end;
+
+	if (unlikely(end <= start))
+		return;
+
+	new_start = bcm_l2_phys_addr(start);
Quoted 8 lines

arch/arm/mm/cache-l2x0.c static void aurora_flush_range(unsigned long start, unsigned long end) · line 588

Quoted 5 lines
arch/arm/mm/cache-l2x0.c +5 -0
+	new_end = bcm_l2_phys_addr(end);
+
+	/* normal case, no cross section between start and end */
+	if (likely((bcm_addr_is_sys_emi(start) && bcm_addr_is_sys_emi(end)) ||
+		(!bcm_addr_is_sys_emi(start) && !bcm_addr_is_sys_emi(end)))) {

You could avoid evaluating bcm_addr_is_sys_emi twice for each address. In fact, you know start < end, so you just need to check start >= EMI_START and end < EMI_END.

This test is to confirm that the range is completely within 1 section, so a single test won't do that - with the test as-is, the code after this 'if' already knows that there is section overlap. But I'll be removing section 1 handling and that will simplify things.

thanks,
csd