From patchwork Sun Nov 12 17:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13453364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9505EC4332F for ; Sun, 12 Nov 2023 17:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wACHi1Ma4VbNHmsUnF2HGZ4PyOODc/V17KCAF6T/kgs=; b=dp/IWcZkZ6IzFJ HUYGJKpgQCQm+VBetsBcBTEIEOfAwJYhKtmv/waG/acdtMSoq+eJCsIBovuezTBz0xk2aMp6ECH28 ombTavKUIDLeJjFyIIUK0z5VFzDIcuaJkmrs7JxNEoxmEOJbBvHJGKbuTrjZBr4p24GZeCJdMbMmr 7OcjtEWSfEaXFLzjtrpBGc8zbjUsQukR+iMsccXnaJCPIYuQ+nMAEVWxQNiooReQUv62btg4E6IIM D/FWkJMp9hA84iAAonoAJ8nYO/2coSsFMhqOEDFTpkIxwURzNVX7shMl0XsyNrJ/rlJZYAaFgjNva Ug1sfixW+gdqm4IIozgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2EL8-00CcoN-1a; Sun, 12 Nov 2023 17:33:42 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2EL4-00Ccnv-38 for linux-arm-kernel@lists.infradead.org; Sun, 12 Nov 2023 17:33:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1699810395; x=1700415195; i=wahrenst@gmx.net; bh=mMXqRGkNbsNAPyh+mZIVYkEDyUy+h/05R/ZCmUhYpaQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=Koglhbcf1VusTISTtF0qojVN/3dYJqXZPfxSY38lSqs2Fp7olgEXCgR+NQQb18Xo 4rnvHL8UQZTIgj4/sXo4EcTp4kxdHBqmx9NxFlDEVS8aZavZowHt3gKXpz1615meu eT6bHAQyhZPhdbhQdsGJZG/FvFRf4I2EfCRchTYlMyWGFCJ+t/h+tSWnzLkex0Qni HzXoQg6Qlv7Tq2I4K91uCZ92v8HcLd/TzVgSEWtHND5A30M1L39JJpTrpYKs+BG2o YF/qy8T6mI0y2aTO23lhTkoyGf/BuM8j9Va4uLEHea3FRC4phXR/Ow+LNEh1WPOi9 bx2zyR0/2LyGbVH81g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MAONd-1rDX8q0Dvf-00BvId; Sun, 12 Nov 2023 18:33:15 +0100 From: Stefan Wahren To: Wim Van Sebroeck , Guenter Roeck Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, Phil Elwell , Ray Jui , Scott Branden , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH] watchdog: bcm2835_wdt: Fix WDIOC_SETTIMEOUT handling Date: Sun, 12 Nov 2023 18:32:51 +0100 Message-Id: <20231112173251.4827-1-wahrenst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wG 6A/hPe3W9BxGTKuDFlevpYkxuzkwNN4jkWEgpT/i1EOw8LV0GqJxz8LTKFFbrcw37q7u2Z7xh YFre4uQMRKl0uGAtA5u/hAWNnm59f0KenyYn8EN1+sHjqQxBOcQTnZv1hqVC9yBBoRwC2diUT Frz10jbC6A57yieQPehwT1VnIxE3aXxDKspyBlpGSoUgMNbatyv9DwcU9HECy6+7NW1JvrEUY AxQ/5g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231112_093339_486431_B9CF351C X-CRM114-Status: GOOD ( 11.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Users report about the unexpected behavior for setting timeouts above 15 sec on Raspberry Pi. According to watchdog-api.rst the ioctl WDIOC_SETTIMEOUT shouldn't fail because of hardware limitations. But looking at the code shows that max_timeout based on the register value PM_WDOG_TIME_SET, which is the maximum. Since 664a39236e71 ("watchdog: Introduce hardware maximum heartbeat in watchdog core") the watchdog core is able to handle this problem. This fix has been tested with watchdog-test from selftests. Link: https://bugzilla.kernel.org/show_bug.cgi?id=217374 Fixes: 664a39236e71 ("watchdog: Introduce hardware maximum heartbeat in watchdog core") Signed-off-by: Stefan Wahren Reviewed-by: Guenter Roeck Reviewed-by: Florian Fainelli --- drivers/watchdog/bcm2835_wdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c index 7a855289ff5e..bb001c5d7f17 100644 --- a/drivers/watchdog/bcm2835_wdt.c +++ b/drivers/watchdog/bcm2835_wdt.c @@ -42,6 +42,7 @@ #define SECS_TO_WDOG_TICKS(x) ((x) << 16) #define WDOG_TICKS_TO_SECS(x) ((x) >> 16) +#define WDOG_TICKS_TO_MSECS(x) ((x) * 1000 >> 16) struct bcm2835_wdt { void __iomem *base; @@ -140,7 +141,7 @@ static struct watchdog_device bcm2835_wdt_wdd = { .info = &bcm2835_wdt_info, .ops = &bcm2835_wdt_ops, .min_timeout = 1, - .max_timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), + .max_hw_heartbeat_ms = WDOG_TICKS_TO_MSECS(PM_WDOG_TIME_SET), .timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), };