From patchwork Fri Sep 28 10:59:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 1518671 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 EEBA0DF283 for ; Fri, 28 Sep 2012 11:08:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1THYOr-0002hG-Ky; Fri, 28 Sep 2012 11:06:29 +0000 Received: from na3sys009aog125.obsmtp.com ([74.125.149.153]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1THYOn-0002h2-FL for linux-arm-kernel@lists.infradead.org; Fri, 28 Sep 2012 11:06:26 +0000 Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob125.postini.com ([74.125.148.12]) with SMTP ID DSNKUGWEpQRhP+ImnawspmLPuixyKF2ldtJ8@postini.com; Fri, 28 Sep 2012 04:06:25 PDT Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 28 Sep 2012 03:59:16 -0700 Received: from localhost (unknown [10.38.34.220]) by maili.marvell.com (Postfix) with ESMTP id 19A474E510; Fri, 28 Sep 2012 03:59:17 -0700 (PDT) From: Fan Wu To: Russell King , Nicolas Pitre , Will Deacon , H Hartley Sweeten , Tony Lindgren Subject: [PATCH] ARM: Add BUG_ON when hlt counter is wrongly used Date: Fri, 28 Sep 2012 18:59:16 +0800 Message-Id: <1348829956-18189-1-git-send-email-fwu@marvell.com> X-Mailer: git-send-email 1.7.0.4 X-OriginalArrivalTime: 28 Sep 2012 10:59:16.0919 (UTC) FILETIME=[4DB09470:01CD9D68] 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 [74.125.149.153 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ning Jiang , fwu , YiLu Mao , Ning Jiang , 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 From: fwu 1. On ARM platform, "nohlt" can be used to prevent core from idle process, returning immediately. 2. There are two interfaces, exported for other modules, named "disable_hlt" and "enable_hlt" are used to enable/disable the cpuidle mechanism by increasing/decreasing "hlt_counter". Disable_hlt and enable_hlt are paired operation, when you first call disable_hlt and then enable_hlt, the semantics are right. 3. There is no obvious constraint to prevent user(driver/module) code to prevent the case that enable_hlt is ahead of disable_hlt, which is a fatal operation on kernel state change from user, and there is no any WARNING or notification if the case happens in current kernel code. This patch aims to report BUG when the case happens, just like what the kernel do when enable_irq is ahead of disable_irq. Signed-off-by: fwu Signed-off-by: YiLu Mao Signed-off-by: Ning Jiang Change-Id: Iddacf45aec012bb663e130801727b4eb3d11436b --- arch/arm/kernel/process.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 693b744..d3f2972 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -70,6 +70,7 @@ EXPORT_SYMBOL(disable_hlt); void enable_hlt(void) { hlt_counter--; + BUG_ON(hlt_counter < 0); } EXPORT_SYMBOL(enable_hlt);