Skip to contentSkip to conversation

ARM: mvebu: coherency support improvements

RFC PATCH New Thomas Petazzoni 2 participants 10 messages Dec 26, 2013 – Dec 27, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ARM: mvebu: coherency support improvements

Jason, Gregory, Andrew, Sebastian,

Here is a set of patches that make some changes to the mach-mvebu coherency code, and the way the mvebu-mbus driver determines whether hardware I/O coherency is enabled or not.

These changes are proposed in preparation to the introduction of the support for more recent SOCs in mach-mvebu, which have a slightly different coherency fabric (hence the need for different compatible strings) and different constraints to be able to enable the I/O coherency (not only the coherency fabric must be available, but the kernel must be running in CONFIG_SMP).

Moreover, the mvebu-mbus driver was directly poking into the DT to find whether a coherency fabric node was available or not, to determine if I/O coherency is enabled or not. However, with the new constraint that CONFIG_SMP must be enabled on some SOCs to get I/O coherency, the solution of having mvebu-mbus directly poke into the DT is not longer appropriate. This patch set therefore changes the mvebu_mbus_dt_init() function call to take an additional boolean argument telling whether the system is running in I/O coherent mode or not.

I've for now marked those patches as RFC, to indicate that they are clearly open for discussion. For example, I'm still wondering if I should not introduce separate compatible strings marvell,armada-370-coherency-fabric and marvell,armada-xp-coherency-fabric for Armada 370 and Armada XP respectively instead of using marvell,armada-370-coherency-fabric for both. Our experience has shown that we often initially believe that a given hardware unit is similar between SOCs, and then later discover that there are in fact some slight differences, which should have called for different compatible strings from the beginning.

Best regards,

Thomas

Thomas Petazzoni (6):
ARM: mvebu: prepare coherency code to support more SOCs
ARM: mvebu: add a coherency_available() call
bus: mvebu: pass the coherency availability information at init time
ARM: mvebu: use of_find_matching_node_and_match() in coherency.c
ARM: mvebu: update Armada 370/XP DT to use new coherency compatible
string
ARM: mvebu: update coherency fabric DT binding documentation

 .../devicetree/bindings/arm/coherency-fabric.txt   | 19 +++--
 arch/arm/boot/dts/armada-370-xp.dtsi               |  2 +-
 arch/arm/mach-kirkwood/board-dt.c                  |  2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |  2 +-
 arch/arm/mach-mvebu/coherency.c                    | 80 ++++++++++++++++------
 arch/arm/mach-mvebu/coherency.h                    |  1 +
 drivers/bus/mvebu-mbus.c                           | 11 +--
 include/linux/mbus.h                               |  2 +-
 8 files changed, 79 insertions(+), 40 deletions(-)
Signature · 1 line
1.8.3.2
#1 lore raw

RFC PATCH 1/6 ARM: mvebu: prepare coherency code to support more SOCs

The code that handles the coherency fabric of Armada 370 and Armada XP in arch/arm/mach-mvebu/coherency.c made the assumption that there was only one type of coherency fabric. Unfortunately, it turns out that upcoming SoCs have a slightly different coherency unit.

In preparation to the introduction of the coherency support for more SoCs, this commit:

* Adds a new "marvell,armada-370-coherency-fabric" compatible string, to indicate the Armada 370/XP variant of the coherency fabric. The existing compatible string "marvel,coherency-fabric" is preserved for compatibility reasons, and has the same behavior as the new "marvell,armada-370-coherency-fabric".

* Introduces a data associated to the compatible string in the compatible string match table, so that the code can differantiate the variant of coherency unit being used.

* Separates the coherency unit initialization code into its own function.

---
 .../devicetree/bindings/arm/coherency-fabric.txt   | 12 ++++-
 arch/arm/mach-mvebu/coherency.c                    | 53 ++++++++++++++++------
 2 files changed, 49 insertions(+), 16 deletions(-)
Documentation/devicetree/bindings/arm/coherency-fabric.txt +10 -2
index 17d8cd1..6bd8788 100644
@@ -4,7 +4,15 @@ Available on Marvell SOCs: Armada 370 and Armada XP
 
 Required properties:
 
-- compatible: "marvell,coherency-fabric"
+- compatible: the possible values are:
+
+ * "marvell,coherency-fabric", kept for backward compatibility reasons
+   only. To be used for the coherency fabric of the Armada 370 and
+   Armada XP. It is recommended to use
+   "marvell,armada-370-coherency-fabric" instead.
+
+ * "marvell,armada-370-coherency-fabric", for the Armada 370 and
+   Armada XP coherency fabric.
 
 - reg: Should contain coherency fabric registers location and
   length. First pair for the coherency fabric registers, second pair
