ARM: mvebu: coherency support improvements
A message that is not in the archive (sent off-list or not yet received): 1388067146-18111-1-git-send-email-thomas.petazzoni@free-electrons.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20131226171302.3409b096@skate
A message that is not in the archive (sent off-list or not yet received): [email protected]
cover ARM: mvebu: coherency support improvements
All,
resending to include the MLs
Quoted 19 lines · Andrew Lunn
Quoted 9 lines · Thomas Petazzoni
Dear Andrew Lunn,
Quoted 5 lines · Andrew Lunn
In the .dtsi file i would suggest multiple compatibilities from the most specific to the most general. So listing:
marvell,armada-370-coherency-fabric, marvell,armada-370-xp-coherency-fabric,Quoted 8 lines
Quoted 2 lines
gives you the most forward/backward compatibility, as you discover more about the hardware.
True, that's another possibility. Though it's unclear if a compatible string such as "marvell,armada-370-xp-coherency-fabric" makes sense. If you create such a compatible string, and then later discover than 370 and XP cannot be handled in a same way, then why have a "shared" compatible string?
Quoted 7 lines
Well presumably, if you need to split it further, it is somehow broken, or at least not optimal. Anybody who cannot update there DT blob keeps with the current somehow broken/non-optimal behavior, but those who can upgrade there DT blob get better behavior.
More compatible strings helps with backward compatibility for old DT blobs.
Please, let's not over-think this. Right now, are there _any_ capability differences we're aware of between the two? If not, then we should use marvell,armada-370-xp-coherency-fabric. *after* we discover an incompatible difference, then we add marvell,armada-370-coherency-fabric. The driver, if it sees the new compatible string, will use the new feature. If it doesn't, it will default to the old behavior as it was under marvell,armada-370-xp-coherency-fabric.
Let's not get ahead of ourselves guessing towards the 'perfect' DT binding.
thx,
Jason.
A message that is not in the archive (sent off-list or not yet received): 1388067146-18111-2-git-send-email-thomas.petazzoni@free-electrons.com
RFC PATCH 1/6 ARM: mvebu: prepare coherency code to support more SOCs
All,
resending to include the MLs.
Quoted 35 lines · Thomas Petazzoni
The code that handles the coherency fabric of Armada 370 and Armada XP in
arch/arm/mach-mvebu/coherency.cmade 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.
Signed-off-by Thomas Petazzoni <[email protected]>--- .../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 +0
-0@@ -4,7 +4,15 @@ Available on Marvell SOCs: Armada 370 and Armada XP Required properties:
Documentation/devicetree/bindings/arm/coherency-fabric.txt Available on Marvell SOCs: Armada 370 and Armada XP · line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/coherency-fabric.txt +9
-1-- 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.
This is completely unneeded. Once the new SoC is announced, all you should need is marvell,coherency-fabric (for 370/XP) and marvell,whizbang-coherency-fabric for the new whizbang SoC.
thx,
Jason.
Quoted 94 lines
Documentation/devicetree/bindings/arm/coherency-fabric.txt +1
-1- 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@@ -37,8 +37,20 @@ static void __iomem *coherency_cpu_base;#define IO_SYNC_BARRIER_CTL_OFFSET 0x0 +enum { +COHERENCY_FABRIC_TYPE_ARMADA_370_XP , +}; + +/* +* The "marvell,coherency-fabric" compatible string is kept for +* backward compatibility reasons, and is equivalent to +* "marvell,armada-370-coherency-fabric". +*/ static struct of_device_id of_coherency_table[] = { - {.compatible ="marvell,coherency-fabric" }, + {.compatible ="marvell,coherency-fabric" , + .data = (void *)COHERENCY_FABRIC_TYPE_ARMADA_370_XP }, + {.compatible ="marvell,armada-370-coherency-fabric" , + .data = (void *)COHERENCY_FABRIC_TYPE_ARMADA_370_XP }, {/* end of list */ }, };@@ -120,26 +132,39 @@ static struct notifier_block mvebu_hwcc_platform_nb = { .notifier_call = mvebu_hwcc_platform_notifier, }; +static void __init armada_370_coherency_init (struct device_node *np) +{ +struct resource res; +of_address_to_resource (np,0 , &res); + coherency_phys_base = res.start; +/* +* Ensure secondary CPUs will see the updated value, +* which they read before they join the coherency +* fabric, and therefore before they are coherent with +* the boot CPU cache. +*/ +sync_cache_w (&coherency_phys_base); + coherency_base =of_iomap (np,0 ); + coherency_cpu_base =of_iomap (np,1 ); +set_cpu_coherent (cpu_logical_map (smp_processor_id ()),0 ); +} +int __init coherency_init (void ) {struct device_node *np; np =of_find_matching_node (NULL , of_coherency_table);if (np) { -struct resource res; +const struct of_device_id *match = +of_match_node (of_coherency_table, np); +int type; + + type = (int ) match->data;pr_info ("Initializing Coherency fabric\n" ); -of_address_to_resource (np,0 , &res); - coherency_phys_base = res.start; -/* -* Ensure secondary CPUs will see the updated value, -* which they read before they join the coherency -* fabric, and therefore before they are coherent with -* the boot CPU cache. -*/ -sync_cache_w (&coherency_phys_base); - coherency_base =of_iomap (np,0 ); - coherency_cpu_base =of_iomap (np,1 ); -set_cpu_coherent (cpu_logical_map (smp_processor_id ()),0 ); + +if (type ==COHERENCY_FABRIC_TYPE_ARMADA_370_XP ) +armada_370_coherency_init (np); +of_node_put (np); }Signature · 1 line
1.8.3.2
A message that is not in the archive (sent off-list or not yet received): 1388067146-18111-3-git-send-email-thomas.petazzoni@free-electrons.com
RFC PATCH 2/6 ARM: mvebu: add a coherency_available() call
All,
Including the MLs.
Quoted 35 lines · 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_SMPenabled.Signed-off-by Thomas Petazzoni <[email protected]>--- 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 +2
-1@@ -38,6 +38,7 @@ static void __iomem *coherency_cpu_base;#define IO_SYNC_BARRIER_CTL_OFFSET 0x0enum { +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;
arch/arm/mach-mvebu/coherency.c int __init coherency_init(void) · line 165
Quoted 5 lines
arch/arm/mach-mvebu/coherency.c +1
-0@@ -160,27 +161,42 @@ int __init coherency_init(void)int type; type = (int ) match->data; +pr_info ("Initializing Coherency fabric\n" );
This seems to no longer be true at this point. Perhaps once moved to the correct location, it could report the type of coherency fabric?
thx,
Jason.
Quoted 57 lines
arch/arm/mach-mvebu/coherency.c +20
-6+/* 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@@ -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
A message that is not in the archive (sent off-list or not yet received): 1388067146-18111-4-git-send-email-thomas.petazzoni@free-electrons.com
RFC PATCH 3/6 bus: mvebu: pass the coherency availability information at init time
All,
Including the MLs
Quoted 40 lines · 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.Signed-off-by Thomas Petazzoni <[email protected]>--- 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@@ -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 +0
-0
arch/arm/mach-mvebu/armada-370-xp.c static void __init armada_370_xp_timer_and_clk_init(void) · line 42
Quoted 5 lines
arch/arm/mach-mvebu/armada-370-xp.c +1
-1@@ -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 ()));
coherency_available() is only available when support for armada 370/xp is enabled. Please update the Kconfig to restrict the conditions under which this driver can be built.
thx,
Jason.
Quoted 61 lines
arch/arm/mach-mvebu/armada-370-xp.c +0
-0#ifdef CONFIG_CACHE_L2X0 l2x0_of_init (0 , ~0UL );#endif drivers/bus/mvebu-mbus.c +3
-8@@ -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@@ -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
A message that is not in the archive (sent off-list or not yet received): 1388067146-18111-6-git-send-email-thomas.petazzoni@free-electrons.com
RFC PATCH 5/6 ARM: mvebu: update Armada 370/XP DT to use new coherency compatible string
All,
Including the MLs.
Quoted 13 lines · Thomas Petazzoni
Update the common Armada 370 and Armada XP Device Tree files to use the new compatible string for the coherency fabric.
Signed-off-by Thomas Petazzoni <[email protected]>--- arch/arm/boot/dts/armada-370-xp.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/boot/dts/armada-370-xp.dtsi +0
-0
arch/arm/boot/dts/armada-370-xp.dtsi line 120
Quoted 5 lines
arch/arm/boot/dts/armada-370-xp.dtsi +1
-1@@ -117,7 +117,7 @@ }; coherency-fabric at 20200 { - compatible = "marvell,coherency-fabric"; + compatible = "marvell,armada-370-coherency-fabric";
Not needed, see my reply to 1/6.
thx,
Jason.
Quoted 6 lines
arch/arm/boot/dts/armada-370-xp.dtsi +0
-0reg = <0x20200 0xb0>, <0x21010 0x1c>; };Signature · 1 line
1.8.3.2