From patchwork Tue Nov 26 07:36:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "A. Sverdlin" X-Patchwork-Id: 13885528 Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75810194AE8 for ; Tue, 26 Nov 2024 07:36:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.136.64.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732606617; cv=none; b=OkryAT3Ejg46+/INjz4aXja5kZ8bW4rJxPOQNma+9XnYWBqNOkf7119USPETPJD91dzX7QNqdKYsxYaQh9s7VP0spDNiFYbsuQjis/+oMktCkeiyoZ8iErw5nv1/Mb27VzXcCWN/fmL0NbUodVUd9JUl+cJVaFuCKi4JDDGud2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732606617; c=relaxed/simple; bh=KNVO8J3gsl2DA/9ocoZ52F61ETHEzcquUh12mEvk7Kg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RPK1ngzvKBKnDXToU5WCdaxT75FaWYYIBHpamV7oQAHdYmVktciceOk5Z7dxIJJSzwpIuE0fRM0akvpAI36P/h9DR3DbVnOClsrCdF01idwEurqauOJl4edYNrSP8ZwyXAjkCx18/jlOrU6IdEvlyLAd59BGA8pKEaZUR0hUb4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com; dkim=pass (2048-bit key) header.d=siemens.com header.i=alexander.sverdlin@siemens.com header.b=B6Xv0/jo; arc=none smtp.client-ip=185.136.64.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=siemens.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rts-flowmailer.siemens.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=siemens.com header.i=alexander.sverdlin@siemens.com header.b="B6Xv0/jo" Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 20241126073649d9947aa62048498ce0 for ; Tue, 26 Nov 2024 08:36:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=alexander.sverdlin@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=EtDCUfr3LrwAsgpNBtOhELyiQg8r8ri1jLgAFEDt+8Q=; b=B6Xv0/joc4vKaDj3qjfUWawbR/grdTOp/swwVAkSlaffweDNQoNsCIVm1l/p6jQhiC5ndq qeqjJlXvQeosa3rXuFl1a3Myz0Ws+2rpJExvHojX3ys5aPCHDypb4TDDfg1DZBN+Jpv2BZQp uD3XXot5FnZ431Un5MJMglrpcQSJUaWRYmexBO0rj3OBmhjQZCPAP922ws8qiWyOfJII62QO D1kSRXpqP1bCdOG26oAhX5QH+bVryR5W/VoMM6SyT+jwmoYj5VOGs4175vkRrBxAIWcxIPYS bELVuMf9/f8Ql0agSbGXSN4JWTsB4ZpN2fOzAaV3Z0AC3h/0lkm0Vkzw==; From: "A. Sverdlin" To: linux-watchdog@vger.kernel.org Cc: Alexander Sverdlin , Wim Van Sebroeck , Guenter Roeck , Judith Mendez , Vignesh Raghavendra , Tero Kristo Subject: [PATCH] watchdog: rti: Fix off-by-one in heartbeat recovery Date: Tue, 26 Nov 2024 08:36:43 +0100 Message-ID: <20241126073646.126752-1-alexander.sverdlin@siemens.com> Precedence: bulk X-Mailing-List: linux-watchdog@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-456497:519-21489:flowmailer From: Alexander Sverdlin According to AM62x TRM WDT period is (RTIDWDPRLD + 1) * (2^13) / RTICLK1, Fix the heartbeat recovery. In practice this doesn't affect rounded heatbeat in seconds, but it does correct 4% of error in milliseconds, for, say, default 60s heartbeat. This affects last_ping calculation. Signed-off-by: Alexander Sverdlin Reviewed-by: Guenter Roeck --- drivers/watchdog/rti_wdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 563d842014dfb..0416e54b17edb 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -273,7 +273,8 @@ static int rti_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &wdd->status); time_left_ms = rti_wdt_get_timeleft_ms(wdd); - heartbeat_ms = readl(wdt->base + RTIDWDPRLD); + /* AM62x TRM: texp = (RTIDWDPRLD + 1) * (2^13) / RTICLK1 */ + heartbeat_ms = readl(wdt->base + RTIDWDPRLD) + 1; heartbeat_ms <<= WDT_PRELOAD_SHIFT; heartbeat_ms *= 1000; do_div(heartbeat_ms, wdt->freq);