From patchwork Sat Sep 29 00:48:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Wu X-Patchwork-Id: 1527881 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 AB99C3FE80 for ; Sat, 29 Sep 2012 01:02:51 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1THlQ3-0002i9-Dw; Sat, 29 Sep 2012 01:00:35 +0000 Received: from na3sys009aog137.obsmtp.com ([74.125.149.18]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1THlQ0-0002hv-Eu for linux-arm-kernel@lists.infradead.org; Sat, 29 Sep 2012 01:00:33 +0000 Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob137.postini.com ([74.125.148.12]) with SMTP ID DSNKUGZII7PgtFB0BCaOywB0u1Ilh4YDUQKW@postini.com; Fri, 28 Sep 2012 18:00: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 17:48:04 -0700 Received: from localhost (unknown [10.38.34.220]) by maili.marvell.com (Postfix) with ESMTP id B16764E513; Fri, 28 Sep 2012 17:48:04 -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: Sat, 29 Sep 2012 08:48:07 +0800 Message-Id: <1348879687-18887-1-git-send-email-fwu@marvell.com> X-Mailer: git-send-email 1.7.0.4 X-OriginalArrivalTime: 29 Sep 2012 00:48:04.0869 (UTC) FILETIME=[15DB9350:01CD9DDC] 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.18 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 --- 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);