From patchwork Tue Nov 17 09:20:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Siyuan X-Patchwork-Id: 4143 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id 7DD851C816D for ; Tue, 17 Nov 2026 10:21:08 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=163.com; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-27767-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-27767-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id AD923246E2 for ; Tue, 17 Nov 2026 09:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1794907261; b=J2GKkAuwXykDQwOf+VmtBm39hEixDDvM3rzJGPAx0ydQaK0mrmRjv/UXsipGHa095tdG 6YTLIZbprLvMHbR5x3Gz0CfSLDWvDgyKnJf9KIJagTE0tjTdfDe6Lbnq/OkSpDNju06gx f0l4RG8u9aVkXh8VR7wktEIYBxkrIhXfYzOUCe8u6QkFnAOxZoZ4HsJ7kLlLZ8/xj9/0I NkJ5iUQe10a13gKxeYu+/3fXJ6oDaVOtuuJeIwGoB7uXyurSiZlZwMs2Enzx0tZVTG6Xs Lm50EoCFEMMAJ9p5rhGfsvZTamBp1hqBRT73GPVVfg2JRWtKdUYh6QE1zLqGghGOOCA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794907261; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=JnmMVbIw83ezki5KT6mW7oV1wFkBAGupagQ9VIbFe4Y=; b=QI0dgThOJ7J4C8gA6bFOdsurheJn9WvHz/+5teWS5VOyVdWCnjDcZ7GSEbC/M9mJI0Ht uKLpl0xriIJ/EbXktlJOTG9mYnG662NmZwesdFnHFwvEcrTaYHcyTAgDdgbo1X4WepXIJ AvvE71900GO+8LhCZ0c2ySSUx847WmwTvfoU0QhxQpa/s0gUIYIiYi01DZ/0OzkmjUONg 7yErgUJSjpOGHnKeYRMtmKS1HnJLcDGfug382J/eOI0nODM7FPVCZWqcS3RASGeMdaz/c pODBBAcH4vI7uj1vJ6ai3vxP5OuQojOVtLSlohEicZSiU1VDgcxYf4vAnR3aB4DwpcQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=QR5YYnp4; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=fail smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70179606A335; Tue, 17 Nov 2026 09:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=QR5YYnp4 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794907261; b=ye2Zip7Bfi/saxR2HrKAJCmJxLQHMrbvbjw90jQ4rQCprhukV22XAJP9wlUYQCdpoEaY gQQ/2//r9Ie0Zv92cOHx2Eae3S6YEGLvepaiXuNnnrQ2hU0ibJii8eXkwbnaORx+g+Alh i1VvL/q6SBZUY0QLqQR4DQRxEGqs5cnD0E8UZJwP2lxfYuG3VDjaFWkiVB4ug+fV0Nt0b koSif52/4nNmd7AaaMJic9BK2Dt3CA6ETDYJrNgMmFaO3vQ5wuEHN9kevLXWBG/02tgYu HDXOfbPrlWmUdVkAyp+izv/R2Jxezv7Q1jM1bHQsVu2kYyxOlkTlSjq+CTHQJCrywyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794907261; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=JnmMVbIw83ezki5KT6mW7oV1wFkBAGupagQ9VIbFe4Y=; b=SvDKSCnwfbTKxMpxop5CZpc+xN1v9Ovyskqxj2Wd7zkMSicIMXQoJjvP6haN+KRS8Oz0 +AMoLdM4bjgO11ioaqAx2qINIZVdEjL93Qd6tS2zbp7jOKuoS2Qy4v8iuWwhVB+CCZ/gd 19KFuJJHHaUx08rIzOb3KMC2RKgeI7tRH7K66Fj0x5ySOK3C/H68TlXhT5SkpNy+cXRu9 D+QUCmyCEp9KpYlXOKe+lUK02O/TGE1S5QZe+3goOffjwC/JYm4Bh+Q+/NJEa/TicwT5S WUmowHKg/4auCzhWHmKcKMAgrgh7W5ZgnlohGbIowbfCkEdw4px2G8ZhGsvtdNT66Vw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=QR5YYnp4; arc=none smtp.remote-ip=117.135.210.2 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55041606A337 for ; Tue, 17 Nov 2026 09:20:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 55041606A337 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Jn mMVbIw83ezki5KT6mW7oV1wFkBAGupagQ9VIbFe4Y=; b=QR5YYnp4TeJxrlToAy ZbcwPUfpR2BPI1UsWO121vDgVUCcMvXmPHpxwRlru4KIAdEAVmgx2I0K+RcMF88T gU6SS5Hl+yAVuN7bZIUM2HuQCZCJRP8LLPjwTC69LpqLGKSlt4EAekQl6Ev2b24s ryGBc4joDFXey0/dQGyCUW2hI= Received: from SYPC (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wD3_3ZvHPxqa8ngIA--.50000S2; Tue, 17 Nov 2026 17:20:48 +0800 (CST) From: Yang Siyuan To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] watchdog: sunxi_wdt: stop the watchdog across system suspend Date: Tue, 17 Nov 2026 17:20:36 +0800 Message-ID: <20261117092036.12192-1-hsyysy@163.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-CM-TRANSID: _____wD3_3ZvHPxqa8ngIA--.50000S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr1ruryrGFyUZF4Dtr43Jrb_yoW5AFWUpF 4Yya4FkrWjqr4avr43Aw1DAF1rG34vgrW7AryxG34fA3Z8Gr1rGF18tryjy3ZxGFyrGF1r GF1jq3yxGayj9a7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jI_M3UUUUU= X-CM-SenderInfo: 5kv152r16rljoofrz/xtbC7RD8MWr8HHBv5QAA3A X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX The H616 watchdog has a maximum timeout of 16 seconds. systemd keeps /dev/watchdog0 open with RuntimeWatchdogSec=16s, but during system suspend all userspace is frozen and the watchdog core only cancels its ping worker; it does not stop the hardware. A suspend longer than the timeout therefore resets the board before it can resume. Add system sleep PM ops to stop the watchdog before suspend and restart it after resume if it was running. The driver did not store its private data in the platform device, so add platform_set_drvdata() for the PM callbacks. Tested on an Anbernic RG35XX-SP: a 30-second s2idle suspend resumes without the 16-second watchdog reset, and /dev/watchdog0 keeps working afterwards. Signed-off-by: Yang Siyuan --- drivers/watchdog/sunxi_wdt.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3 diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index a6500eb..23b50cb 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -55,6 +55,7 @@ struct sunxi_wdt_dev { struct watchdog_device wdt_dev; void __iomem *wdt_base; const struct sunxi_wdt_reg *wdt_regs; + bool running_at_suspend; }; /* @@ -225,6 +226,36 @@ static int sunxi_wdt_start(struct watchdog_device *wdt_dev) return 0; } +/* + * The hardware watchdog has a maximum timeout of 16 seconds. A system + * suspend easily lasts longer than that, and the watchdog core only cancels + * its ping worker during suspend; it does not stop the timer. Stop the + * watchdog explicitly while suspended and re-arm it on resume. + */ +static int sunxi_wdt_suspend(struct device *dev) +{ + struct sunxi_wdt_dev *sunxi_wdt = dev_get_drvdata(dev); + + sunxi_wdt->running_at_suspend = sunxi_wdt_is_running(&sunxi_wdt->wdt_dev); + sunxi_wdt_stop(&sunxi_wdt->wdt_dev); + + return 0; +} + +static int sunxi_wdt_resume(struct device *dev) +{ + struct sunxi_wdt_dev *sunxi_wdt = dev_get_drvdata(dev); + + if (sunxi_wdt->running_at_suspend) + sunxi_wdt_start(&sunxi_wdt->wdt_dev); + + return 0; +} + +static const struct dev_pm_ops sunxi_wdt_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(sunxi_wdt_suspend, sunxi_wdt_resume) +}; + static const struct watchdog_info sunxi_wdt_info = { .identity = DRV_NAME, .options = WDIOF_SETTIMEOUT | @@ -307,6 +338,8 @@ static int sunxi_wdt_probe(struct platform_device *pdev) if (IS_ERR(sunxi_wdt->wdt_base)) return PTR_ERR(sunxi_wdt->wdt_base); + platform_set_drvdata(pdev, sunxi_wdt); + sunxi_wdt->wdt_dev.info = &sunxi_wdt_info; sunxi_wdt->wdt_dev.ops = &sunxi_wdt_ops; sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; @@ -348,6 +381,7 @@ static struct platform_driver sunxi_wdt_driver = { .driver = { .name = DRV_NAME, .of_match_table = sunxi_wdt_dt_ids, + .pm = &sunxi_wdt_pm_ops, }, };