From patchwork Wed May 7 01:41:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 4124841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4DF9BFF02 for ; Wed, 7 May 2014 01:44:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16AD02024F for ; Wed, 7 May 2014 01:44:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F15F620222 for ; Wed, 7 May 2014 01:44:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhqsP-0006HR-Cv; Wed, 07 May 2014 01:42:29 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhqsN-0006Fz-QD for linux-arm-kernel@lists.infradead.org; Wed, 07 May 2014 01:42:28 +0000 Received: by mail-pa0-f41.google.com with SMTP id lj1so339014pab.28 for ; Tue, 06 May 2014 18:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0eCiJZi8DOpW4hYSQKCh22wg6SVEYR0TOBcTImC29OA=; b=UmZbYzJsitMnD2U7QqrwHfSltzarNO51z1lhXcN9lLrfPlaRspFE5Neg2Bd41iAG9E k+P4lhN5+RVutYL0s3jpjNGBv6BqVPLJudV3UqOLpzcnonBDqzPJ5I08NsPFNXWrzRUt tBtLUCyv17eeVFdk6yZCnbC4GDakN6Flbi0RRIvTuNVy8fjQ167A2uKoMvkK8cCllMXg sZUk1E103Zxz7I0RGwpCY/qUQq4ouSsK4HpJKb6zBbolOWSZ7JqwDR0XJ09QyI4S5adn +b+U/gOTnDcYGcgBAyz9EgDvQmmI0H24rU1rVGSPRn0p5kOEkPjolkPFmPkuiDfQUoOd MALg== X-Received: by 10.66.219.225 with SMTP id pr1mr12861101pac.83.1399426926082; Tue, 06 May 2014 18:42:06 -0700 (PDT) Received: from localhost ([122.179.39.122]) by mx.google.com with ESMTPSA id qh2sm105905090pab.13.2014.05.06.18.42.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 06 May 2014 18:42:05 -0700 (PDT) From: arunks.linux@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v1 2/2] arm64: Fix deadlock scenario with smp_send_stop() Date: Wed, 7 May 2014 07:11:23 +0530 Message-Id: <1399426883-13779-2-git-send-email-arunks.linux@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1399426883-13779-1-git-send-email-arunks.linux@gmail.com> References: <1399426883-13779-1-git-send-email-arunks.linux@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140506_184227_868759_0A73458E X-CRM114-Status: GOOD ( 11.87 ) X-Spam-Score: -0.1 (/) Cc: catalin.marinas@arm.com, Arun KS , Arun KS , swarren@nvidia.com, sboyd@codeaurora.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arun KS 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() 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 this task runs to completion. We use local_irq_disable() here for cross-arch consistency with x86. Based-on-work-by: Stephen Boyd Signed-off-by: Arun KS --- arch/arm64/kernel/process.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 2d43614..abe57e0 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -134,6 +134,7 @@ void machine_shutdown(void) */ void machine_halt(void) { + local_irq_disable(); smp_send_stop(); while (1); } @@ -146,6 +147,7 @@ void machine_halt(void) */ void machine_power_off(void) { + local_irq_disable(); smp_send_stop(); if (pm_power_off) pm_power_off(); @@ -164,10 +166,9 @@ void machine_power_off(void) */ void machine_restart(char *cmd) { - smp_send_stop(); - /* Disable interrupts first */ local_irq_disable(); + smp_send_stop(); /* Now call the architecture specific reboot code. */ if (arm_pm_restart)