All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Shimko <a.shimko.dev@gmail.com>
To: wim@linux-watchdog.org, linux@roeck-us.net,
	p.zabel@pengutronix.de, Sergey.Semin@baikalelectronics.ru,
	mika.westerberg@linux.intel.com, andi.shyti@kernel.org,
	iav@iav.lv
Cc: Artem Shimko <a.shimko.dev@gmail.com>,
	linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/3] watchdog: dw_wdt: fix reset line management
Date: Thu, 22 Oct 2026 16:43:48 +0300	[thread overview]
Message-ID: <20261022134354.534642-1-a.shimko.dev@gmail.com> (raw)
In-Reply-To: <y>

Hello,

This is v2 of the series fixing reset line management in the dw_wdt
driver. Compared to v1, the series is reduced from 5 patches to 3:
the manual reset_control_deassert()/reset_control_assert() handling
is replaced by the device-managed _deasserted variant from the start.

Patch 1 replaces devm_reset_control_get_optional_shared() with
devm_reset_control_get_optional_shared_deasserted(), so the reset line
is deasserted on acquisition, before the first register access in
dw_wdt_update_mode(), and is asserted again automatically by devres
when the device is removed. This removes the out_assert_rst label and
the explicit reset_control_assert() calls in probe error paths and in
dw_wdt_drv_remove(), and uses dev_err_probe() for the acquisition error.

Patch 2 adds reset line management during system suspend/resume:
the reset is asserted before clocks are disabled in suspend, and
deasserted after clocks are re-enabled and before the register state
is restored in resume. Error handling is added for the reset operations
in resume, with a cleanup path that disables the clocks in reverse
order of enabling.

Patch 3 cleans up the error paths in dw_wdt_resume().

Thank you.

Testing:

$ ls /dev/watchdog*
/dev/watchdog   /dev/watchdog1  /dev/watchdog3
/dev/watchdog0  /dev/watchdog2

$ ls /sys/class/watchdog/
watchdog0  watchdog1  watchdog2  watchdog3

$ chmod +x watchdog-test
$ ./watchdog-test -f /dev/watchdog0 -i -s
watchdog_info:
 identity:              Synopsys DesignWare Watchdog
 firmware_version:      0
Support/Status: Set timeout (in seconds)
Support/Status: Supports magic close char
Support/Status: Pretimeout (in seconds), get/set
Support/Status: Keep alive ping reply
Support/Status: Keep alive ping reply

$ echo mem > /sys/power/state
...
...
[ 1560.147058] PM: suspend exit
[ 1560.371470] usb 1-1: new high-speed USB device number 3 using xhci-hcd
[ 1561.031825] cdc_ncm 1-1:2.0: MAC-Address: a4:2a:95:e8:fc:e4
[ 1561.037736] cdc_ncm 1-1:2.0: setting rx_max = 16384
[ 1561.054408] cdc_ncm 1-1:2.0: setting tx_max = 16384
[ 1561.084713] cdc_ncm 1-1:2.0 eth0: register 'cdc_ncm' at usb-xhci-hcd.2.auto-1, CDC NCM (NO ZLP), a4:2a:95:e8:fc:e4

$ ./watchdog-test -f /dev/watchdog0 -i -s
watchdog_info:
 identity:              Synopsys DesignWare Watchdog
 firmware_version:      0
Support/Status: Set timeout (in seconds)
Support/Status: Supports magic close char
Support/Status: Pretimeout (in seconds), get/set
Support/Status: Keep alive ping reply
Support/Status: Keep alive ping reply

$ ls /dev/watchdog*
/dev/watchdog   /dev/watchdog1  /dev/watchdog3
/dev/watchdog0  /dev/watchdog2

$ echo 1 > /dev/watchdog0
$ cat /sys/kernel/debug/1e012000.wdt/registers | grep ccvr
ccvr = 0x09a7baab
$ cat /sys/kernel/debug/1e012000.wdt/registers | grep ccvr
ccvr = 0x0599dce0
$ cat /sys/kernel/debug/1e012000.wdt/registers | grep ccvr
ccvr = 0x01926467
$ [  110.392536] watchdog0: pretimeout event

--
Best regards,
Artem

ChangeLog:
  v1:
    * https://lore.kernel.org/all/20260320135624.223863-1-a.shimko.dev@gmail.com/T/#t
  v2:
    * Reduced from 5 patches to 3: manual reset handling is replaced by
      the devm _deasserted variant from the start, so the intermediate
      states that could leak the deasserted reset line are gone and every
      commit is self-contained.

Artem Shimko (3):
  watchdog: dw_wdt: use
    devm_reset_control_get_optional_shared_deasserted
  watchdog: dw_wdt: manage reset line during system suspend/resume
  watchdog: dw_wdt: clean up error paths in resume function

 drivers/watchdog/dw_wdt.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

-- 
2.43.0


             reply	other threads:[~2026-10-22 13:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 13:43 Artem Shimko [this message]
2026-10-22 13:43 ` [PATCH v2 1/3] watchdog: dw_wdt: use devm_reset_control_get_optional_shared_deasserted Artem Shimko
2026-10-23  3:05   ` Tzung-Bi Shih
     [not found]     ` <CAOPX745qshBW4NPh8cNt9kGUEtp6C1Ds8HVTjFjL2=q1azrFsw@mail.gmail.com>
2026-10-24 13:19       ` Tzung-Bi Shih
2026-10-22 13:43 ` [PATCH v2 2/3] watchdog: dw_wdt: manage reset line during system suspend/resume Artem Shimko
2026-10-23  3:05   ` Tzung-Bi Shih
2026-10-22 13:43 ` [PATCH v2 3/3] watchdog: dw_wdt: clean up error paths in resume function Artem Shimko
2026-10-23  3:06   ` Tzung-Bi Shih
2026-10-22 21:15 ` [PATCH v2 0/3] watchdog: dw_wdt: fix reset line management Igor Velkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261022134354.534642-1-a.shimko.dev@gmail.com \
    --to=a.shimko.dev@gmail.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=andi.shyti@kernel.org \
    --cc=iav@iav.lv \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mika.westerberg@linux.intel.com \
    --cc=p.zabel@pengutronix.de \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.