From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1B3EC433DF for ; Wed, 24 Jun 2020 15:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8A1420723 for ; Wed, 24 Jun 2020 15:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404407AbgFXPYa (ORCPT ); Wed, 24 Jun 2020 11:24:30 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:39144 "EHLO lizzard.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404017AbgFXPY3 (ORCPT ); Wed, 24 Jun 2020 11:24:29 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 05OFO7aH004305 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jun 2020 17:24:07 +0200 Received: from [167.87.59.49] ([167.87.59.49]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 05OFO5fK027922; Wed, 24 Jun 2020 17:24:06 +0200 Subject: Re: [PATCH 2/2] watchdog: rti: tweak min_hw_heartbeat_ms to match initial allowed window To: Tero Kristo , wim@linux-watchdog.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org References: <20200624114534.1362-1-t-kristo@ti.com> <20200624114534.1362-3-t-kristo@ti.com> From: Jan Kiszka Message-ID: <289c6104-a885-d3c1-c670-a081ebaaf782@siemens.com> Date: Wed, 24 Jun 2020 17:24:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200624114534.1362-3-t-kristo@ti.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24.06.20 13:45, Tero Kristo wrote: > If the RTI watchdog has been started by someone (like bootloader) when > the driver probes, we must adjust the initial ping timeout to match the > currently running watchdog window to avoid generating watchdog reset. > > Signed-off-by: Tero Kristo > --- > drivers/watchdog/rti_wdt.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c > index d456dd72d99a..02ea2b2435f5 100644 > --- a/drivers/watchdog/rti_wdt.c > +++ b/drivers/watchdog/rti_wdt.c > @@ -55,11 +55,13 @@ static int heartbeat; > * @base - base io address of WD device > * @freq - source clock frequency of WDT > * @wdd - hold watchdog device as is in WDT core > + * @min_hw_heartbeat_save - save of the min hw heartbeat value > */ > struct rti_wdt_device { > void __iomem *base; > unsigned long freq; > struct watchdog_device wdd; > + unsigned int min_hw_heartbeat_save; > }; > > static int rti_wdt_start(struct watchdog_device *wdd) > @@ -107,6 +109,11 @@ static int rti_wdt_ping(struct watchdog_device *wdd) > /* put watchdog in active state */ > writel_relaxed(WDKEY_SEQ1, wdt->base + RTIWDKEY); > > + if (wdt->min_hw_heartbeat_save) { > + wdd->min_hw_heartbeat_ms = wdt->min_hw_heartbeat_save; > + wdt->min_hw_heartbeat_save = 0; > + } > + > return 0; > } > > @@ -201,6 +208,24 @@ static int rti_wdt_probe(struct platform_device *pdev) > goto err_iomap; > } > > + if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) { > + u32 time_left; > + u32 heartbeat; > + > + set_bit(WDOG_HW_RUNNING, &wdd->status); > + time_left = rti_wdt_get_timeleft(wdd); > + heartbeat = readl(wdt->base + RTIDWDPRLD); > + heartbeat <<= WDT_PRELOAD_SHIFT; > + heartbeat /= wdt->freq; > + if (time_left < heartbeat / 2) > + wdd->min_hw_heartbeat_ms = 0; > + else > + wdd->min_hw_heartbeat_ms = > + (time_left - heartbeat / 2 + 1) * 1000; > + > + wdt->min_hw_heartbeat_save = 11 * heartbeat * 1000 / 20; > + } > + > ret = watchdog_register_device(wdd); > if (ret) { > dev_err(dev, "cannot register watchdog device\n"); > This assumes that the bootloader also programmed a 50% window, right? The pending U-Boot patch will do that, but what if that may chance or someone uses a different setup? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux