From patchwork Fri Jul 15 12:04:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 978032 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6FC5PSP001915 for ; Fri, 15 Jul 2011 12:05:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751173Ab1GOMFb (ORCPT ); Fri, 15 Jul 2011 08:05:31 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:55831 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103Ab1GOMFa (ORCPT ); Fri, 15 Jul 2011 08:05:30 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p6FC5RfT024214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 15 Jul 2011 07:05:27 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep34.itg.ti.com (8.13.7/8.13.8) with ESMTP id p6FC5RPd000739; Fri, 15 Jul 2011 07:05:27 -0500 (CDT) Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6FC5MU1001175; Fri, 15 Jul 2011 07:05:26 -0500 (CDT) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 8.3.106.1; Fri, 15 Jul 2011 17:35:23 +0530 Received: from localhost.localdomain ([172.24.190.145]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6FC51Zf017050; Fri, 15 Jul 2011 17:35:20 +0530 (IST) From: Tarun Kanti DebBarma To: CC: , , , , Tarun Kanti DebBarma Subject: [PATCH v14 REPOST 08/12] OMAP: dmtimer: add timeout to low-level routines Date: Fri, 15 Jul 2011 17:34:57 +0530 Message-ID: <1310731501-13078-9-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1310731501-13078-1-git-send-email-tarun.kanti@ti.com> References: <1310731501-13078-1-git-send-email-tarun.kanti@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Jul 2011 12:05:33 +0000 (UTC) The low-level read and write access routines wait on write-pending register in posted mode to make sure that previous write is complete on respective registers. This waiting is done in an infinite while loop. Now it is being modified to use timeout instead. Signed-off-by: Tarun Kanti DebBarma Reviewed-by: Varadarajan, Charulatha Acked-by: Cousson, Benoit Reviewed-by: Santosh Shilimkar --- arch/arm/plat-omap/include/plat/dmtimer.h | 34 ++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 10 deletions(-) diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h index 53d5da6..6e34094 100644 --- a/arch/arm/plat-omap/include/plat/dmtimer.h +++ b/arch/arm/plat-omap/include/plat/dmtimer.h @@ -36,6 +36,8 @@ #include #include +#include + #ifndef __ASM_ARCH_DMTIMER_H #define __ASM_ARCH_DMTIMER_H @@ -230,6 +232,8 @@ int omap_dm_timers_active(void); #define OMAP_TIMER_TICK_INT_MASK_COUNT_REG \ (_OMAP_TIMER_TICK_INT_MASK_COUNT_OFFSET | (WP_TOWR << WPSHIFT)) +#define MAX_WRITE_PEND_WAIT 10000 /* 10ms timeout delay */ + struct omap_dm_timer { unsigned long phys_base; int id; @@ -251,11 +255,16 @@ void omap_dm_timer_prepare(struct omap_dm_timer *timer); static inline u32 __omap_dm_timer_read(void __iomem *base, u32 reg, int posted, u8 func_offset) { - if (posted) - while (__raw_readl(base + - ((OMAP_TIMER_WRITE_PEND_REG + func_offset) & 0xff)) - & (reg >> WPSHIFT)) - cpu_relax(); + int i = 0; + + if (posted) { + omap_test_timeout(!(__raw_readl(base + + ((OMAP_TIMER_WRITE_PEND_REG + func_offset) & 0xff)) & + (reg >> WPSHIFT)), MAX_WRITE_PEND_WAIT, i); + + if (WARN_ON_ONCE(i == MAX_WRITE_PEND_WAIT)) + pr_err("read timeout.\n"); + } return __raw_readl(base + (reg & 0xff)); } @@ -263,11 +272,16 @@ static inline u32 __omap_dm_timer_read(void __iomem *base, u32 reg, static inline void __omap_dm_timer_write(void __iomem *base, u32 reg, u32 val, int posted, u8 func_offset) { - if (posted) - while (__raw_readl(base + - ((OMAP_TIMER_WRITE_PEND_REG + func_offset) & 0xff)) - & (reg >> WPSHIFT)) - cpu_relax(); + int i = 0; + + if (posted) { + omap_test_timeout(!(__raw_readl(base + + ((OMAP_TIMER_WRITE_PEND_REG + func_offset) & 0xff)) & + (reg >> WPSHIFT)), MAX_WRITE_PEND_WAIT, i); + + if (WARN_ON(i == MAX_WRITE_PEND_WAIT)) + pr_err("write timeout.\n"); + } __raw_writel(val, base + (reg & 0xff)); }