From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 74FF622A4DA; Wed, 4 Jun 2025 11:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749037788; cv=none; b=pbbhA2q5y/JiAl8qLiOXEPlt0qYBwJNubv4CtuKSQLsVvFnanGjSFRnw/IYvlml67+hFtOjldN5TQOExNTqjDEM8+57+2j88bN5ZuKHlQk51xJS22JbGZ6D0mU5HN7ldJAmHEpZjw2KoXeBxk1FYEmmjGHsdD/Eukvp/VApR5V4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749037788; c=relaxed/simple; bh=sYefenUvoFAGRhe6rQAUlxP2LlI1ut/lAWA9frHYOyU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=rtKF+qd+ekG3cHzarpKXo7w+Xz9lV7a+4XOIMqLghMCw559NfzjC1oz5KOYOrQINCmJ9C5z9RSe11FOnCsjYoZg3EY2PN5as4itLDRWjPT/uFQAS29sz7Dt8GwMs2pGTUl6+hUHwjmDHF0WzqRorunFeRN1wikLuWmCz5gUPhg0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMsiFJQ5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uMsiFJQ5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AD11C4CEEF; Wed, 4 Jun 2025 11:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749037788; bh=sYefenUvoFAGRhe6rQAUlxP2LlI1ut/lAWA9frHYOyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMsiFJQ5OBVIuSp+wlxfW60c/r8q5tmwFS1zSXiXsIHU5HvOgHqMB3IYyeMtHKhGS nBMnwlwDlVF1sQvV5yufXOQavZ4OCQab1N8T3bjsZjgVAGHVCsPx6XVNE+cTlt6Tlm SB7XIOzCoPdCOTEi/Gftbb+cMi6jwRih8S5djT+nUffLYTduMO65xg8CXGs5oEM6a4 xm28tnT1Q4PvEweRg1+mzVcvuuY/pr+47eshrfDs3dXbVZ/hBnfd/QsBA8dCS6X5sZ dD2rRua/YmheApnFMgjuULw4Vv0dOMyQp3n94uYPOooTLs2wPde9eTVchnxcMAmXIy WJbul0qolma4A== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Marcus Folkesson , Guenter Roeck , Wim Van Sebroeck , Sasha Levin , support.opensource@diasemi.com, linux-watchdog@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 2/8] watchdog: da9052_wdt: respect TWDMIN Date: Wed, 4 Jun 2025 07:49:37 -0400 Message-Id: <20250604114944.208828-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250604114944.208828-1-sashal@kernel.org> References: <20250604114944.208828-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Marcus Folkesson [ Upstream commit 325f510fcd9cda5a44bcb662b74ba4e3dabaca10 ] We have to wait at least the minimium time for the watchdog window (TWDMIN) before writings to the wdt register after the watchdog is activated. Otherwise the chip will assert TWD_ERROR and power down to reset mode. Signed-off-by: Marcus Folkesson Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20250326-da9052-fixes-v3-4-a38a560fef0e@gmail.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- Based on my analysis, here's my assessment: **YES** This commit should be backported to stable kernel trees. Here's my extensive analysis: ## Analysis of the Commit ### 1. **Bug Fix Nature** The commit fixes a critical hardware timing constraint issue. The DA9052 PMIC has a minimum watchdog window time (TWDMIN = 256ms) that must be respected. Writing to the watchdog register before this time elapses causes the chip to assert TWD_ERROR and power down to reset mode, which is a serious system failure. ### 2. **Code Changes Analysis** The commit makes a single, targeted change in `drivers/watchdog/da9052_wdt.c`: ```c da9052_wdt->timeout = DA9052_DEF_TIMEOUT; +da9052_wdt->min_hw_heartbeat_ms = DA9052_TWDMIN; da9052_wdt->info = &da9052_wdt_info; ``` This change adds `min_hw_heartbeat_ms = DA9052_TWDMIN` (256ms) to the watchdog device structure during probe. ### 3. **Technical Correctness** - **DA9052_TWDMIN is already defined** as 256 in the driver (line 25) - **The current code already implements manual timing protection** in `da9052_wdt_ping()` (lines 119-121) using jiffies tracking and `mdelay()` - **The watchdog core provides proper infrastructure** for `min_hw_heartbeat_ms` as seen in similar DA9062/DA9063 drivers and watchdog core code - **This replaces manual timing logic with standard core handling**, making it more reliable and consistent ### 4. **Risk Assessment - Very Low** - **Minimal code change**: Only adds one line setting a field - **No behavioral change**: The timing constraint was already enforced manually - **Uses existing infrastructure**: `min_hw_heartbeat_ms` is well-established in watchdog core - **Consistent with related drivers**: DA9062 and DA9063 drivers use the same pattern - **No architectural changes**: Just moves timing enforcement from driver to core ### 5. **User Impact - High** - **Prevents system resets**: Without this fix, rapid watchdog pings can cause unexpected system shutdowns - **Hardware protection**: Prevents TWD_ERROR assertion which leads to PMIC reset - **Critical for production systems**: Watchdog failures can cause data loss and system instability ### 6. **Stable Tree Criteria Compliance** - ✅ **Important bugfix**: Prevents system resets due to hardware timing violations - ✅ **Minimal risk**: Single line addition using existing infrastructure - ✅ **Small and contained**: Only affects DA9052 watchdog driver - ✅ **No new features**: Just improves existing timing protection - ✅ **Clear benefit**: Moves from manual to core-handled timing protection ### 7. **Comparison with Similar Commits** The provided similar commits (all marked "NO") were different in nature: - **Commits #1-3**: Added new functionality or made architectural changes to use core protection - **Commits #4-5**: Simple cleanup removing error messages - **This commit**: Fixes a critical hardware timing bug that can cause system resets This commit is fundamentally different - it fixes a real hardware constraint violation that can cause system failures, not just cleanup or new features. The commit perfectly fits stable tree criteria: it's a small, low-risk fix for an important hardware-related bug that can cause system instability. drivers/watchdog/da9052_wdt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c index 77039f2f0be54..bc0946233ced0 100644 --- a/drivers/watchdog/da9052_wdt.c +++ b/drivers/watchdog/da9052_wdt.c @@ -168,6 +168,7 @@ static int da9052_wdt_probe(struct platform_device *pdev) da9052_wdt = &driver_data->wdt; da9052_wdt->timeout = DA9052_DEF_TIMEOUT; + da9052_wdt->min_hw_heartbeat_ms = DA9052_TWDMIN; da9052_wdt->info = &da9052_wdt_info; da9052_wdt->ops = &da9052_wdt_ops; da9052_wdt->parent = dev; -- 2.39.5