@@ -13,7 +21,7 @@ Required properties:
 Example:
 
 coherency-fabric at d0020200 {
-	compatible = "marvell,coherency-fabric";
+	compatible = "marvell,armada-370-coherency-fabric";
 	reg = <0xd0020200 0xb0>,
 		<0xd0021810 0x1c>;
 
arch/arm/mach-mvebu/coherency.c +39 -14

73 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#2 lore raw

RFC PATCH 2/6 ARM: mvebu: add a coherency_available() call

In reply to Thomas Petazzoni

This commit extends the coherency fabric code to provide a coherency_available()function that the SoC code can call to be told whether coherency support is available or not. On Armada 370/XP, coherency support is available as soon as the relevant DT node is present. On some upcoming SoCs, the DT node needs to be present *and* the system running with CONFIG_SMP enabled.

---
 arch/arm/mach-mvebu/coherency.c | 30 +++++++++++++++++++++++-------
 arch/arm/mach-mvebu/coherency.h |  1 +
 2 files changed, 24 insertions(+), 7 deletions(-)
arch/arm/mach-mvebu/coherency.c +23 -7
index a8209ae..70db4e9 100644
@@ -38,6 +38,7 @@ static void __iomem *coherency_cpu_base;
 #define IO_SYNC_BARRIER_CTL_OFFSET		   0x0
 
 enum {
+	COHERENCY_FABRIC_TYPE_NONE,
 	COHERENCY_FABRIC_TYPE_ARMADA_370_XP,
 };
 
@@ -149,7 +150,7 @@ static void __init armada_370_coherency_init(struct device_node *np)
 	set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
 }
 
-int __init coherency_init(void)
+static int coherency_type(void)
 {
 	struct device_node *np;
 
@@ -160,27 +161,42 @@ int __init coherency_init(void)
 		int type;
 
 		type = (int) match->data;
+
 		pr_info("Initializing Coherency fabric\n");
 
+		/* Armada 370/XP coherency works in both UP and SMP */
 		if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
-			armada_370_coherency_init(np);
+			return type;
 
 		of_node_put(np);
 	}
 
-	return 0;
+	return COHERENCY_FABRIC_TYPE_NONE;
 }
 
-static int __init coherency_late_init(void)
+int coherency_available(void)
 {
+	return coherency_type() != COHERENCY_FABRIC_TYPE_NONE;
+}
+
+int __init coherency_init(void)
+{
+	int type = coherency_type();
 	struct device_node *np;
 
 	np = of_find_matching_node(NULL, of_coherency_table);
-	if (np) {
+
+	if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
+		armada_370_coherency_init(np);
+
+	return 0;
+}
+
+static int __init coherency_late_init(void)
+{
+	if (coherency_available())
 		bus_register_notifier(&platform_bus_type,
 				      &mvebu_hwcc_platform_nb);
-		of_node_put(np);
-	}
 	return 0;
 }
 
arch/arm/mach-mvebu/coherency.h +1 -0
index df33ad8..2a05b6e 100644
@@ -16,5 +16,6 @@
 
 int set_cpu_coherent(int cpu_id, int smp_group_id);
 int coherency_init(void);
+int coherency_available(void);
 
 #endif	/* __MACH_370_XP_COHERENCY_H */
Signature · 1 line
1.8.3.2
#3 lore raw

RFC PATCH 3/6 bus: mvebu: pass the coherency availability information at init time

In reply to Thomas Petazzoni

Until now, the mvebu-mbus was guessing by itself whether hardware I/O coherency was available or not by poking into the Device Tree to see if the coherency fabric Device Tree node was present or not.

However, on some upcoming SoCs, the presence or absence of the coherency fabric DT node isn't sufficient: in CONFIG_SMP, the coherency can be enabled, but not in !CONFIG_SMP.

In order to clean this up, the mvebu_mbus_dt_init() function is extended to get a boolean argument telling whether coherency is enabled or not. Therefore, the logic to decide whether coherency is available or not now belongs to the core SoC code instead of the mvebu-mbus driver itself, which is much better.

---
 arch/arm/mach-kirkwood/board-dt.c   |  2 +-
 arch/arm/mach-mvebu/armada-370-xp.c |  2 +-
 drivers/bus/mvebu-mbus.c            | 11 +++--------
 include/linux/mbus.h                |  2 +-
 4 files changed, 6 insertions(+), 11 deletions(-)
arch/arm/mach-kirkwood/board-dt.c +1 -1
index 9caa4fe..ba0f1ca 100644
@@ -150,7 +150,7 @@ static void __init kirkwood_dt_init(void)
 	 */
 	writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
 
