* [PATCH 1/2] ARM: kernel: DT cpu map validity check helper function
@ 2013-01-14 7:52 Hiroshi Doyu
[not found] ` <1358149970-28156-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Hiroshi Doyu @ 2013-01-14 7:52 UTC (permalink / raw)
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
Cc: lorenzo.pieralisi-5wv7dgnIgG8, linux-lFZ/pmaqli7XmaaqVzeoHQ
From: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
Since the introduction of /cpu nodes bindings for ARM and the
corresponding parse function arm_dt_init_cpu_maps(), the cpu_logical_map
and the number of possible CPUs are set according to the DT /cpu
nodes entries. Currently most of the existing ARM SMP platforms detect the
number of cores through HW probing in their .smp_init_cpus functions and set
the possible CPU mask accordingly.
This method should be upgraded so that the CPU counting mechanism will be
based on DT, keeping legacy HW probing mechanism as a fall back solution.
In order to implement this fall back solution mechanism, the ARM DT code
should provide a helper function to platforms to check if the cpu map
has been properly initialized through DT. If the check fails the
platform will resort to legacy HW based cores counting mechanism.
This patch implements a helper function that platforms can call to check
whether DT based cpu map initialization and cores count were completed
successfully.
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
---
arch/arm/include/asm/prom.h | 10 ++++++++++
arch/arm/kernel/devtree.c | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h
index a219227..487614a 100644
--- a/arch/arm/include/asm/prom.h
+++ b/arch/arm/include/asm/prom.h
@@ -18,6 +18,15 @@
extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
extern void arm_dt_memblock_reserve(void);
extern void __init arm_dt_init_cpu_maps(void);
+/*
+ * Return true if cpu map initialization has been
+ * carried out correctly from DT
+ */
+static inline bool __init arm_dt_cpu_map_valid(void)
+{
+ extern bool valid_dt_cpu_map;
+ return valid_dt_cpu_map;
+}
#else /* CONFIG_OF */
@@ -28,6 +37,7 @@ static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys)
static inline void arm_dt_memblock_reserve(void) { }
static inline void arm_dt_init_cpu_maps(void) { }
+static inline bool __init arm_dt_cpu_map_valid(void) { return false; }
#endif /* CONFIG_OF */
#endif /* ASMARM_PROM_H */
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 70f1bde..4d8d1ec 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -64,6 +64,11 @@ void __init arm_dt_memblock_reserve(void)
}
/*
+ * Export DT cpu map validity flag to platforms
+ */
+bool valid_dt_cpu_map __initdata;
+
+/*
* arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
* and builds the cpu logical map array containing MPIDR values related to
* logical cpus
@@ -158,6 +163,7 @@ void __init arm_dt_init_cpu_maps(void)
* a reg property, the DT CPU list can be considered valid and the
* logical map created in smp_setup_processor_id() can be overridden
*/
+ valid_dt_cpu_map = true;
for (i = 0; i < cpuidx; i++) {
set_cpu_possible(i, true);
cpu_logical_map(i) = tmp_map[i];
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ARM: tegra: Use DT /cpu node to detect number of CPU core
[not found] ` <1358149970-28156-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-01-14 7:52 ` Hiroshi Doyu
[not found] ` <1358149970-28156-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Hiroshi Doyu @ 2013-01-14 7:52 UTC (permalink / raw)
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
Cc: lorenzo.pieralisi-5wv7dgnIgG8, linux-lFZ/pmaqli7XmaaqVzeoHQ,
Hiroshi Doyu
SCU based detection only works with Cortex-A9 MP and it doesn't
support ones with multiple clusters. The only way to detect number of
CPU core correctly is with DT /cpu node. If DT /cpu node based
detection fails, we just simply fall back a single core in Tegra SoCs.
Signed-off-by: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
Based on the discussion:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/140608.html
---
arch/arm/mach-tegra/platsmp.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 6867030..456e7cc 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -24,6 +24,7 @@
#include <asm/mach-types.h>
#include <asm/smp_scu.h>
#include <asm/smp_plat.h>
+#include <asm/prom.h>
#include <mach/powergate.h>
@@ -177,22 +178,10 @@ done:
return status;
}
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
static void __init tegra_smp_init_cpus(void)
{
- unsigned int i, ncores = scu_get_core_count(scu_base);
-
- if (ncores > nr_cpu_ids) {
- pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
- ncores, nr_cpu_ids);
- ncores = nr_cpu_ids;
- }
-
- for (i = 0; i < ncores; i++)
- set_cpu_possible(i, true);
+ if (!arm_dt_cpu_map_valid())
+ set_cpu_possible(0, true);
set_smp_cross_call(gic_raise_softirq);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ARM: tegra: Use DT /cpu node to detect number of CPU core
[not found] ` <1358149970-28156-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-01-14 9:27 ` Russell King - ARM Linux
[not found] ` <20130114092720.GX23505-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Russell King - ARM Linux @ 2013-01-14 9:27 UTC (permalink / raw)
To: Hiroshi Doyu
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, lorenzo.pieralisi-5wv7dgnIgG8
On Mon, Jan 14, 2013 at 09:52:50AM +0200, Hiroshi Doyu wrote:
> + if (!arm_dt_cpu_map_valid())
> + set_cpu_possible(0, true);
You don't need to do any of this (and, therefore, I don't think you even
need the first patch.)
The generic boot code will set CPU0 as possible, present and online. Think
about it: you're booting on that very CPU so it better be possible, present
and online. If it isn't, what CPU is executing your code?
arm_dt_init_cpu_maps() will only ever set _additional_ CPUs in the possible
map.
Ergo, by the time the above code is run, CPU0 will already be marked as
possible. Therefore, the above code and arm_dt_cpu_map_valid() is not
required.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ARM: tegra: Use DT /cpu node to detect number of CPU core
[not found] ` <20130114092720.GX23505-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 2013-01-14 9:49 ` Hiroshi Doyu
[not found] ` <20130114.114925.1476619399284636466.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Hiroshi Doyu @ 2013-01-14 9:49 UTC (permalink / raw)
To: linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org, Stephen Warren,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Hi Russell,
Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> wrote @ Mon, 14 Jan 2013 10:27:20 +0100:
> On Mon, Jan 14, 2013 at 09:52:50AM +0200, Hiroshi Doyu wrote:
> > + if (!arm_dt_cpu_map_valid())
> > + set_cpu_possible(0, true);
>
> You don't need to do any of this (and, therefore, I don't think you even
> need the first patch.)
>
> The generic boot code will set CPU0 as possible, present and online. Think
> about it: you're booting on that very CPU so it better be possible, present
> and online. If it isn't, what CPU is executing your code?
>
> arm_dt_init_cpu_maps() will only ever set _additional_ CPUs in the possible
> map.
>
> Ergo, by the time the above code is run, CPU0 will already be marked as
> possible. Therefore, the above code and arm_dt_cpu_map_valid() is not
> required.
Right.
In Tegra, we've decided to not use SCU based detection at all any more
and to continue with a single core even when DT cpu detection
fails. For Tegra, "arm_dt_cpu_map_valid()" is not necessary. For other
SoCs, this would be necessary when they want to detect again with
SCU.
Now this original Tegra patch would be independet of the 1st patch as
below:
>From 36061aff7a772524a1d1785884889619042d4445 Mon Sep 17 00:00:00 2001
From: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Date: Mon, 26 Nov 2012 12:25:14 +0200
Subject: [PATCH 1/1] ARM: tegra: Use DT /cpu node to detect number of CPU
core
SCU based detection only works with Cortex-A9 MP and it doesn't
support ones with multiple clusters. The only way to detect number of
CPU core correctly is with DT /cpu node.
Tegra SoCs decided to use DT detection as the only way and to not use
SCU based detection at all. Even if DT /cpu node based detection
fails, it continues with a single core
Signed-off-by: Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
Based on the discussion:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/140608.html
---
arch/arm/mach-tegra/platsmp.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 6867030..689ee4b 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -177,23 +177,8 @@ done:
return status;
}
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
static void __init tegra_smp_init_cpus(void)
{
- unsigned int i, ncores = scu_get_core_count(scu_base);
-
- if (ncores > nr_cpu_ids) {
- pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
- ncores, nr_cpu_ids);
- ncores = nr_cpu_ids;
- }
-
- for (i = 0; i < ncores; i++)
- set_cpu_possible(i, true);
-
set_smp_cross_call(gic_raise_softirq);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ARM: tegra: Use DT /cpu node to detect number of CPU core
[not found] ` <20130114.114925.1476619399284636466.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-01-14 12:35 ` Lorenzo Pieralisi
0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Pieralisi @ 2013-01-14 12:35 UTC (permalink / raw)
To: Hiroshi Doyu
Cc: linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org, Stephen Warren,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
On Mon, Jan 14, 2013 at 09:49:25AM +0000, Hiroshi Doyu wrote:
> Hi Russell,
>
> Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> wrote @ Mon, 14 Jan 2013 10:27:20 +0100:
>
> > On Mon, Jan 14, 2013 at 09:52:50AM +0200, Hiroshi Doyu wrote:
> > > + if (!arm_dt_cpu_map_valid())
> > > + set_cpu_possible(0, true);
> >
> > You don't need to do any of this (and, therefore, I don't think you even
> > need the first patch.)
> >
> > The generic boot code will set CPU0 as possible, present and online. Think
> > about it: you're booting on that very CPU so it better be possible, present
> > and online. If it isn't, what CPU is executing your code?
> >
> > arm_dt_init_cpu_maps() will only ever set _additional_ CPUs in the possible
> > map.
> >
> > Ergo, by the time the above code is run, CPU0 will already be marked as
> > possible. Therefore, the above code and arm_dt_cpu_map_valid() is not
> > required.
>
> Right.
>
> In Tegra, we've decided to not use SCU based detection at all any more
> and to continue with a single core even when DT cpu detection
> fails. For Tegra, "arm_dt_cpu_map_valid()" is not necessary. For other
> SoCs, this would be necessary when they want to detect again with
> SCU.
Correct. I will keep my patch around and repost it if and when we want other
platforms to rely on legacy HW number of cores count discovery.
Given that's going to be temporary legacy code anyway, I hope we won't need it
at all.
Lorenzo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-14 12:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-14 7:52 [PATCH 1/2] ARM: kernel: DT cpu map validity check helper function Hiroshi Doyu
[not found] ` <1358149970-28156-1-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-14 7:52 ` [PATCH 2/2] ARM: tegra: Use DT /cpu node to detect number of CPU core Hiroshi Doyu
[not found] ` <1358149970-28156-2-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-14 9:27 ` Russell King - ARM Linux
[not found] ` <20130114092720.GX23505-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-01-14 9:49 ` Hiroshi Doyu
[not found] ` <20130114.114925.1476619399284636466.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-14 12:35 ` Lorenzo Pieralisi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).