From patchwork Thu May 8 13:23:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 4136211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A69D9F1E1 for ; Thu, 8 May 2014 13:27:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4A9E201D3 for ; Thu, 8 May 2014 13:27:17 +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 1060920034 for ; Thu, 8 May 2014 13:27:17 +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 1WiOJ2-00019M-Jl; Thu, 08 May 2014 13:24:12 +0000 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiOJ0-00018L-14 for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 13:24:10 +0000 Received: by mail-pd0-f181.google.com with SMTP id w10so2296971pde.40 for ; Thu, 08 May 2014 06:23:48 -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; bh=09Z+TIGQ7YLVfTw3hvh8KWagybZgLQy1c11bh32KS2U=; b=NL2OwAka9KO4CoAfAxepPMnFh4WPCrlWJILQHAwc0S5F2YXCUJoyryxv0OQb0ccUc2 TYmrGKZ617clJOAcQzKkcLylX3LzCD2hmbKUg+S0xAp2aVBXrU87TFsnHQeG6pmUvJYU hL8/QYC57/gpdJ9AK78MacnePOZIWkDzOYl5FeOMDD9IWiLzCYnA353ZDZyw/NmDeegg CJYl+RO753Bk8uXPjBG6nnC27WqNho8dgVDjSxKZuS3ptl3jQSbX94cCG1uTa5F9H4sc iXmpXtBVd3X9zd1fyifIazHrmo6Lb8nEGZc/oJ0/2q67Qzaj9oaycMV0Wi4khY/SLCBm Whng== X-Received: by 10.66.169.111 with SMTP id ad15mr4252784pac.27.1399555427722; Thu, 08 May 2014 06:23:47 -0700 (PDT) Received: from localhost ([122.166.139.231]) by mx.google.com with ESMTPSA id ga1sm2052914pbb.82.2014.05.08.06.23.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 06:23:47 -0700 (PDT) From: arunks.linux@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: ARM: Disable preemption along with interrupts during shutdown Date: Thu, 8 May 2014 18:53:31 +0530 Message-Id: <1399555411-15330-1-git-send-email-arunks.linux@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140508_062410_108171_096C0AC0 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) Cc: rmk+kernel@arm.linux.org.uk, Arun KS , Arun KS 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 'irqs disabled' is funtamentally unsafe way of disabling preemption. Any spin_unlock() decreasing the preemption count to 0 might trigger a reschedule. A simple printk() might trigger a reschedule. To be on safe side disable preemption as well using preempt_disable() Signed-off-by: Arun KS --- arch/arm/kernel/process.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 81ef686..9ecb7b5 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -193,6 +193,7 @@ void machine_shutdown(void) void machine_halt(void) { local_irq_disable(); + preempt_disable(); smp_send_stop(); local_irq_disable(); @@ -208,6 +209,7 @@ void machine_halt(void) void machine_power_off(void) { local_irq_disable(); + preempt_disable(); smp_send_stop(); if (pm_power_off) @@ -228,6 +230,7 @@ void machine_power_off(void) void machine_restart(char *cmd) { local_irq_disable(); + preempt_disable(); smp_send_stop(); arm_pm_restart(reboot_mode, cmd);