linux-mips
[Top] [All Lists]

[PATCH 08/11] MIPS: Netlogic: wait for all hardware threads

To: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: [PATCH 08/11] MIPS: Netlogic: wait for all hardware threads
From: "Jayachandran C" <jchandra@broadcom.com>
Date: Mon, 10 Jun 2013 13:11:07 +0530
Cc: "Jayachandran C" <jchandra@broadcom.com>
In-reply-to: <1370850070-5127-1-git-send-email-jchandra@broadcom.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1370850070-5127-1-git-send-email-jchandra@broadcom.com>
Sender: linux-mips-bounce@linux-mips.org
Earlier we just waited for the first thread of the CPU to come online
before proceeding to wake up others. Update it to wait for all the CPUs
in the core. This will be useful when the boot-up is slow, like while
debugging or when running in a simulator.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
 arch/mips/netlogic/xlp/wakeup.c |   27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c
index feb5736..0cce37c 100644
--- a/arch/mips/netlogic/xlp/wakeup.c
+++ b/arch/mips/netlogic/xlp/wakeup.c
@@ -77,13 +77,28 @@ static int xlp_wakeup_core(uint64_t sysbase, int node, int 
core)
        return count != 0;
 }
 
+static int wait_for_cpus(int cpu, int bootcpu)
+{
+       volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY);
+       int i, count, notready;
+
+       count = 0x20000000;
+       do {
+               notready = nlm_threads_per_core;
+               for (i = 0; i < nlm_threads_per_core; i++)
+                       if (cpu_ready[cpu + i] || cpu == bootcpu)
+                               --notready;
+       } while (notready != 0 && --count > 0);
+
+       return count != 0;
+}
+
 static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask)
 {
        struct nlm_soc_info *nodep;
        uint64_t syspcibase;
        uint32_t syscoremask;
-       volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY);
-       int core, n, cpu, count, val;
+       int core, n, cpu;
 
        for (n = 0; n < NLM_NR_NODES; n++) {
                syspcibase = nlm_get_sys_pcibase(n);
@@ -123,11 +138,8 @@ static void xlp_enable_secondary_cores(const cpumask_t 
*wakeup_mask)
                        /* core is up */
                        nodep->coremask |= 1u << core;
 
-                       /* spin until the first hw thread sets its ready */
-                       count = 0x20000000;
-                       do {
-                               val = cpu_ready[cpu];
-                       } while (val == 0 && --count > 0);
+                       /* spin until the hw threads sets their ready */
+                       wait_for_cpus(cpu, 0);
                }
        }
 }
@@ -139,6 +151,7 @@ void xlp_wakeup_secondary_cpus()
         * first wakeup core 0 threads
         */
        xlp_boot_core0_siblings();
+       wait_for_cpus(0, 0);
 
        /* now get other cores out of reset */
        xlp_enable_secondary_cores(&nlm_cpumask);
-- 
1.7.9.5



<Prev in Thread] Current Thread [Next in Thread>