On 27/09/12 01:36, thar...@gateworks.com wrote:
Fix number of cores present in system.
cns3xxx always has multiple cores according to SCU_CONFIGURATION but looking
at SCU_CPU_STATUS tells you which ones are active.
Signed-off-by: Tim Harvey<thar...@gateworks.com>
target/linux/cns3xxx/patches-3.3/450-smp_ncores.patch | 130
++++++++++++++++++
1 file changed, 130 insertions(+)
Index: trunk/target/linux/cns3xxx/patches-3.3/450-smp_ncores.patch
===================================================================
--- trunk/target/linux/cns3xxx/patches-3.3/450-smp_ncores.patch (revision 0)
+++ trunk/target/linux/cns3xxx/patches-3.3/450-smp_ncores.patch (working copy)
@@ -0,0 +1,130 @@
+--- a/arch/arm/mach-cns3xxx/platsmp.c
++++ b/arch/arm/mach-cns3xxx/platsmp.c
+@@ -1,18 +1,17 @@
+-/* linux/arch/arm/mach-cns3xxx/platsmp.c
++/*
++ * linux/arch/arm/mach-cns3xxx/platsmp.c
+ *
+- * Copyright 2011 Gateworks Corporation
++ * Copyright (C) 2002 ARM Ltd.
++ * Copyright 2012 Gateworks Corporation
+ * Chris Lang<cl...@gateworks.com>
++ * Tim Harvey<thar...@gateworks.com>
+ *
+- * Cloned from linux/arch/arm/mach-vexpress/platsmp.c
+- *
+- * Copyright (C) 2002 ARM Ltd.
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+-*/
+-
++ */
+ #include<linux/init.h>
+ #include<linux/errno.h>
+ #include<linux/delay.h>
+@@ -30,11 +29,13 @@
+
+ extern void cns3xxx_secondary_startup(void);
+
++#define SCU_CPU_STATUS 0x08
++static void __iomem *scu_base;
++
+ /*
+ * control for which core is the next to come out of the secondary
+ * boot "holding pen"
+ */
+-
+ volatile int __cpuinitdata pen_release = -1;
+
+ /*
+@@ -50,11 +51,6 @@ static void write_pen_release(int val)
+ outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1));
+ }
+
+-static void __iomem *scu_base_addr(void)
+-{
+- return (void __iomem *)(CNS3XXX_TC11MP_SCU_BASE_VIRT);
+-}
+-
+ static DEFINE_SPINLOCK(boot_lock);
+
+ void __cpuinit platform_secondary_init(unsigned int cpu)
+@@ -128,25 +124,28 @@ int __cpuinit boot_secondary(unsigned in
+ * Initialise the CPU possible map early - this describes the CPUs
+ * which may be present or become present in the system.
+ */
+-
+ void __init smp_init_cpus(void)
+ {
+- void __iomem *scu_base = scu_base_addr();
+ unsigned int i, ncores;
++ unsigned int status;
+
+- ncores = scu_base ? scu_get_core_count(scu_base) : 1;
+-
+- /* sanity check */
+- if (ncores> NR_CPUS) {
+- printk(KERN_WARNING
+- "cns3xxx: no. of cores (%d) greater than configured "
+- "maximum of %d - clipping\n",
+- ncores, NR_CPUS);
+- ncores = NR_CPUS;
++printk("\n\n%s\n", __func__);
++ scu_base = (void __iomem *) CNS3XXX_TC11MP_SCU_BASE_VIRT;
++ /*
++ * for CNS3xxx SCU_CPU_STATUS is more reliable than SCU_CONFIGURATION
++ * used in arch/arm/kernel/smp_scu.c
++ */
++ //ncores = scu_get_core_count(scu_base);
++ status = __raw_readl(scu_base + SCU_CPU_STATUS);
++printk("%s: status=%x\n", __func__, status);
++ for (i = 0; i< NR_CPUS+1; i++) {
++ if (((status>> (i*2))& 0x3) == 0)
++ set_cpu_possible(i, true);
++ else
++ break;
+ }
+-
+- for (i = 0; i< ncores; i++)
+- set_cpu_possible(i, true);
++ ncores = i;
++printk("ncores=%d\n", ncores);
+
+ set_smp_cross_call(gic_raise_softirq);
+ }
+@@ -154,15 +153,29 @@ void __init smp_init_cpus(void)
+ void __init platform_smp_prepare_cpus(unsigned int max_cpus)
+ {
+ int i;
++ unsigned int status;
+
+ /*
+ * Initialise the present map, which describes the set of CPUs
+ * actually populated at the present time.
++ *
++ * for CNS3xxx SCU_CPU_STATUS is more reliable than SCU_CONFIGURATION
++ * used in arch/arm/kernel/smp_scu.c
+ */
+- for (i = 0; i< max_cpus; i++)
+- set_cpu_present(i, true);
++ status = __raw_readl(scu_base + SCU_CPU_STATUS);
++printk("\n\n%s: max_cpus=%d status=%x\n", __func__, max_cpus, status);
whitespace breakge
++ for (i = 0; i< max_cpus; i++) {
++ if (((status>> (i*2))& 0x3) == 0)
++{
++printk("CPU%d\n", i);
ditto
++ set_cpu_present(i, true);
++}
++ }
+
+- scu_enable(scu_base_addr());
++ /*
++ * enable SCU
++ */
++ scu_enable(scu_base);
+
+ /*
+ * Write the address of secondary startup into the
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel