Commit 2667677f authored by Greg Ungerer's avatar Greg Ungerer Committed by Greg Kroah-Hartman

bus: mvebu: pass the coherency availability information at init time

commit 5686a1e5 upstream.

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: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1397483228-25625-4-git-send-email-thomas.petazzoni@free-electrons.comSigned-off-by: default avatarJason Cooper <jason@lakedaemon.net>

[ Greg Ungerer: back ported to linux-3.10.y
  Back port necessary due to large code differences in affected files.
  This change in combination with commit e5535545 ("ARM: mvebu: disable
  I/O coherency on non-SMP situations on Armada 370/375/38x/XP") is
  critical to the hardware I/O coherency being set correctly by both the
  mbus driver and all peripheral hardware drivers. Without this change
  drivers will incorrectly enable I/O coherency window attributes and
  this causes rare unreliable system behavior including oops. ]
Signed-off-by: default avatarGreg Ungerer <gerg@uclinux.org>
Acked-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ea0d66be
...@@ -226,7 +226,7 @@ void __init dove_init_early(void) ...@@ -226,7 +226,7 @@ void __init dove_init_early(void)
orion_time_set_base(TIMER_VIRT_BASE); orion_time_set_base(TIMER_VIRT_BASE);
mvebu_mbus_init("marvell,dove-mbus", mvebu_mbus_init("marvell,dove-mbus",
BRIDGE_WINS_BASE, BRIDGE_WINS_SZ, BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ); DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ, 0);
} }
static int __init dove_find_tclk(void) static int __init dove_find_tclk(void)
......
...@@ -530,7 +530,7 @@ void __init kirkwood_init_early(void) ...@@ -530,7 +530,7 @@ void __init kirkwood_init_early(void)
mvebu_mbus_init("marvell,kirkwood-mbus", mvebu_mbus_init("marvell,kirkwood-mbus",
BRIDGE_WINS_BASE, BRIDGE_WINS_SZ, BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ); DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ, 0);
} }
int kirkwood_tclk; int kirkwood_tclk;
......
...@@ -337,11 +337,11 @@ void __init mv78xx0_init_early(void) ...@@ -337,11 +337,11 @@ void __init mv78xx0_init_early(void)
if (mv78xx0_core_index() == 0) if (mv78xx0_core_index() == 0)
mvebu_mbus_init("marvell,mv78xx0-mbus", mvebu_mbus_init("marvell,mv78xx0-mbus",
BRIDGE_WINS_CPU0_BASE, BRIDGE_WINS_SZ, BRIDGE_WINS_CPU0_BASE, BRIDGE_WINS_SZ,
DDR_WINDOW_CPU0_BASE, DDR_WINDOW_CPU_SZ); DDR_WINDOW_CPU0_BASE, DDR_WINDOW_CPU_SZ, 0);
else else
mvebu_mbus_init("marvell,mv78xx0-mbus", mvebu_mbus_init("marvell,mv78xx0-mbus",
BRIDGE_WINS_CPU1_BASE, BRIDGE_WINS_SZ, BRIDGE_WINS_CPU1_BASE, BRIDGE_WINS_SZ,
DDR_WINDOW_CPU1_BASE, DDR_WINDOW_CPU_SZ); DDR_WINDOW_CPU1_BASE, DDR_WINDOW_CPU_SZ, 0);
} }
void __init_refok mv78xx0_timer_init(void) void __init_refok mv78xx0_timer_init(void)
......
...@@ -66,7 +66,8 @@ void __init armada_370_xp_init_early(void) ...@@ -66,7 +66,8 @@ void __init armada_370_xp_init_early(void)
ARMADA_370_XP_MBUS_WINS_BASE, ARMADA_370_XP_MBUS_WINS_BASE,
ARMADA_370_XP_MBUS_WINS_SIZE, ARMADA_370_XP_MBUS_WINS_SIZE,
ARMADA_370_XP_SDRAM_WINS_BASE, ARMADA_370_XP_SDRAM_WINS_BASE,
ARMADA_370_XP_SDRAM_WINS_SIZE); ARMADA_370_XP_SDRAM_WINS_SIZE,
coherency_available());
#ifdef CONFIG_CACHE_L2X0 #ifdef CONFIG_CACHE_L2X0
l2x0_of_init(0, ~0UL); l2x0_of_init(0, ~0UL);
......
...@@ -137,6 +137,20 @@ static struct notifier_block mvebu_hwcc_platform_nb = { ...@@ -137,6 +137,20 @@ static struct notifier_block mvebu_hwcc_platform_nb = {
.notifier_call = mvebu_hwcc_platform_notifier, .notifier_call = mvebu_hwcc_platform_notifier,
}; };
/*
* Keep track of whether we have IO hardware coherency enabled or not.
* On Armada 370's we will not be using it for example. We need to make
* that available [through coherency_available()] so the mbus controller
* doesn't enable the IO coherency bit in the attribute bits of the
* chip selects.
*/
static int coherency_enabled;
int coherency_available(void)
{
return coherency_enabled;
}
int __init coherency_init(void) int __init coherency_init(void)
{ {
struct device_node *np; struct device_node *np;
...@@ -170,6 +184,7 @@ int __init coherency_init(void) ...@@ -170,6 +184,7 @@ int __init coherency_init(void)
coherency_base = of_iomap(np, 0); coherency_base = of_iomap(np, 0);
coherency_cpu_base = of_iomap(np, 1); coherency_cpu_base = of_iomap(np, 1);
set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0); set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
coherency_enabled = 1;
bus_register_notifier(&platform_bus_type, bus_register_notifier(&platform_bus_type,
&mvebu_hwcc_platform_nb); &mvebu_hwcc_platform_nb);
} }
......
...@@ -19,6 +19,7 @@ int coherency_get_cpu_count(void); ...@@ -19,6 +19,7 @@ int coherency_get_cpu_count(void);
#endif #endif
int set_cpu_coherent(int cpu_id, int smp_group_id); int set_cpu_coherent(int cpu_id, int smp_group_id);
int coherency_available(void);
int coherency_init(void); int coherency_init(void);
#endif /* __MACH_370_XP_COHERENCY_H */ #endif /* __MACH_370_XP_COHERENCY_H */
...@@ -213,7 +213,7 @@ void __init orion5x_init_early(void) ...@@ -213,7 +213,7 @@ void __init orion5x_init_early(void)
mbus_soc_name = NULL; mbus_soc_name = NULL;
mvebu_mbus_init(mbus_soc_name, ORION5X_BRIDGE_WINS_BASE, mvebu_mbus_init(mbus_soc_name, ORION5X_BRIDGE_WINS_BASE,
ORION5X_BRIDGE_WINS_SZ, ORION5X_BRIDGE_WINS_SZ,
ORION5X_DDR_WINS_BASE, ORION5X_DDR_WINS_SZ); ORION5X_DDR_WINS_BASE, ORION5X_DDR_WINS_SZ, 0);
} }
void orion5x_setup_wins(void) void orion5x_setup_wins(void)
......
...@@ -838,7 +838,7 @@ fs_initcall(mvebu_mbus_debugfs_init); ...@@ -838,7 +838,7 @@ fs_initcall(mvebu_mbus_debugfs_init);
int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
size_t mbuswins_size, size_t mbuswins_size,
phys_addr_t sdramwins_phys_base, phys_addr_t sdramwins_phys_base,
size_t sdramwins_size) size_t sdramwins_size, int is_coherent)
{ {
struct mvebu_mbus_state *mbus = &mbus_state; struct mvebu_mbus_state *mbus = &mbus_state;
const struct of_device_id *of_id; const struct of_device_id *of_id;
...@@ -865,8 +865,7 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, ...@@ -865,8 +865,7 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
return -ENOMEM; return -ENOMEM;
} }
if (of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric")) mbus->hw_io_coherency = is_coherent;
mbus->hw_io_coherency = 1;
for (win = 0; win < mbus->soc->num_wins; win++) for (win = 0; win < mbus->soc->num_wins; win++)
mvebu_mbus_disable_window(mbus, win); mvebu_mbus_disable_window(mbus, win);
......
...@@ -67,6 +67,6 @@ int mvebu_mbus_add_window(const char *devname, phys_addr_t base, ...@@ -67,6 +67,6 @@ int mvebu_mbus_add_window(const char *devname, phys_addr_t base,
int mvebu_mbus_del_window(phys_addr_t base, size_t size); 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, 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 mbus_size, phys_addr_t sdram_phys_base,
size_t sdram_size); size_t sdram_size, int is_coherent);
#endif /* __LINUX_MBUS_H */ #endif /* __LINUX_MBUS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment