From patchwork Wed Sep 5 21:01:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 1411041 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id F10F5DF28C for ; Wed, 5 Sep 2012 21:04:45 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9MjP-0006Kq-TV; Wed, 05 Sep 2012 21:01:51 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T9MjM-0006KS-Lk for linux-arm-kernel@lists.infradead.org; Wed, 05 Sep 2012 21:01:49 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6826"; a="230997338" Received: from pdmz-ns-snip_115.254.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.254]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Sep 2012 14:01:29 -0700 Received: from sboyd-linux.qualcomm.com (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 5512710004AB; Wed, 5 Sep 2012 14:01:29 -0700 (PDT) From: Stephen Boyd To: Russell King - ARM Linux Subject: [PATCH] ARM: Fix deadlock scenario with smp_send_stop() Date: Wed, 5 Sep 2012 14:01:26 -0700 Message-Id: <1346878886-7159-1-git-send-email-sboyd@codeaurora.org> X-Mailer: git-send-email 1.7.12.176.g3fc0e4c X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.251 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If one process calls sys_reboot and that process then stops other CPUs while those CPUs are within a spin_lock() region we can potentially encounter a deadlock scenario like below. CPU 0 CPU 1 ----- ----- spin_lock(my_lock) smp_send_stop() send_IPI handle_IPI() disable_preemption/irqs while(1); spin_lock(my_lock) <--- Waits forever We shouldn't attempt to run any other tasks after we send a stop IPI to a CPU so disable preemption so that the reboot task runs to completion. Reported-by: Sundarajan Srinivasan Signed-off-by: Stephen Boyd --- Unfortunately this won't fix the other problem I mentioned two weeks ago where smp_send_stop races with other CPUs calling cpu_up(). arch/arm/kernel/process.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 693b744..663a7a8 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -239,6 +239,7 @@ __setup("reboot=", reboot_setup); void machine_shutdown(void) { + preempt_disable(); #ifdef CONFIG_SMP smp_send_stop(); #endif