-	BUG_ON(mvebu_mbus_dt_init());
+	BUG_ON(mvebu_mbus_dt_init(false));
 
 	kirkwood_l2_init();
 
arch/arm/mach-mvebu/armada-370-xp.c +1 -1
index e2acff9..b407525 100644
@@ -39,7 +39,7 @@ static void __init armada_370_xp_timer_and_clk_init(void)
 	of_clk_init(NULL);
 	clocksource_of_init();
 	coherency_init();
-	BUG_ON(mvebu_mbus_dt_init());
+	BUG_ON(mvebu_mbus_dt_init(coherency_available()));
 #ifdef CONFIG_CACHE_L2X0
 	l2x0_of_init(0, ~0UL);
 #endif
drivers/bus/mvebu-mbus.c +3 -8
index 2394e97..16d11cf 100644
@@ -700,7 +700,6 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,
 					 phys_addr_t sdramwins_phys_base,
 					 size_t sdramwins_size)
 {
-	struct device_node *np;
 	int win;
 
 	mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size);
@@ -713,12 +712,6 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,
 		return -ENOMEM;
 	}
 
-	np = of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric");
-	if (np) {
-		mbus->hw_io_coherency = 1;
-		of_node_put(np);
-	}
-
 	for (win = 0; win < mbus->soc->num_wins; win++)
 		mvebu_mbus_disable_window(mbus, win);
 
@@ -888,7 +881,7 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
 	}
 }
 
-int __init mvebu_mbus_dt_init(void)
+int __init mvebu_mbus_dt_init(bool is_coherent)
 {
 	struct resource mbuswins_res, sdramwins_res;
 	struct device_node *np, *controller;
@@ -927,6 +920,8 @@ int __init mvebu_mbus_dt_init(void)
 		return -EINVAL;
 	}
 
+	mbus_state.hw_io_coherency = is_coherent;
+
 	/* Get optional pcie-{mem,io}-aperture properties */
 	mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture,
 					  &mbus_state.pcie_io_aperture);
include/linux/mbus.h +1 -1
index 345b8c5..550c88f 100644
@@ -73,6 +73,6 @@ int mvebu_mbus_del_window(phys_addr_t base, size_t size);
 int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
 		    size_t mbus_size, phys_addr_t sdram_phys_base,
 		    size_t sdram_size);
-int mvebu_mbus_dt_init(void);
+int mvebu_mbus_dt_init(bool is_coherent);
 
 #endif /* __LINUX_MBUS_H */
Signature · 1 line
1.8.3.2
#4 lore raw

RFC PATCH 4/6 ARM: mvebu: use of_find_matching_node_and_match() in coherency.c

In reply to Thomas Petazzoni

In the mach-mvebu coherency code, instead of using of_find_matching_node() and then of_match_node(), directly use the of_find_matching_node_and_match() which does both at once.

We take this opportunity to also simplify the initialization of the "type" variable.

---
 arch/arm/mach-mvebu/coherency.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-mvebu/coherency.c +3 -6
