mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: imx6: add OF fixup to delete nonexistent CPU cores
@ 2015-10-26 16:33 Lucas Stach
  2015-10-27 14:43 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2015-10-26 16:33 UTC (permalink / raw)
  To: barebox

Make sure that the DT passed to Linux reflects the actual number of CPU
cores present in the system by reading the SCU configuration. As both
the Q and DL variants of the MX6 have versions with cores fused away,
but the DTs have the maximum number of cores specified, this just deletes
any nonexistent CPU core nodes.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index c49de49209f3..c2a4d62c51da 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -238,3 +238,37 @@ static int imx6_mmu_init(void)
 	return 0;
 }
 postmmu_initcall(imx6_mmu_init);
+
+#define SCU_CONFIG	0x04
+
+static int imx6_fixup_cpus(struct device_node *root, void *context)
+{
+	struct device_node *cpus_node, *np, *tmp;
+	unsigned long scu_phys_base;
+	unsigned int max_core_index;
+
+	cpus_node = of_find_node_by_name(root, "cpus");
+	if (!cpus_node)
+		return 0;
+
+	/* get actual number of available CPU cores from SCU */
+	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (scu_phys_base));
+	max_core_index = (readl(IOMEM(scu_phys_base) + SCU_CONFIG) & 0x03);
+
+	for_each_child_of_node_safe(cpus_node, tmp, np) {
+		u32 cpu_index;
+
+		if (of_property_read_u32(np, "reg", &cpu_index))
+			continue;
+
+		if (cpu_index > max_core_index)
+			of_delete_node(np);
+	}
+
+	return 0;
+}
+
+static int imx6_fixup_cpus_register(void) {
+	return of_register_fixup(imx6_fixup_cpus, NULL);
+}
+device_initcall(imx6_fixup_cpus_register);
-- 
2.6.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: imx6: add OF fixup to delete nonexistent CPU cores
  2015-10-26 16:33 [PATCH] ARM: imx6: add OF fixup to delete nonexistent CPU cores Lucas Stach
@ 2015-10-27 14:43 ` Sascha Hauer
  2015-10-27 14:45   ` Lucas Stach
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2015-10-27 14:43 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Mon, Oct 26, 2015 at 05:33:49PM +0100, Lucas Stach wrote:
> Make sure that the DT passed to Linux reflects the actual number of CPU
> cores present in the system by reading the SCU configuration. As both
> the Q and DL variants of the MX6 have versions with cores fused away,
> but the DTs have the maximum number of cores specified, this just deletes
> any nonexistent CPU core nodes.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/mach-imx/imx6.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> index c49de49209f3..c2a4d62c51da 100644
> --- a/arch/arm/mach-imx/imx6.c
> +++ b/arch/arm/mach-imx/imx6.c
> @@ -238,3 +238,37 @@ static int imx6_mmu_init(void)
>  	return 0;
>  }
>  postmmu_initcall(imx6_mmu_init);
> +
> +#define SCU_CONFIG	0x04
> +
> +static int imx6_fixup_cpus(struct device_node *root, void *context)
> +{
> +	struct device_node *cpus_node, *np, *tmp;
> +	unsigned long scu_phys_base;
> +	unsigned int max_core_index;
> +
> +	cpus_node = of_find_node_by_name(root, "cpus");
> +	if (!cpus_node)
> +		return 0;
> +
> +	/* get actual number of available CPU cores from SCU */
> +	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (scu_phys_base));
> +	max_core_index = (readl(IOMEM(scu_phys_base) + SCU_CONFIG) & 0x03);
> +
> +	for_each_child_of_node_safe(cpus_node, tmp, np) {
> +		u32 cpu_index;
> +
> +		if (of_property_read_u32(np, "reg", &cpu_index))
> +			continue;
> +
> +		if (cpu_index > max_core_index)
> +			of_delete_node(np);
> +	}
> +
> +	return 0;
> +}
> +
> +static int imx6_fixup_cpus_register(void) {
> +	return of_register_fixup(imx6_fixup_cpus, NULL);
> +}
> +device_initcall(imx6_fixup_cpus_register);

Please make sure we do this on i.MX6 only.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: imx6: add OF fixup to delete nonexistent CPU cores
  2015-10-27 14:43 ` Sascha Hauer
@ 2015-10-27 14:45   ` Lucas Stach
  0 siblings, 0 replies; 3+ messages in thread
From: Lucas Stach @ 2015-10-27 14:45 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Am Dienstag, den 27.10.2015, 15:43 +0100 schrieb Sascha Hauer:
> On Mon, Oct 26, 2015 at 05:33:49PM +0100, Lucas Stach wrote:
> > Make sure that the DT passed to Linux reflects the actual number of CPU
> > cores present in the system by reading the SCU configuration. As both
> > the Q and DL variants of the MX6 have versions with cores fused away,
> > but the DTs have the maximum number of cores specified, this just deletes
> > any nonexistent CPU core nodes.
> > 
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > ---
> >  arch/arm/mach-imx/imx6.c | 34 ++++++++++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> > 
> > diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> > index c49de49209f3..c2a4d62c51da 100644
> > --- a/arch/arm/mach-imx/imx6.c
> > +++ b/arch/arm/mach-imx/imx6.c
> > @@ -238,3 +238,37 @@ static int imx6_mmu_init(void)
> >  	return 0;
> >  }
> >  postmmu_initcall(imx6_mmu_init);
> > +
> > +#define SCU_CONFIG	0x04
> > +
> > +static int imx6_fixup_cpus(struct device_node *root, void *context)
> > +{
> > +	struct device_node *cpus_node, *np, *tmp;
> > +	unsigned long scu_phys_base;
> > +	unsigned int max_core_index;
> > +
> > +	cpus_node = of_find_node_by_name(root, "cpus");
> > +	if (!cpus_node)
> > +		return 0;
> > +
> > +	/* get actual number of available CPU cores from SCU */
> > +	asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (scu_phys_base));
> > +	max_core_index = (readl(IOMEM(scu_phys_base) + SCU_CONFIG) & 0x03);
> > +
> > +	for_each_child_of_node_safe(cpus_node, tmp, np) {
> > +		u32 cpu_index;
> > +
> > +		if (of_property_read_u32(np, "reg", &cpu_index))
> > +			continue;
> > +
> > +		if (cpu_index > max_core_index)
> > +			of_delete_node(np);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int imx6_fixup_cpus_register(void) {
> > +	return of_register_fixup(imx6_fixup_cpus, NULL);
> > +}
> > +device_initcall(imx6_fixup_cpus_register);
> 
> Please make sure we do this on i.MX6 only.
> 
Argh, right. It's so easy to forget about that...

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-27 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 16:33 [PATCH] ARM: imx6: add OF fixup to delete nonexistent CPU cores Lucas Stach
2015-10-27 14:43 ` Sascha Hauer
2015-10-27 14:45   ` Lucas Stach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox