From patchwork Thu Jul 7 14:06:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkuzmichev@mvista.com X-Patchwork-Id: 952932 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p67E9D4E015816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 14:09:39 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QepGH-0004nF-Dm; Thu, 07 Jul 2011 14:09:01 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QepGH-0006Ck-2B; Thu, 07 Jul 2011 14:09:01 +0000 Received: from mail-fx0-f43.google.com ([209.85.161.43]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QepGD-0006CS-JC for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 14:08:58 +0000 Received: by fxg17 with SMTP id 17so1014641fxg.16 for ; Thu, 07 Jul 2011 07:08:50 -0700 (PDT) Received: by 10.223.36.89 with SMTP id s25mr1335977fad.9.1310047729895; Thu, 07 Jul 2011 07:08:49 -0700 (PDT) Received: from localhost.localdomain (mail.dev.rtsoft.ru [213.79.90.226]) by mx.google.com with ESMTPS id y21sm42706fad.39.2011.07.07.07.08.47 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jul 2011 07:08:49 -0700 (PDT) From: Vitaly Kuzmichev To: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Russell King , Arnd Bergmann , Wim Van Sebroeck , Marc Zyngier , Colin Cross Subject: [PATCH V4 2/4] ARM: smp_twd: mpcore_wdt: Fix watchdog counter loading Date: Thu, 7 Jul 2011 18:06:19 +0400 Message-Id: <1310047579-4694-1-git-send-email-vkuzmichev@mvista.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1310041339-2348-1-git-send-email-vkuzmichev@mvista.com> References: <1310041339-2348-1-git-send-email-vkuzmichev@mvista.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_100857_891913_F2741C51 X-CRM114-Status: GOOD ( 13.86 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.161.43 listed in list.dnswl.org] Cc: Valentine Barshak , linux-kernel@vger.kernel.org, Vitaly Kuzmichev X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 07 Jul 2011 14:09:39 +0000 (UTC) Although the commit "98af057092f8f0dabe63c5df08adc2bbfbddb1d2 ARM: 6126/1: ARM mpcore_wdt: fix build failure and other fixes" resolved long standing mpcore_wdt driver build problems, it introduced an error in the relationship between the MPcore watchdog timer clock rate and mpcore_margin, "MPcore timer margin in seconds", such that watchdog timeouts are now arbitrary rather than the number of seconds specified by mpcore_margin. This change restores mpcore_wdt_keepalive() to its equivalent implementation prior to commit 98af057 such that watchdog timeouts now occur as specified by mpcore_margin. The variable 'mpcore_timer_rate' which caused that build failure was replaced by 'twd_timer_rate'. Adding exported function to obtain 'twd_timer_rate' value in mpcore_wdt driver. MPCORE_WATCHDOG needed to build 'mpcore_wdt' already depends on HAVE_ARM_TWD needed to build 'smp_twd', so from the point of view of 'mpcore_wdt' driver the exported function will always exist. Signed-off-by: Valentine Barshak Signed-off-by: Vitaly Kuzmichev --- Forgot to change EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL, sorry Other patches are unchanged. arch/arm/include/asm/smp_twd.h | 1 + arch/arm/kernel/smp_twd.c | 7 +++++++ drivers/watchdog/mpcore_wdt.c | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h index fed9981..38130b1 100644 --- a/arch/arm/include/asm/smp_twd.h +++ b/arch/arm/include/asm/smp_twd.h @@ -24,5 +24,6 @@ extern void __iomem *twd_base; int twd_timer_ack(void); void twd_timer_setup(struct clock_event_device *); +unsigned long twd_timer_get_rate(void); #endif diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index 2c277d4..dd64fae 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -142,3 +142,10 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk) clockevents_register_device(clk); } + +/* Needed by mpcore_wdt */ +unsigned long twd_timer_get_rate(void) +{ + return twd_timer_rate; +} +EXPORT_SYMBOL_GPL(twd_timer_get_rate); diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c index 2b4af22..efde50b 100644 --- a/drivers/watchdog/mpcore_wdt.c +++ b/drivers/watchdog/mpcore_wdt.c @@ -99,9 +99,7 @@ static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt) spin_lock(&wdt_lock); /* Assume prescale is set to 256 */ - count = __raw_readl(wdt->base + TWD_WDOG_COUNTER); - count = (0xFFFFFFFFU - count) * (HZ / 5); - count = (count / 256) * mpcore_margin; + count = (twd_timer_get_rate() / 256) * mpcore_margin; /* Reload the counter */ writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);