An SBI Watchdog for RISC-V: Qualcomm Posts a Firmware-Defined Driver With IMSIC Pretimeout
On 2 October 2026 (date header Fri Oct 02 2026 - 12:43:08 EST), Prajwal N posted an RFC two-patch series to the Linux kernel mailing list: [RFC PATCH 1/2] include: sbi_ecall_interface: Add defines for the RISC-V SBI watchdog extension and [RFC PATCH 2/2] drivers/watchdog: Add RISC-V SBI watchdog driver. The new driver file carries a Copyright (C) 2026 Qualcomm Inc. header.
The series is small in volume — 416 insertions across a nine-line Kconfig stanza, a one-line Makefile change and a new 406-line drivers/watchdog/riscv_sbi_wdt.c — but it changes what a watchdog is on a RISC-V platform. Instead of an MMIO timer block inside a specific SoC, the watchdog becomes a service that firmware exposes through the Supervisor Binary Interface, and Linux reaches it with SBI ecalls. If it lands, a vendor with a compliant SBI implementation gets a working watchdog on Linux with no SoC-specific driver at all.
Copyright (C) 2026 Qualcomm Inc. header in the new source file; the submitter's email address is redacted in the public archive. Treat the ABI — ecall IDs, attribute enumerations, capability bits — as provisional until the watchdog and RISC-V maintainers converge on it.What the Driver Actually Does
The new RISCV_SBI_WATCHDOG Kconfig symbol is a tristate that depends on RISCV_SBI and defaults to RISCV. Its help text is a single blunt sentence: "Requires firmware support." That dependency is the whole design: every watchdog action becomes an ecall against a new extension ID, SBI_EXT_WDT.
Functionally the driver implements the standard Linux watchdog contract. sbiwdt_info advertises WDIOF_SETTIMEOUT, WDIOF_KEEPALIVEPING, WDIOF_PRETIMEOUT and WDIOF_MAGICCLOSE, and the ops table wires the standard callbacks onto six SBI function IDs:
| Linux watchdog op | SBI function ID | Notes |
|---|---|---|
start | SBI_EXT_WATCHDOG_START | Arms the firmware-side timer. |
stop | SBI_EXT_WATCHDOG_STOP | Disarms it. |
ping | SBI_EXT_WATCHDOG_PAT | The keepalive / service call. |
set_timeout | SBI_EXT_WATCHDOG_WRITE_ATTRIBUTE | Writes the timeout attribute. |
set_pretimeout | SBI_EXT_WATCHDOG_WRITE_ATTRIBUTE | Rejects values ≥ timeout with -EINVAL. |
get_timeleft | SBI_EXT_WATCHDOG_READ_ATTRIBUTE | Reads remaining time from firmware. |
Defaults are conservative. SBI_WDT_DEFAULT_TIMEOUT is 60 seconds, and sbiwdt_init_attributes() reads the firmware's minimum period and uses it as min_timeout, falling back to 1 µs if the firmware reports zero. SBI error codes are translated to Linux errno values through the existing sbi_err_map_linux_errno() helper, so the watchdog core sees ordinary return codes.
Pretimeout Arrives as an MSI, Not an Interrupt Line
The most interesting engineering detail is how the pretimeout notification — the "the real timeout is about to fire" warning that lets software dump state or trigger a controlled recovery — is delivered. Rather than a wired interrupt from a timer block, the driver asks the IMSIC (the incoming message-signaled interrupt controller of the ratified RISC-V AIA) for a platform MSI:
sbiwdt_probe()callsimsic_get_global_config(), thenirq_find_matching_fwnode(imsic_global->fwnode, DOMAIN_BUS_PLATFORM_MSI)to locate the MSI interrupt domain.platform_device_msi_init_and_alloc_irqs(dev, 1, sbiwdt_msi_write)allocates one MSI for the platform device.- The
sbiwdt_msi_write()callback receives the MSI address and data that the kernel has prepared and forwards both to firmware in a singleSBI_EXT_WATCHDOG_WRITE_NOTIF_MSI_MESSAGEecall — so it is OpenSBI itself that will raise the notification message when the pretimeout expires. - The resulting virtual IRQ is registered under the name
"sbiwdt-pretimeout"and its handler simply callswatchdog_notify_pretimeout(), handing the event to the watchdog core's pretimeout governor machinery.
This path is gated on a capability bit: SBI_WDT_CAP_MSI_SUPPORT_MASK is BIT(1) of the firmware-reported wdt_capability. If the bit is clear, the driver still registers with the watchdog core — it simply has no pretimeout path.
The SBI v3.0 Gate
Module init is where platform support is enforced. Two conditions must both hold, or the driver refuses to load:
if (sbi_spec_version < sbi_mk_version(3, 0) ||
sbi_probe_extension(SBI_EXT_WDT) <= 0)
return -ENODEV;
The running firmware must implement SBI 3.0 or later, and it must probe positive for the watchdog extension. Registration happens at late_initcall through platform_driver_register() plus platform_device_register_simple() — and there is no device-tree node in this RFC, because the "device" is the firmware interface itself rather than a memory-mapped block. The kernel discovers it by probing, the same way it discovers the SBAI console or the SBI PMU.
Why This Matters for Bring-Up
A per-SoC watchdog driver is one of the first things a new RISC-V SoC needs — and historically one of the least portable things in the tree. Every vendor's timer block has its own registers, its own timeout semantics and its own quirk list. Moving the interface behind SBI has three consequences:
- Portability. A board with compliant firmware gets a working watchdog on any kernel new enough to carry the driver. The same binary kernel image can serve boards whose watchdogs live in entirely different silicon.
- Single place to fix bugs. Timeout arithmetic and error translation live in one driver, not in a dozen vendor copies.
- Firmware becomes the safety boundary. The actual timer, its clock domain and its reset behavior stay under M-mode control, which matches how functional-safety platforms already treat watchdogs.
The trade-off is a hard dependency on firmware that does not exist everywhere yet. The RFC status also means the ABI is not settled: the ecall IDs and attribute enumerations live in a shared header, so any change on the OpenSBI side has to stay in lockstep with the kernel. And on boards whose firmware predates SBI 3.0, the driver simply declines to load — those platforms keep their existing SoC watchdog drivers.
Where This Fits With the Rest of the RISC-V Firmware Surface
The SBI watchdog RFC lands in a busy season for the RISC-V firmware/OS boundary: the gtrace hardware-trace framework (also posted this month), RISC-V IOMMU v6 with IMSIC MSI remapping for VFIO, and the K3's mainline bring-up where OpenSBI platform support has been advancing patch by patch. The common thread: RISC-V is pushing more platform functionality behind standardized firmware interfaces — RFENCE, SSE, PMU, now a watchdog — so that OS support scales across vendors without N per-SoC drivers.
SBI 看门狗来了:Qualcomm 提交固件定义型驱动,pretimeout 走 IMSIC MSI
2026 年 10 月 2 日(邮件头 Fri Oct 02 2026 - 12:43:08 EST),Prajwal N 向 Linux 内核邮件列表投递了一个 RFC 两补丁系列:[RFC PATCH 1/2] include: sbi_ecall_interface: Add defines for the RISC-V SBI watchdog extension 与 [RFC PATCH 2/2] drivers/watchdog: Add RISC-V SBI watchdog driver。新驱动文件头部标注 Copyright (C) 2026 Qualcomm Inc.
系列体量不大 — 全部 416 行新增:Kconfig 9 行、Makefile 1 行、新的 406 行 drivers/watchdog/riscv_sbi_wdt.c — 但它改变了 RISC-V 平台上"看门狗"的定义:看门狗不再是特定 SoC 里的 MMIO 定时器块,而是固件通过 SBI(监管者二进制接口)暴露的一项服务,Linux 用 ecall 调用它。一旦落地,固件实现合规的厂商无需任何 SoC 专属驱动即可在 Linux 上获得可用的看门狗。
驱动实际做什么
新增 Kconfig 符号 RISCV_SBI_WATCHDOG 为 tristate,depends on RISCV_SBI,默认 RISCV,帮助文本只有一句:"Requires firmware support."(需要固件支持)。驱动实现标准 Linux 看门狗契约:sbiwdt_info 声明 WDIOF_SETTIMEOUT / KEEPALIVEPING / PRETIMEOUT / MAGICCLOSE,把标准回调映射到对 SBI_EXT_WDT 的 六个 SBI 功能号:READ_ATTRIBUTE、WRITE_ATTRIBUTE、WRITE_NOTIF_MSI_MESSAGE、START、STOP、PAT(ping 即喂狗)。
默认值保守:SBI_WDT_DEFAULT_TIMEOUT 为 60 秒;sbiwdt_init_attributes() 读取固件上报的最小周期作为 min_timeout,固件报零则回退到 1 µs。set_pretimeout() 拒绝大于等于 timeout 的取值(-EINVAL);SBI 错误码经 sbi_err_map_linux_errno() 转成 Linux errno。
pretimeout 以 MSI 送达,而非中断线
最有工程价值的细节是 pretimeout("真正的超时即将到来"的预警,给软件留出转储状态或受控恢复的时间窗)的送达方式:不占用任何硬件中断线,而是向 IMSIC(已批准的 RISC-V AIA 中的消息信号中断控制器)申请平台 MSI:
sbiwdt_probe()先imsic_get_global_config(),再irq_find_matching_fwnode(imsic_global->fwnode, DOMAIN_BUS_PLATFORM_MSI)定位 MSI 域;platform_device_msi_init_and_alloc_irqs(dev, 1, sbiwdt_msi_write)为平台设备分配一个 MSI;- 回调
sbiwdt_msi_write()把内核准备好的 MSI 地址与数据通过一次SBI_EXT_WATCHDOG_WRITE_NOTIF_MSI_MESSAGEecall 转交给固件 — 也就是说,将来真正发出通知消息的是 OpenSBI; - 得到的虚拟 IRQ 以
"sbiwdt-pretimeout"注册,处理函数调用watchdog_notify_pretimeout(),交给看门狗核心的 pretimeout governor 机制。
该路径由能力位门控:SBI_WDT_CAP_MSI_SUPPORT_MASK 是固件上报 wdt_capability 的 BIT(1)。位为 0 时驱动照常注册,只是没有 pretimeout 能力。
SBI 3.0 门槛
if (sbi_spec_version < sbi_mk_version(3, 0) ||
sbi_probe_extension(SBI_EXT_WDT) <= 0)
return -ENODEV;
固件必须实现 SBI 3.0 及以上,且 watchdog 扩展探测必须为正,两者缺一不可。驱动在 late_initcall 通过 platform_driver_register() + platform_device_register_simple() 注册,没有设备树节点 — "设备"就是固件接口本身,与 SBI console、SBI PMU 的发现方式一致。
为什么对 bring-up 有意义
每个新 RISC-V SoC 都需要看门狗驱动,而它历来是内核里可移植性最差的部分之一。把接口收到 SBI 之后:合规固件的板子在任何足够新的内核上直接获得看门狗(同一份内核镜像可以服务看门狗完全不同的板子);超时算术与错误翻译集中在一处;真正的定时器、时钟域与复位行为留在 M-mode 固件手里 — 这正是功能安全平台对待看门狗的常规方式。代价是对尚不普遍的固件能力的硬依赖;RFC 状态下 ABI 未定,OpenSBI 侧任何改动都必须与内核同步。固件早于 SBI 3.0 的板子不受影响,继续用各自的 SoC 看门狗驱动。
相关阅读:OpenSBI K3 平台支持 · gtrace 硬件跟踪框架 · RISC-V IOMMU v6 MSI 重映射
Резюме (RU)
2 октября 2026 г. Prajwal N опубликовал RFC из двух патчей: определения расширения SBI watchdog и новый драйвер drivers/watchdog/riscv_sbi_wdt.c (копирайт Qualcomm Inc., 416 строк всего). Смысл: watchdog становится сервисом прошивки через SBI — шесть ecall к SBI_EXT_WDT (START, STOP, PAT, READ/WRITE ATTRIBUTE, WRITE_NOTIF_MSI_MESSAGE), таймаут по умолчанию 60 с, pretimeout — через platform MSI от IMSIC (AIA). Загрузка требует SBI 3.0+; device-tree не нужен. RFC: ни платформы, ни реализации OpenSBI, ни измерений не названо; ABI временный.
Resumen (ES)
El 2 de octubre de 2026, Prajwal N envió a LKML una serie RFC de dos parches: definiciones de la extensión SBI watchdog y un nuevo driver drivers/watchdog/riscv_sbi_wdt.c (Copyright Qualcomm Inc., 416 líneas en total). La idea: el watchdog se convierte en un servicio del firmware expuesto por SBI — seis ecalls contra SBI_EXT_WDT (START, STOP, PAT, READ/WRITE ATTRIBUTE, WRITE_NOTIF_MSI_MESSAGE), timeout por defecto de 60 s, y el pretimeout llega como un platform MSI del IMSIC (AIA). Requiere SBI 3.0+; sin nodo de device-tree. Es un RFC: no se nombra hardware, ni implementación OpenSBI, ni mediciones; el ABI es provisional.
Résumé (FR)
Le 2 octobre 2026, Prajwal N a publié sur LKML une série RFC de deux patchs : les définitions de l’extension SBI watchdog et un nouveau pilote drivers/watchdog/riscv_sbi_wdt.c (Copyright Qualcomm Inc., 416 lignes au total). L’idée : le watchdog devient un service du firmware exposé via SBI — six ecalls vers SBI_EXT_WDT (START, STOP, PAT, READ/WRITE ATTRIBUTE, WRITE_NOTIF_MSI_MESSAGE), délai par défaut de 60 s, et le prétimeout arrive sous forme de platform MSI de l’IMSIC (AIA). Nécessite SBI 3.0+ ; aucun nœud device-tree. C’est une RFC : ni plateforme matérielle, ni implémentation OpenSBI, ni mesures ; l’ABI est provisoire.
Kurzfassung (DE)
Am 2. Oktober 2026 reichte Prajwal N eine RFC-Zwei-Patch-Serie auf LKML ein: Definitionen der SBI-Watchdog-Erweiterung und ein neuer Treiber drivers/watchdog/riscv_sbi_wdt.c (Copyright Qualcomm Inc., insgesamt 416 Zeilen). Kernidee: Der Watchdog wird zu einem Firmware-Dienst über SBI — sechs Ecalls gegen SBI_EXT_WDT (START, STOP, PAT, READ/WRITE ATTRIBUTE, WRITE_NOTIF_MSI_MESSAGE), Standard-Timeout 60 s, und der Pretimeout kommt als Platform-MSI vom IMSIC (AIA). Benötigt SBI 3.0+; kein Device-Tree-Knoten. Es ist ein RFC: weder Hardware-Plattform noch OpenSBI-Implementierung noch Messungen genannt; das ABI ist provisorisch.
خلاصه (FA)
در ۲ اکتبر ۲۰۲۶ Prajwal N یک سری RFC دو پچی به LKML فرستد: تعریفهای پسترزش SBI watchdog و درییر جدید drivers/watchdog/riscv_sbi_wdt.c (کپیرایت Qualcomm Inc، در کل ۴۱۶ خط). ایده: وچدراگ به خدمتی از فیرمور تبدیل میشود که از طریق SBI در دسترس است — شش ecall به SBI_EXT_WDT (START، STOP، PAT، READ/WRITE ATTRIBUTE، WRITE_NOTIF_MSI_MESSAGE)، تایماوت پیشفرض ۶۰ ثانیه، و pretimeout به صورت platform MSI از IMSIC (AIA) میرسد. نیازمند به SBI 3.0 به بالا است؟ بدون گره device-tree. این یک RFC است: هیچ سختافزاری مشخص، هیچ پیادهسازی OpenSBI و هیچ اندازهگیری معرفی نشده و ABI موقت است.
Sources / 参考来源
- LKML archive — Prajwal N, "[RFC PATCH 2/2] drivers/watchdog: Add RISC-V SBI watchdog driver", Fri Oct 02 2026 12:43:08 EST
- LKML archive — Prajwal N, "[RFC PATCH 1/2] include: sbi_ecall_interface: Add defines for the RISC-V SBI watchdog extension"
- RISC-V Supervisor Binary Interface specification (SBI 3.0 gating reference)
- OpenSBI repository — reference SBI implementation (no watchdog extension implementation named at posting time)
- Linux watchdog subsystem API — WDIOF flags and pretimeout governor contract