Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1316508ybt; Thu, 25 Jun 2020 03:10:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3YBHbcspkm0kuY9XNTEwjdyE9xph+9GiioTj/tJLJZXry6JcpUC8o/qy7eeV0roEXd6uV X-Received: by 2002:a50:fd07:: with SMTP id i7mr13297160eds.221.1593079836132; Thu, 25 Jun 2020 03:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593079836; cv=none; d=google.com; s=arc-20160816; b=Bkp+CTcC+O60zO3FFaj903dTCjtwHcRGfes3qtbHD9yZ5iQuatAt/KoaybSx0mEMp9 k8zbI49C0hYNeD3SV4i3kuujZpZMN2ppR4UPh1TJahE5NKYTGqjuWDhrj8ODFk5yjngz UGlIKr4VnqY10ibOyrJSO2rIIt9luE6EYN+So6ireJ9bRDNLHhA1o9w0lz4V1pb0Amvh DL4S7K/nfDkMRKDJqSD8IDqJsFAvjGX+7INU9VOOLrRNdYhIIIcQ1UXr14CXhb+1z4In nChRSyGCNHELKO47DQWLcAcqAQB9ok4D9BcPllDCx/C3HQu/z4s9CmdfvinHJhAgqWJB cKpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7w+PW5Q+NZhGwE5LNPAmenmlllZIyyFilMbiOR1atUM=; b=dO2hKIXUL4jTImiocBN3WU3LhGQ9QkgUepKHBQWo/uA8LwhArq9My4I53x+I3AJqgO kaq4+zM4ALC8kK2Unu8tY4Sh7rdP1YlXSU0fn1nHeNr4S3TdDWTPfO/VMIZ5lmAlXzj9 jjfgKhNsFrQR1CVba97g7Y0g6/rC0o+/bJPR2V6Ojyml2Vy9GO5iplzHKxm/rUjwZSm3 kidTtQ0OdKKLsEhFOTgf8a+k4Qb1MyaR2pqKwBz8e0fvE+5tocKULDXMByMqI6HRNI9j RynnlsIxhsPAnYW6gSZl5s6awMSqIOsRVFAG/cPcOtLnmgS/F3YSwK6xtvm3QL3wmJxI TGog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si14035822edw.365.2020.06.25.03.10.12; Thu, 25 Jun 2020 03:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390828AbgFYKAn (ORCPT + 99 others); Thu, 25 Jun 2020 06:00:43 -0400 Received: from goliath.siemens.de ([192.35.17.28]:35223 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390356AbgFYKAn (ORCPT ); Thu, 25 Jun 2020 06:00:43 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 05PA0Jeu009001 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 12:00:20 +0200 Received: from [167.87.244.238] ([167.87.244.238]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 05PA0IvT000636; Thu, 25 Jun 2020 12:00:18 +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> <289c6104-a885-d3c1-c670-a081ebaaf782@siemens.com> From: Jan Kiszka Message-ID: <2cf3df87-5f0b-f8ff-a977-21625badb2c5@siemens.com> Date: Thu, 25 Jun 2020 12:00:18 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.06.20 10:32, Tero Kristo wrote: > On 24/06/2020 18:24, Jan Kiszka wrote: >> 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? > > Yes, we assume 50%. I think based on the hw design, 50% is the only sane > value to be used, otherwise you just shrink the open window too much and > for no apparent reason. Fine with me, but should we check that assumption when adopting the watchdog? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux