Skip to contentSkip to conversation

powerpc/kdump: Fix timeout in crash_kexec_wait_realmode

PATCH New Anton Blanchard 2 participants 3 messages Jul 5, 2011 – Jul 6, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/kdump: Fix timeout in crash_kexec_wait_realmode

We check for timeout expiry in the outer loop, but we also need to check it in the inner loop or we can lock up forever waiting for a CPU to hit real mode.

---

arch/powerpc/kernel/crash.c +2 -1
Index: linux-powerpc/arch/powerpc/kernel/crash.c
===================================================================
@@ -240,7 +240,8 @@ static void crash_kexec_wait_realmode(in
 		if (i == cpu)
 			continue;
 
-		while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) {
+		while ((paca[i].kexec_state < KEXEC_STATE_REAL_MODE) &&
+				(msecs > 0)) {
 			barrier();
 			if (!cpu_possible(i)) {
 				break;
#1 lore raw

PATCH 1/1 powerpc/kdump: Fix timeout in crash_kexec_wait_realmode

The existing code it pretty ugly. How about we clean it up even more like this?

From: Anton Blanchard <[email protected]>

We check for timeout expiry in the outer loop, but we also need to check it in the inner loop or we can lock up forever waiting for a CPU to hit real mode.

arch/powerpc/kernel/crash.c +1 -5
index 4e6ee94..cc6a9d5 100644
@@ -242,12 +242,8 @@ static void crash_kexec_wait_realmode(int cpu)
 
 		while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) {
 			barrier();
-			if (!cpu_possible(i)) {
+			if (!cpu_possible(i) || !cpu_online(i) || (msecs <= 0))
 				break;
-			}
-			if (!cpu_online(i)) {
-				break;
-			}
 			msecs--;
 			mdelay(1);
 		}
#2 lore raw
Quoted 2 lines · On Tue, 05 Jul 2011 16:40:10 +1000 Michael Neuling <[email protected]> wrote:

The existing code it pretty ugly. How about we clean it up even more like this?

Looks good and it passed my kdump test cases.

Anton

Quoted 29 lines

From: Anton Blanchard <[email protected]>

We check for timeout expiry in the outer loop, but we also need to check it in the inner loop or we can lock up forever waiting for a CPU to hit real mode.

arch/powerpc/kernel/crash.c +1 -5
index 4e6ee94..cc6a9d5 100644
@@ -242,12 +242,8 @@ static void crash_kexec_wait_realmode(int cpu)
 
 		while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) {
 			barrier();
-			if (!cpu_possible(i)) {
+			if (!cpu_possible(i) || !cpu_online(i) ||
 (msecs <= 0)) break;
-			}
-			if (!cpu_online(i)) {
-				break;
-			}
 			msecs--;
 			mdelay(1);
 		}