From: Prajwal N <prajwal.n@oss.qualcomm.com>
To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, wim@linux-watchdog.org, linux@roeck-us.net,
radim.krcmar@oss.qualcomm.com, anup@brainfault.org,
anup.patel@oss.qualcomm.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org, prajwal.n.oss@gmail.com,
Prajwal N <prajwal.n@oss.qualcomm.com>
Subject: [RFC PATCH v4 0/2] Add RISC-V SBI watchdog driver
Date: Tue, 24 Nov 2026 18:45:40 +0530 [thread overview]
Message-ID: <20261124131542.613271-1-prajwal.n@oss.qualcomm.com> (raw)
This series adds a driver for RISC-V SBI watchdog extension.
The SBI watchdog extension exposes watchdog including start,
stop, pat, read and write attributes to the S-mode software.
The kernel driver uses the standard SBI calls to interact and
configure the attributes. The driver integrates with the
kernel watchdog framework (/dev/watchdog) to ease user-space
implementations.
The driver currently subscribes to the Message Signaled
Interrupts (MSI) for watchdog pretimeout events.
The series consists of following changes:
- Patch 1 adds the definition for SBI watchdog extension ID,
function IDs, and various attributes that are supported by
the extension
- Patch 2 implements the kernel driver that utilizes standard
SBI calls to interact and configure the attributes.
This is based on the OpenSBI watchdog extension implementation
patch series available at:
Link: https://lore.kernel.org/opensbi/20261002083040.2533097-1-prajwal.n@oss.qualcomm.com
Steps to test the SBI watchdog extension
1) Compile the kernel along with watchdog kselftest for RISC-V.
2) Compile OpenSBI patch series mentioned earlier to generate fw_dynamic.bin
3) Launch QEMU virt machine with IMSIC support enabled.
Note: The following command requires a rootfs.cpio packed in Image. It can
be modified to use rootfs.ext2
$ qemu-system-riscv64 -M virt,aia=aplic-imsic -m 2G -smp 4 -nographic \
-bios fw_dynamic.bin -kernel Image -append "root=/dev/vda rw console=ttyS0"
4) On kernel boot-up, the /dev/watchdog entry should be available and the
kselftest binary (watchdog-test) can be used to test the functionality.
Following are some sample test cases,
- Dumps all the supported options.
./watchdog-test -h
- Starts the watchdog, configures the timeout to 8s, ping interval to 2s,
and disables the pretimeout.
./watchdog-test -t 8 -p 2 -n 0
- Starts the watchdog, configures the timeout to 8s, ping interval to 9s,
and disables the pretimeout.
./watchdog-test -t 8 -p 9 -n 0
- Starts the watchdog, configures the timeout to 8s, ping interval to 2s,
and configures the pretimeout to 6s before the timeout.
./watchdog-test -t 8 -p 3 -n 6
Changes in v4:
- Address review comment in the commit message
- Improve the comments in code to address Sashiko reviews
Changes in v3:
- Address Sashiko review comments
- Select WATCHDOG_CORE in the RISCV_SBI_WATCHDOG config section
- Appropriately return from error conditions when using dev_err_probe()
Changes in v2:
- Address Sashiko review comments
- Fix silent overflow in sec_to_usec() by setting max_timeout to U32_MAX / USEC_PER_SEC
in probe, preventing timeouts greater than 4294 seconds from wrapping around silently.
- Add pretimeout validation in sbiwdt_set_timeout() to return -EINVAL if the new timeout
is less than or equal to the current pretimeout.
- Advertise WDIOF_PRETIMEOUT dynamically at runtime by assigning sbiwdt_pretimeout_info
to wdd.info only after MSI detection succeeds, rather than statically in watchdog_info,
since CONFIG_RISCV_IMSIC=y does not guarantee MSI availability at runtime.
- Fix MSI interrupt leak on probe failure by registering platform_device_msi_free_irqs_all()
via devm_add_action_or_reset() immediately after platform_device_msi_init_and_alloc_irqs()
succeeds. This ensures all subsequent probe failure paths are automatically covered without
explicit goto labels.
- Add module_exit() routine.
- Replace dev_err() with dev_err_probe() in probe() error paths for cleaner error reporting.
- Link to v1:
https://lore.kernel.org/linux-riscv/20261002163758.2919372-1-prajwal.n@oss.qualcomm.com/
- Sashiko review of v1
https://sashiko.dev/#/patchset/20261002163758.2919372-1-prajwal.n%40oss.qualcomm.com
Changes in v1:
- Initial RFC submission
Prajwal N (2):
RISC-V: Add defines for the RISC-V SBI watchdog extension
drivers/watchdog: Add RISC-V SBI watchdog driver
arch/riscv/include/asm/sbi.h | 26 ++
drivers/watchdog/Kconfig | 10 +
drivers/watchdog/Makefile | 1 +
drivers/watchdog/riscv_sbi_wdt.c | 442 +++++++++++++++++++++++++++++++
4 files changed, 479 insertions(+)
create mode 100644 drivers/watchdog/riscv_sbi_wdt.c
--
2.43.0
next reply other threads:[~2026-11-24 13:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:15 Prajwal N [this message]
2026-11-24 13:15 ` [RFC PATCH v4 1/2] RISC-V: Add defines for the RISC-V SBI watchdog extension Prajwal N
2026-11-24 13:15 ` [RFC PATCH v4 2/2] drivers/watchdog: Add RISC-V SBI watchdog driver Prajwal N
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=20261124131542.613271-1-prajwal.n@oss.qualcomm.com \
--to=prajwal.n@oss.qualcomm.com \
--cc=alex@ghiti.fr \
--cc=anup.patel@oss.qualcomm.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=prajwal.n.oss@gmail.com \
--cc=radim.krcmar@oss.qualcomm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®