aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-05-14 01:12:31 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-05-14 01:12:31 -0400
commitb2b48584dfc69a5ebc70ee7976524d7122e5df5f (patch)
tree0b13cf3bae358c65aa577ef7f3ee9962bf6fff43 /arch/powerpc
parent75b93da43aa1132bf23dafbb4badb028ccf78129 (diff)
powerpc/powernv: Fix starting of secondary CPUs on OPALv2 and v3
The current code fails to handle kexec on OPALv2. This fixes it and adds code to improve the situation on OPALv3 where we can query the CPU status from the firmware and decide what to do based on that. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/powernv/smp.c62
1 files changed, 56 insertions, 6 deletions
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 6a3ecca5b725..88c9459c3e07 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -71,18 +71,68 @@ int pnv_smp_kick_cpu(int nr)
71 71
72 BUG_ON(nr < 0 || nr >= NR_CPUS); 72 BUG_ON(nr < 0 || nr >= NR_CPUS);
73 73
74 /* On OPAL v2 the CPU are still spinning inside OPAL itself, 74 /*
75 * get them back now 75 * If we already started or OPALv2 is not supported, we just
76 * kick the CPU via the PACA
76 */ 77 */
77 if (!paca[nr].cpu_start && firmware_has_feature(FW_FEATURE_OPALv2)) { 78 if (paca[nr].cpu_start || !firmware_has_feature(FW_FEATURE_OPALv2))
78 pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n", nr, pcpu); 79 goto kick;
79 rc = opal_start_cpu(pcpu, start_here); 80
81 /*
82 * At this point, the CPU can either be spinning on the way in
83 * from kexec or be inside OPAL waiting to be started for the
84 * first time. OPAL v3 allows us to query OPAL to know if it
85 * has the CPUs, so we do that
86 */
87 if (firmware_has_feature(FW_FEATURE_OPALv3)) {
88 uint8_t status;
89
90 rc = opal_query_cpu_status(pcpu, &status);
80 if (rc != OPAL_SUCCESS) { 91 if (rc != OPAL_SUCCESS) {
81 pr_warn("OPAL Error %ld starting CPU %d\n", 92 pr_warn("OPAL Error %ld querying CPU %d state\n",
82 rc, nr); 93 rc, nr);
83 return -ENODEV; 94 return -ENODEV;
84 } 95 }
96
97 /*
98 * Already started, just kick it, probably coming from
99 * kexec and spinning
100 */
101 if (status == OPAL_THREAD_STARTED)
102 goto kick;
103
104 /*
105 * Available/inactive, let's kick it
106 */
107 if (status == OPAL_THREAD_INACTIVE) {
108 pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n",
109 nr, pcpu);
110 rc = opal_start_cpu(pcpu, start_here);
111 if (rc != OPAL_SUCCESS) {
112 pr_warn("OPAL Error %ld starting CPU %d\n",
113 rc, nr);
114 return -ENODEV;
115 }
116 } else {
117 /*
118 * An unavailable CPU (or any other unknown status)
119 * shouldn't be started. It should also
120 * not be in the possible map but currently it can
121 * happen
122 */
123 pr_devel("OPAL: CPU %d (HW 0x%x) is unavailable"
124 " (status %d)...\n", nr, pcpu, status);
125 return -ENODEV;
126 }
127 } else {
128 /*
129 * On OPAL v2, we just kick it and hope for the best,
130 * we must not test the error from opal_start_cpu() or
131 * we would fail to get CPUs from kexec.
132 */
133 opal_start_cpu(pcpu, start_here);
85 } 134 }
135 kick:
86 return smp_generic_kick_cpu(nr); 136 return smp_generic_kick_cpu(nr);
87} 137}
88 138