From patchwork Fri Jul 17 22:44:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vikram pandita X-Patchwork-Id: 36135 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6HMlLB5009924 for ; Fri, 17 Jul 2009 22:47:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757950AbZGQWrT (ORCPT ); Fri, 17 Jul 2009 18:47:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757957AbZGQWrT (ORCPT ); Fri, 17 Jul 2009 18:47:19 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:44006 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757950AbZGQWrT (ORCPT ); Fri, 17 Jul 2009 18:47:19 -0400 Received: from dlep36.itg.ti.com ([157.170.170.91]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n6HMlDDj029908; Fri, 17 Jul 2009 17:47:18 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id n6HMlAxv004871; Fri, 17 Jul 2009 17:47:10 -0500 (CDT) Received: from vip-tid (lta0307903-128247075087.am.dhcp.ti.com [128.247.75.87]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id n6HMlA900775; Fri, 17 Jul 2009 17:47:10 -0500 (CDT) Received: from vip-tid (localhost.localdomain [127.0.0.1]) by vip-tid (Postfix) with ESMTP id AD6A129C9DE; Fri, 17 Jul 2009 17:44:55 -0500 (CDT) Received: (from vikram@localhost) by vip-tid (8.14.3/8.14.3/Submit) id n6HMitZt027180; Fri, 17 Jul 2009 17:44:55 -0500 X-Authentication-Warning: vip-tid: vikram set sender to vikram.pandita@ti.com using -f From: Vikram Pandita To: khilman@deeprootsystems.com, linux-omap@vger.kernel.org Cc: jon-hunter@ti.com, Vikram Pandita Subject: [PATCH] OMAP3: PM: Prevent hang in prcm_interrupt handler Date: Fri, 17 Jul 2009 17:44:47 -0500 Message-Id: <1247870687-27149-1-git-send-email-vikram.pandita@ti.com> X-Mailer: git-send-email 1.6.3.3.334.g916e1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org There are two scenarios where a race condition could result in a hang in the prcm_interrupt handler: 1) Waiting for PRM_IRQSTATUS_MPU register to clear. Bit 0 of the PRM_IRQSTATUS_MPU register indicates that a wake-up event is pending for the MPU. This bit can only be cleared if the all the wake-up events latched in the various PM_WKST_x registers have been cleared. If a wake-up event occurred during the processing of the prcm interrupt handler, after the corresponding PM_WKST_x register was checked but before the PRM_IRQSTATUS_MPU was cleared, then the CPU would be stuck forever waiting for bit 0 in PRM_IRQSTATUS_MPU to be cleared. 2) Waiting for the PM_WKST_x register to clear. Some power domains have more than one wake-up source. The PM_WKST_x registers indicate the source of a wake-up event and need to be cleared after a wake-up event occurs. When the PM_WKST_x registers are read and before they are cleared, it is possible that another wake-up event could occur causing another bit to be set in one of the PM_WKST_x registers. If this did occur after reading a PM_WKST_x register then the CPU would miss this event and get stuck forever in a loop waiting for that PM_WKST_x register to clear. This patch address the above race conditions that would result in a hang. Adapted from a version posted by Jon Hunter: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg13786.html Signed-off-by: Vikram Pandita cc: Hunter, Jon --- arch/arm/mach-omap2/pm34xx.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 4cbeff1..ce34ac1 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -200,6 +200,10 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id) u32 wkst, irqstatus_mpu; u32 fclk, iclk; +restart: + fclk = 0; + iclk = 0; + /* WKUP */ wkst = prm_read_mod_reg(WKUP_MOD, PM_WKST); if (wkst) { @@ -285,8 +289,11 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id) prm_write_mod_reg(irqstatus_mpu, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); - while (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET)) - cpu_relax(); + /* In case another wakep happend while in this handler, + * restart the clearing process + */ + if (prm_read_mod_reg(OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET)) + goto restart; return IRQ_HANDLED; }