From patchwork Tue Jul 5 06:40:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 103203 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id AC89D100AB8 for ; Tue, 5 Jul 2011 16:40:17 +1000 (EST) Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id DCE6B1007D1; Tue, 5 Jul 2011 16:40:10 +1000 (EST) Received: by localhost.localdomain (Postfix, from userid 1000) id BFC4DC39C9; Tue, 5 Jul 2011 16:40:10 +1000 (EST) Received: from neuling.org (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id BA9F2C3587; Tue, 5 Jul 2011 16:40:10 +1000 (EST) From: Michael Neuling To: Anton Blanchard Subject: [PATCH] powerpc/kdump: Fix timeout in crash_kexec_wait_realmode In-reply-to: <20110705161202.62dc7d24@kryten> References: <20110705161202.62dc7d24@kryten> Comments: In-reply-to Anton Blanchard message dated "Tue, 05 Jul 2011 16:12:02 +1000." X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.2.1 Date: Tue, 05 Jul 2011 16:40:10 +1000 Message-ID: <29259.1309848010@neuling.org> Cc: linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org The existing code it pretty ugly. How about we clean it up even more like this? From: Anton Blanchard 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. Signed-off-by: Anton Blanchard Signed-off-by: Michael Neuling Cc: diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index 4e6ee94..cc6a9d5 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c @@ -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); }