From patchwork Fri Sep 28 10:22:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 1518431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 732FC3FC71 for ; Fri, 28 Sep 2012 10:31:47 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1THXpA-0006Xa-U2; Fri, 28 Sep 2012 10:29:37 +0000 Received: from na3sys009aog128.obsmtp.com ([74.125.149.141]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1THXp6-0006XM-LK for linux-arm-kernel@lists.infradead.org; Fri, 28 Sep 2012 10:29:33 +0000 Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob128.postini.com ([74.125.148.12]) with SMTP ID DSNKUGV8AKtkhEnjNebhF8hXTABbyqp9Kn4y@postini.com; Fri, 28 Sep 2012 03:29:32 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:22:55 -0700 Received: from localhost (unknown [10.38.34.220]) by maili.marvell.com (Postfix) with ESMTP id 355274E510; Fri, 28 Sep 2012 03:22:55 -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:22:54 +0800 Message-Id: <1348827774-17880-1-git-send-email-fwu@marvell.com> X-Mailer: git-send-email 1.7.0.4 X-OriginalArrivalTime: 28 Sep 2012 10:22:55.0042 (UTC) FILETIME=[39309220:01CD9D63] 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.141 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: 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 Acked-by: Nicolas Pitre --- 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..5bbd3be 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);