index 70db4e9..2eb3243 100644
@@ -153,14 +153,11 @@ static void __init armada_370_coherency_init(struct device_node *np)
 static int coherency_type(void)
 {
 	struct device_node *np;
+	const struct of_device_id *match;
 
-	np = of_find_matching_node(NULL, of_coherency_table);
+	np = of_find_matching_node_and_match(NULL, of_coherency_table, &match);
 	if (np) {
-		const struct of_device_id *match =
-			of_match_node(of_coherency_table, np);
-		int type;
-
-		type = (int) match->data;
+		int type = (int) match->data;
 
 		pr_info("Initializing Coherency fabric\n");
 
Signature · 1 line
1.8.3.2
#5 lore raw

RFC PATCH 5/6 ARM: mvebu: update Armada 370/XP DT to use new coherency compatible string

In reply to Thomas Petazzoni

Update the common Armada 370 and Armada XP Device Tree files to use the new compatible string for the coherency fabric.

---
 arch/arm/boot/dts/armada-370-xp.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/armada-370-xp.dtsi +1 -1
index 7f10f62..c32f522 100644
@@ -117,7 +117,7 @@
 			};
 
 			coherency-fabric at 20200 {
-				compatible = "marvell,coherency-fabric";
+				compatible = "marvell,armada-370-coherency-fabric";
 				reg = <0x20200 0xb0>, <0x21010 0x1c>;
 			};
 
Signature · 1 line
1.8.3.2
#6 lore raw

RFC PATCH 6/6 ARM: mvebu: update coherency fabric DT binding documentation

In reply to Thomas Petazzoni

Update the Marvell coherency fabric DT binding documentation to provide an example that uses valid register addresses for the second register pair. Take this opportunity to change the example to have only register offsets from the internal register base address instead of absolute addresses, as is now done in the real DT files.

---
 Documentation/devicetree/bindings/arm/coherency-fabric.txt | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/arm/coherency-fabric.txt +2 -5
index 6bd8788..857de26 100644
@@ -20,10 +20,7 @@ Required properties:
 
 Example:
 
-coherency-fabric at d0020200 {
+coherency-fabric at 20200 {
 	compatible = "marvell,armada-370-coherency-fabric";
-	reg = <0xd0020200 0xb0>,
-		<0xd0021810 0x1c>;
-
+	reg = <0x20200 0xb0>, <0x21010 0x1c>;
 };
-
Signature · 1 line
1.8.3.2
#7 lore raw

cover ARM: mvebu: coherency support improvements

In reply to Thomas Petazzoni

Thomas,

Quoted 47 lines · Thomas Petazzoni

Jason, Gregory, Andrew, Sebastian,

Here is a set of patches that make some changes to the mach-mvebu coherency code, and the way the mvebu-mbus driver determines whether hardware I/O coherency is enabled or not.

These changes are proposed in preparation to the introduction of the support for more recent SOCs in mach-mvebu, which have a slightly different coherency fabric (hence the need for different compatible strings) and different constraints to be able to enable the I/O coherency (not only the coherency fabric must be available, but the kernel must be running in CONFIG_SMP).

Moreover, the mvebu-mbus driver was directly poking into the DT to find whether a coherency fabric node was available or not, to determine if I/O coherency is enabled or not. However, with the new constraint that CONFIG_SMP must be enabled on some SOCs to get I/O coherency, the solution of having mvebu-mbus directly poke into the DT is not longer appropriate. This patch set therefore changes the mvebu_mbus_dt_init() function call to take an additional boolean argument telling whether the system is running in I/O coherent mode or not.

I've for now marked those patches as RFC, to indicate that they are clearly open for discussion. For example, I'm still wondering if I should not introduce separate compatible strings marvell,armada-370-coherency-fabric and marvell,armada-xp-coherency-fabric for Armada 370 and Armada XP respectively instead of using marvell,armada-370-coherency-fabric for both. Our experience has shown that we often initially believe that a given hardware unit is similar between SOCs, and then later discover that there are in fact some slight differences, which should have called for different compatible strings from the beginning.

Best regards,

Thomas

Thomas Petazzoni (6):
ARM: mvebu: prepare coherency code to support more SOCs
ARM: mvebu: add a coherency_available() call
bus: mvebu: pass the coherency availability information at init time
ARM: mvebu: use of_find_matching_node_and_match() in coherency.c
ARM: mvebu: update Armada 370/XP DT to use new coherency compatible
string
ARM: mvebu: update coherency fabric DT binding documentation

Quoted 9 lines
 .../devicetree/bindings/arm/coherency-fabric.txt   | 19 +++--
 arch/arm/boot/dts/armada-370-xp.dtsi               |  2 +-
 arch/arm/mach-kirkwood/board-dt.c                  |  2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |  2 +-
 arch/arm/mach-mvebu/coherency.c                    | 80 ++++++++++++++++------
 arch/arm/mach-mvebu/coherency.h                    |  1 +
 drivers/bus/mvebu-mbus.c                           | 11 +--
 include/linux/mbus.h                               |  2 +-
 8 files changed, 79 insertions(+), 40 deletions(-)

How is this different than the RFC v1 I just looked over?

thx,

Jason.

#8 lore raw

cover ARM: mvebu: coherency support improvements

Quoted 60 lines · Jason Cooper

Thomas,

Quoted 47 lines · Thomas Petazzoni

Jason, Gregory, Andrew, Sebastian,

Here is a set of patches that make some changes to the mach-mvebu coherency code, and the way the mvebu-mbus driver determines whether hardware I/O coherency is enabled or not.

These changes are proposed in preparation to the introduction of the support for more recent SOCs in mach-mvebu, which have a slightly different coherency fabric (hence the need for different compatible strings) and different constraints to be able to enable the I/O coherency (not only the coherency fabric must be available, but the kernel must be running in CONFIG_SMP).

Moreover, the mvebu-mbus driver was directly poking into the DT to find whether a coherency fabric node was available or not, to determine if I/O coherency is enabled or not. However, with the new constraint that CONFIG_SMP must be enabled on some SOCs to get I/O coherency, the solution of having mvebu-mbus directly poke into the DT is not longer appropriate. This patch set therefore changes the mvebu_mbus_dt_init() function call to take an additional boolean argument telling whether the system is running in I/O coherent mode or not.

I've for now marked those patches as RFC, to indicate that they are clearly open for discussion. For example, I'm still wondering if I should not introduce separate compatible strings marvell,armada-370-coherency-fabric and marvell,armada-xp-coherency-fabric for Armada 370 and Armada XP respectively instead of using marvell,armada-370-coherency-fabric for both. Our experience has shown that we often initially believe that a given hardware unit is similar between SOCs, and then later discover that there are in fact some slight differences, which should have called for different compatible strings from the beginning.

Best regards,

Thomas

Thomas Petazzoni (6):
ARM: mvebu: prepare coherency code to support more SOCs
ARM: mvebu: add a coherency_available() call
bus: mvebu: pass the coherency availability information at init time
ARM: mvebu: use of_find_matching_node_and_match() in coherency.c
ARM: mvebu: update Armada 370/XP DT to use new coherency compatible
string
ARM: mvebu: update coherency fabric DT binding documentation

Quoted 9 lines
 .../devicetree/bindings/arm/coherency-fabric.txt   | 19 +++--
 arch/arm/boot/dts/armada-370-xp.dtsi               |  2 +-
 arch/arm/mach-kirkwood/board-dt.c                  |  2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |  2 +-
 arch/arm/mach-mvebu/coherency.c                    | 80 ++++++++++++++++------
 arch/arm/mach-mvebu/coherency.h                    |  1 +
 drivers/bus/mvebu-mbus.c                           | 11 +--
 include/linux/mbus.h                               |  2 +-
 8 files changed, 79 insertions(+), 40 deletions(-)
Quoted 1 line

How is this different than the RFC v1 I just looked over?

And now that I've made it past my inbox and to the list emails, it's rather obvious. ;-)

thx,

Jason.

#9 lore raw

cover ARM: mvebu: coherency support improvements

In reply to Thomas Petazzoni

Thomas,

Quoted 47 lines · Thomas Petazzoni

Jason, Gregory, Andrew, Sebastian,

Here is a set of patches that make some changes to the mach-mvebu coherency code, and the way the mvebu-mbus driver determines whether hardware I/O coherency is enabled or not.

These changes are proposed in preparation to the introduction of the support for more recent SOCs in mach-mvebu, which have a slightly different coherency fabric (hence the need for different compatible strings) and different constraints to be able to enable the I/O coherency (not only the coherency fabric must be available, but the kernel must be running in CONFIG_SMP).

Moreover, the mvebu-mbus driver was directly poking into the DT to find whether a coherency fabric node was available or not, to determine if I/O coherency is enabled or not. However, with the new constraint that CONFIG_SMP must be enabled on some SOCs to get I/O coherency, the solution of having mvebu-mbus directly poke into the DT is not longer appropriate. This patch set therefore changes the mvebu_mbus_dt_init() function call to take an additional boolean argument telling whether the system is running in I/O coherent mode or not.

I've for now marked those patches as RFC, to indicate that they are clearly open for discussion. For example, I'm still wondering if I should not introduce separate compatible strings marvell,armada-370-coherency-fabric and marvell,armada-xp-coherency-fabric for Armada 370 and Armada XP respectively instead of using marvell,armada-370-coherency-fabric for both. Our experience has shown that we often initially believe that a given hardware unit is similar between SOCs, and then later discover that there are in fact some slight differences, which should have called for different compatible strings from the beginning.

Best regards,

Thomas

Thomas Petazzoni (6):
ARM: mvebu: prepare coherency code to support more SOCs
ARM: mvebu: add a coherency_available() call
bus: mvebu: pass the coherency availability information at init time
ARM: mvebu: use of_find_matching_node_and_match() in coherency.c
ARM: mvebu: update Armada 370/XP DT to use new coherency compatible
string
ARM: mvebu: update coherency fabric DT binding documentation

Quoted 9 lines
 .../devicetree/bindings/arm/coherency-fabric.txt   | 19 +++--
 arch/arm/boot/dts/armada-370-xp.dtsi               |  2 +-
 arch/arm/mach-kirkwood/board-dt.c                  |  2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |  2 +-
 arch/arm/mach-mvebu/coherency.c                    | 80 ++++++++++++++++------
 arch/arm/mach-mvebu/coherency.h                    |  1 +
 drivers/bus/mvebu-mbus.c                           | 11 +--
 include/linux/mbus.h                               |  2 +-
 8 files changed, 79 insertions(+), 40 deletions(-)

How is this different than the RFC v1 I just looked over?

thx,

Jason.