watchdog: histb: Add HiSilicon STB watchdog driver
cover watchdog: histb: Add HiSilicon STB watchdog driver
The watchdog integrated on HiSilicon STB SoCs reuses the register layout of sp805, but deviates from the standard sp805 in several ways that make the existing sp805 driver unusable on these SoCs. Add a dedicated platform driver for this controller.
David Yang (4):
dt-bindings: watchdog: Add HiSilicon STB watchdog binding
watchdog: histb: Add HiSilicon STB watchdog driver
arm64: dts: hisilicon: hi3798cv200: Add watchdog node
MAINTAINERS: Add HiSilicon STB drivers entry
.../watchdog/hisilicon,histb-wdt.yaml | 54 ++++ MAINTAINERS | 7 + .../arm64/boot/dts/hisilicon/hi3798cv200.dtsi | 8 + drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/histb_wdt.c | 287 ++++++++++++++++++ 6 files changed, 365 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml create mode 100644 drivers/watchdog/histb_wdt.c
Signature · 1 line
2.53.0
PATCH 1/4 dt-bindings: watchdog: Add HiSilicon STB watchdog binding
Add Device Tree binding schema for the watchdog controller found on HiSilicon STB SoCs.
While sharing the register layout of ARM PrimeCell SP805, this block does not implement PrimeCell ID registers and has non-standard reload and lock semantics, requiring a dedicated platform driver binding.
--- .../watchdog/hisilicon,histb-wdt.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml
Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml new file +54 -0
@@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/hisilicon,histb-wdt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon STB SoC Watchdog + +maintainers: + - David Yang <[email protected]> + +description: + HiSilicon STB SoCs (Hi3716, Hi3798, Hi3798, etc) integrate a watchdog device, + which triggers an interrupt after a configurable time period. If that + interrupt has not been serviced when the next interrupt would be triggered, + the reset signal is asserted. + +allOf: + - $ref: watchdog.yaml# + +properties: + compatible: + items: + - enum: + - hisilicon,hi3798cv200-wdt + - const: hisilicon,histb-wdt + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-frequency: true + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + watchdog@8a2c000 { + compatible = "hisilicon,hi3798cv200-wdt", "hisilicon,histb-wdt"; + reg = <0x8a2c000 0x1000>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&crg 0>; + };
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 1/4] dt-bindings: watchdog: Add HiSilicon STB watchdog binding
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] dt-bindings: watchdog: redundant word binding in commit subject - [Low] dt-bindings: watchdog…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] dt-bindings: watchdog: redundant word binding in commit subject
- [Low] dt-bindings: watchdog: non-canonical property order in example node
--
commit a1622b56fb454eac20ec415b3fb13ffbe0760e8a
Author: David Yang <[email protected]>
dt-bindings: watchdog: Add HiSilicon STB watchdog binding
This commit adds a Device Tree binding schema for the watchdog controller found on HiSilicon STB SoCs.
Quoted 1 line
dt-bindings: watchdog: Add HiSilicon STB watchdog binding
[Severity: Low]
The "dt-bindings:" prefix already states that the patch adds a binding, so "binding" at the end of the subject is redundant and can be dropped:
"dt-bindings: watchdog: Add HiSilicon STB watchdog".
Quoted 5 lines
Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml line 54
Quoted 10 lines
Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml new file +10
-0+examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + watchdog@8a2c000 { + compatible = "hisilicon,hi3798cv200-wdt", "hisilicon,histb-wdt"; + reg = <0x8a2c000 0x1000>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&crg 0>; + };
[Severity: Low]
In the example node, clocks should be listed before interrupts to follow the canonical property order used in the properties list above.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/4 watchdog: histb: Add HiSilicon STB watchdog driver
In reply to David YangThe watchdog controller integrated on HiSilicon STB SoCs shares register offsets with the ARM PrimeCell SP805, but differs in several critical behaviors. Add a dedicated platform driver to handle these SoC-specific semantics natively without regressing generic SP805 users.
--- drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/histb_wdt.c | 287 +++++++++++++++++++++++++++++++++++ 3 files changed, 296 insertions(+) create mode 100644 drivers/watchdog/histb_wdt.c
drivers/watchdog/Kconfig +8 -0
@@ -1183,6 +1183,14 @@ config SUNPLUS_WATCHDOG To compile this driver as a module, choose M here: the module will be called sunplus_wdt. +config HISTB_WATCHDOG + tristate "HiSilicon STB Watchdog" + depends on (ARCH_HISI || COMPILE_TEST) && OF + select WATCHDOG_CORE + help + Say Y here to include support for the watchdog timer in HiSilicon STB + SoCs. + # X86 (i386 + ia64 + x86_64) Architecture config ACQUIRE_WDT
drivers/watchdog/Makefile +1 -0
@@ -106,6 +106,7 @@ obj-$(CONFIG_SUNPLUS_WATCHDOG) += sunplus_wdt.o obj-$(CONFIG_MARVELL_GTI_WDT) += marvell_gti_wdt.o obj-$(CONFIG_GUNYAH_WATCHDOG) += gunyah_wdt.o obj-$(CONFIG_MA35D1_WDT) += ma35d1_wdt.o +obj-$(CONFIG_HISTB_WATCHDOG) += histb_wdt.o # X86 (i386 + ia64 + x86_64) Architecture obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
drivers/watchdog/histb_wdt.c new file +287 -0
287 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] watchdog: histb: stale counter reload in histb_wdt_arm() and histb_wdt_ping() - [High] watchdog…
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [High] watchdog: histb: stale counter reload in histb_wdt_arm() and histb_wdt_ping()
- [High] watchdog: histb: unclocked MMIO reads in histb_wdt_get_timeleft() when stopped
- [Medium] watchdog: histb: missing watchdog_stop_on_unregister() in histb_wdt_probe()
- [Medium] watchdog: histb: unchecked histb_wdt_start() error in histb_wdt_resume()
- [Medium] watchdog: histb: deadlock and invalid wait context in histb_wdt_restart()
--
commit 8f21fc6b65d49db93aa95ad107c510c4d4fadce6
Author: David Yang <[email protected]>
watchdog: histb: Add HiSilicon STB watchdog driver
This commit adds a platform watchdog driver for the watchdog controller integrated on HiSilicon STB SoCs.
Quoted 18 lines
drivers/watchdog/histb_wdt.c new file +12
-0@@ -0,0 +1,287 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* +* HiSilicon STB Watchdog Driver +* +* The watchdog controller integrated on HiSilicon STB SoCs shares register +* offsets with the ARM PrimeCell SP805, but differs in several critical +* hardware behaviors: +* - The ID registers at 0xfe0..0xffc are unimplemented and read zero, +* requiring a platform device driver rather than AMBA probe; +* - Writing WDTLOCK freezes the counter instead of only blocking register +* writes, so the block must remain unlocked while running; +* - Writing WDTLOAD never reloads the running counter; only WDTINTCLR does;
[ ... ]
Quoted 14 lines
drivers/watchdog/histb_wdt.c new file +14
-0+static void histb_wdt_arm (struct histb_wdt *wdt,u32 load) +{ +void __iomem *base = wdt->base; + +spin_lock (&wdt->lock); +writel_relaxed (HISTB_WDT_UNLOCK_KEY , base +HISTB_WDT_LOCK ); +writel_relaxed (0 , base +HISTB_WDT_CONTROL ); +writel_relaxed (HISTB_WDT_INT_MASK , base +HISTB_WDT_INTCLR ); +writel_relaxed (load, base +HISTB_WDT_LOAD ); +writel_relaxed (HISTB_WDT_INT_ENABLE |HISTB_WDT_RESET_ENABLE , + base +HISTB_WDT_CONTROL ); +readl_relaxed (base +HISTB_WDT_LOCK ); +spin_unlock (&wdt->lock); +}
[ ... ]
drivers/watchdog/histb_wdt.c line 120
Quoted 13 lines
drivers/watchdog/histb_wdt.c new file +13
-0+static int histb_wdt_ping (struct watchdog_device *wdd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); +void __iomem *base = wdt->base; + +spin_lock (&wdt->lock); +writel_relaxed (HISTB_WDT_INT_MASK , base +HISTB_WDT_INTCLR ); +writel_relaxed (wdt->load_val, base +HISTB_WDT_LOAD ); +readl_relaxed (base +HISTB_WDT_LOCK ); +spin_unlock (&wdt->lock); + +return 0 ; +}
[Severity: High]
Should HISTB_WDT_LOAD be written before HISTB_WDT_INTCLR in histb_wdt_arm() and histb_wdt_ping()?
As noted in the file header comment, writing WDTLOAD does not reload the counter and only writing WDTINTCLR triggers the reload. Writing HISTB_WDT_INTCLR first reloads the counter with whatever stale value was previously in HISTB_WDT_LOAD. In particular, when histb_wdt_restart() calls histb_wdt_arm(wdt, 1), the counter reloads with the old timeout (or 0xffffffff if the watchdog was never started) instead of 1, so the system fails to reset during the 1 ms delay.
[ ... ]
drivers/watchdog/histb_wdt.c line 157
Quoted 13 lines
drivers/watchdog/histb_wdt.c new file +13
-0+static unsigned int histb_wdt_get_timeleft (struct watchdog_device *wdd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); +u64 value; + +spin_lock (&wdt->lock); + value =readl_relaxed (wdt->base +HISTB_WDT_VALUE ); +if (!(readl_relaxed (wdt->base +HISTB_WDT_RIS ) &HISTB_WDT_INT_MASK )) + value += (u64 )wdt->load_val +1 ; +spin_unlock (&wdt->lock); + +return div_u64 (value, wdt->rate); +}
[Severity: High]
Can histb_wdt_get_timeleft() read HISTB_WDT_VALUE and HISTB_WDT_RIS while wdt->clk is disabled?
wdt->clk is only prepared at probe time and is not enabled until histb_wdt_start() is called, and histb_wdt_stop() disables it again. The watchdog core's timeleft sysfs attribute (and WDIOC_GETTIMELEFT ioctl) invokes wdd->ops->get_timeleft(wdd) without checking watchdog_active(wdd). Reading /sys/class/watchdog/watchdogN/timeleft while the watchdog is stopped accesses the device registers with the clock gated, which can cause a synchronous external abort or bus hang.
Quoted 7 lines
drivers/watchdog/histb_wdt.c new file +7
-0+static int +histb_wdt_restart (struct watchdog_device *wdd,unsigned long mode,void *cmd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); + +/* +* For reset, we start the WDT clock and leave it running.
drivers/watchdog/histb_wdt.c line 175
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+* The clock was prepared at probe time; only clk_enable() is +* safe in this atomic (restart notifier) context. +*/ +clk_enable (wdt->clk); +histb_wdt_arm (wdt,1 ); + +mdelay (1 ); + +return 0 ; +}
[Severity: Medium]
Can histb_wdt_restart() deadlock on wdt->lock via histb_wdt_arm()?
Normal callers acquire wdt->lock with plain spin_lock() while local interrupts remain enabled, whereas histb_wdt_restart() runs from the restart notifier chain after smp_send_stop() or from emergency_restart() in hardirq context:
CPU0 CPU1histb_wdt_ping()
spin_lock(&wdt->lock)
machine_restart()
smp_send_stop()
<stop IPI halts CPU0>
do_kernel_restart()
histb_wdt_restart()
histb_wdt_arm()
spin_lock(&wdt->lock)
<-- spins foreverAn emergency_restart() triggered from a hardirq on the same CPU while wdt->lock is held will likewise deadlock, and taking spinlock_t from hardirq context violates lockdep wait-context nesting on PREEMPT_RT. Programming the registers in histb_wdt_restart() through an unlocked helper avoids taking wdt->lock during restart.
[ ... ]
Quoted 19 lines
drivers/watchdog/histb_wdt.c new file +19
-0+static int histb_wdt_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct histb_wdt *wdt; +int res; + + wdt =devm_kzalloc_obj (dev, *wdt); +if (!wdt) +return -ENOMEM ; + + wdt->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (wdt->base)) +return PTR_ERR (wdt->base); + +/* +* Keep the clock prepared for the lifetime of the driver: +* .restart() runs in atomic context and may only call clk_enable(). +*/ + wdt->clk =devm_clk_get_optional_prepared (dev,NULL );
[ ... ]
drivers/watchdog/histb_wdt.c line 245
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+watchdog_stop_on_reboot (&wdt->wdd); +platform_set_drvdata (pdev, wdt); + + res =devm_watchdog_register_device (dev, &wdt->wdd); +if (res) +return dev_err_probe (dev, res, +"Failed to register watchdog device\n" ); + +return 0 ; +}
[Severity: Medium]
Should histb_wdt_probe() also call watchdog_stop_on_unregister(&wdt->wdd)?
If the device is unbound while the watchdog is active, devm_watchdog_register_device() unregisters the watchdog without calling histb_wdt_stop(). That leaves the hardware counter running to reset the system and causes the devres cleanup for devm_clk_get_optional_prepared() to call clk_unprepare() while wdt->clk is still enabled, triggering a WARN in clk_core_unprepare().
Quoted 9 lines
drivers/watchdog/histb_wdt.c new file +9
-0+static int __maybe_unused histb_wdt_suspend (struct device *dev) +{ +struct histb_wdt *wdt =dev_get_drvdata (dev); + +if (watchdog_active (&wdt->wdd)) +histb_wdt_stop (&wdt->wdd); + +return 0 ; +}
drivers/watchdog/histb_wdt.c line 265
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+ +static int __maybe_unused histb_wdt_resume (struct device *dev) +{ +struct histb_wdt *wdt =dev_get_drvdata (dev); + +if (watchdog_active (&wdt->wdd)) +histb_wdt_start (&wdt->wdd); + +return 0 ; +}
[Severity: Medium]
Should histb_wdt_resume() propagate the return value of histb_wdt_start()?
If clk_enable() fails in histb_wdt_start() during resume, discarding the error leaves WDOG_ACTIVE set while wdt->clk remains disabled. Later watchdog callbacks will then access unclocked MMIO registers and histb_wdt_stop() will call clk_disable() on an already-disabled clock.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Guenter Roeck
maintainerQuoted 106 lines · On 11/21/26 23:18, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [High] watchdog: histb: stale counter reload inhistb_wdt_arm()andhistb_wdt_ping()
- [High] watchdog: histb: unclocked MMIO reads inhistb_wdt_get_timeleft()when stopped
- [Medium] watchdog: histb: missingwatchdog_stop_on_unregister()inhistb_wdt_probe()
- [Medium] watchdog: histb: uncheckedhistb_wdt_start()error inhistb_wdt_resume()
- [Medium] watchdog: histb: deadlock and invalid wait context inhistb_wdt_restart()
--commit
8f21fc6b65d49db93aa95ad107c510c4d4fadce6
Author: David Yang <[email protected]>watchdog: histb: Add HiSilicon STB watchdog driver
This commit adds a platform watchdog driver for the watchdog controller integrated on HiSilicon STB SoCs.
Quoted 18 lines
drivers/watchdog/histb_wdt.c new file +12
-0@@ -0,0 +1,287 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* +* HiSilicon STB Watchdog Driver +* +* The watchdog controller integrated on HiSilicon STB SoCs shares register +* offsets with the ARM PrimeCell SP805, but differs in several critical +* hardware behaviors: +* - The ID registers at 0xfe0..0xffc are unimplemented and read zero, +* requiring a platform device driver rather than AMBA probe; +* - Writing WDTLOCK freezes the counter instead of only blocking register +* writes, so the block must remain unlocked while running; +* - Writing WDTLOAD never reloads the running counter; only WDTINTCLR does; [ ... ]
Quoted 14 lines
drivers/watchdog/histb_wdt.c new file +14
-0+static void histb_wdt_arm (struct histb_wdt *wdt,u32 load) +{ +void __iomem *base = wdt->base; + +spin_lock (&wdt->lock); +writel_relaxed (HISTB_WDT_UNLOCK_KEY , base +HISTB_WDT_LOCK ); +writel_relaxed (0 , base +HISTB_WDT_CONTROL ); +writel_relaxed (HISTB_WDT_INT_MASK , base +HISTB_WDT_INTCLR ); +writel_relaxed (load, base +HISTB_WDT_LOAD ); +writel_relaxed (HISTB_WDT_INT_ENABLE |HISTB_WDT_RESET_ENABLE , + base +HISTB_WDT_CONTROL ); +readl_relaxed (base +HISTB_WDT_LOCK ); +spin_unlock (&wdt->lock); +}[ ... ]
drivers/watchdog/histb_wdt.c line 120
Quoted 13 lines
drivers/watchdog/histb_wdt.c new file +13
-0+static int histb_wdt_ping (struct watchdog_device *wdd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); +void __iomem *base = wdt->base; + +spin_lock (&wdt->lock); +writel_relaxed (HISTB_WDT_INT_MASK , base +HISTB_WDT_INTCLR ); +writel_relaxed (wdt->load_val, base +HISTB_WDT_LOAD ); +readl_relaxed (base +HISTB_WDT_LOCK ); +spin_unlock (&wdt->lock); + +return 0 ; +}[Severity: High]
ShouldHISTB_WDT_LOADbe written beforeHISTB_WDT_INTCLRinhistb_wdt_arm()andhistb_wdt_ping()?As noted in the file header comment, writing WDTLOAD does not reload the counter and only writing WDTINTCLR triggers the reload. Writing
HISTB_WDT_INTCLRfirst reloads the counter with whatever stale value was previously inHISTB_WDT_LOAD. In particular, whenhistb_wdt_restart()callshistb_wdt_arm(wdt, 1), the counter reloads with the old timeout (or0xffffffffif the watchdog was never started) instead of 1, so the system fails to reset during the 1 ms delay.[ ... ]
drivers/watchdog/histb_wdt.c line 157
Quoted 13 lines
drivers/watchdog/histb_wdt.c new file +13
-0+static unsigned int histb_wdt_get_timeleft (struct watchdog_device *wdd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); +u64 value; + +spin_lock (&wdt->lock); + value =readl_relaxed (wdt->base +HISTB_WDT_VALUE ); +if (!(readl_relaxed (wdt->base +HISTB_WDT_RIS ) &HISTB_WDT_INT_MASK )) + value += (u64 )wdt->load_val +1 ; +spin_unlock (&wdt->lock); + +return div_u64 (value, wdt->rate); +}[Severity: High]
Canhistb_wdt_get_timeleft()readHISTB_WDT_VALUEandHISTB_WDT_RISwhilewdt->clkis disabled?
Quoted 8 lines
wdt->clkis only prepared at probe time and is not enabled untilhistb_wdt_start()is called, andhistb_wdt_stop()disables it again. The watchdog core's timeleft sysfs attribute (andWDIOC_GETTIMELEFTioctl) invokeswdd->ops->get_timeleft(wdd)without checkingwatchdog_active(wdd). Reading/sys/class/watchdog/watchdogN/timeleftwhile the watchdog is stopped accesses the device registers with the clock gated, which can cause a synchronous external abort or bus hang.
A generic fix for this problem is pending.
https://patchwork.kernel.org/project/linux-watchdog/patch/[email protected]/
Guenter
Quoted 117 lines
Quoted 7 lines
drivers/watchdog/histb_wdt.c new file +7
-0+static int +histb_wdt_restart (struct watchdog_device *wdd,unsigned long mode,void *cmd) +{ +struct histb_wdt *wdt =watchdog_get_drvdata (wdd); + +/* +* For reset, we start the WDT clock and leave it running. drivers/watchdog/histb_wdt.c line 175
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+* The clock was prepared at probe time; only clk_enable() is +* safe in this atomic (restart notifier) context. +*/ +clk_enable (wdt->clk); +histb_wdt_arm (wdt,1 ); + +mdelay (1 ); + +return 0 ; +}[Severity: Medium]
Canhistb_wdt_restart()deadlock onwdt->lockviahistb_wdt_arm()?Normal callers acquire
wdt->lockwith plainspin_lock()while local interrupts remain enabled, whereashistb_wdt_restart()runs from the restart notifier chain aftersmp_send_stop()or fromemergency_restart()in hardirq context:CPU0 CPU1
histb_wdt_ping()
spin_lock(&wdt->lock)machine_restart() smp_send_stop() <stop IPI halts CPU0> do_kernel_restart() histb_wdt_restart() histb_wdt_arm() spin_lock(&wdt->lock) <-- spins foreverAn
emergency_restart()triggered from a hardirq on the same CPU whilewdt->lockis held will likewise deadlock, and takingspinlock_tfrom hardirq context violates lockdep wait-context nesting onPREEMPT_RT. Programming the registers inhistb_wdt_restart()through an unlocked helper avoids takingwdt->lockduring restart.[ ... ]
Quoted 19 lines
drivers/watchdog/histb_wdt.c new file +19
-0+static int histb_wdt_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct histb_wdt *wdt; +int res; + + wdt =devm_kzalloc_obj (dev, *wdt); +if (!wdt) +return -ENOMEM ; + + wdt->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (wdt->base)) +return PTR_ERR (wdt->base); + +/* +* Keep the clock prepared for the lifetime of the driver: +* .restart() runs in atomic context and may only call clk_enable(). +*/ + wdt->clk =devm_clk_get_optional_prepared (dev,NULL );[ ... ]
drivers/watchdog/histb_wdt.c line 245
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+watchdog_stop_on_reboot (&wdt->wdd); +platform_set_drvdata (pdev, wdt); + + res =devm_watchdog_register_device (dev, &wdt->wdd); +if (res) +return dev_err_probe (dev, res, +"Failed to register watchdog device\n" ); + +return 0 ; +}[Severity: Medium]
Shouldhistb_wdt_probe()also callwatchdog_stop_on_unregister(&wdt->wdd)?If the device is unbound while the watchdog is active,
devm_watchdog_register_device()unregisters the watchdog without callinghistb_wdt_stop(). That leaves the hardware counter running to reset the system and causes the devres cleanup fordevm_clk_get_optional_prepared()to callclk_unprepare()whilewdt->clkis still enabled, triggering a WARN inclk_core_unprepare().Quoted 9 lines
drivers/watchdog/histb_wdt.c new file +9
-0+static int __maybe_unused histb_wdt_suspend (struct device *dev) +{ +struct histb_wdt *wdt =dev_get_drvdata (dev); + +if (watchdog_active (&wdt->wdd)) +histb_wdt_stop (&wdt->wdd); + +return 0 ; +}drivers/watchdog/histb_wdt.c line 265
Quoted 10 lines
drivers/watchdog/histb_wdt.c new file +10
-0+ +static int __maybe_unused histb_wdt_resume (struct device *dev) +{ +struct histb_wdt *wdt =dev_get_drvdata (dev); + +if (watchdog_active (&wdt->wdd)) +histb_wdt_start (&wdt->wdd); + +return 0 ; +}[Severity: Medium]
Shouldhistb_wdt_resume()propagate the return value ofhistb_wdt_start()?If
clk_enable()fails inhistb_wdt_start()during resume, discarding the error leavesWDOG_ACTIVEset whilewdt->clkremains disabled. Later watchdog callbacks will then access unclocked MMIO registers andhistb_wdt_stop()will callclk_disable()on an already-disabled clock.
PATCH 3/4 arm64: dts: hisilicon: hi3798cv200: Add watchdog node
In reply to David YangAdd the on-chip watchdog controller node to hi3798cv200.dtsi, backed by the new hisilicon,histb-wdt platform driver.
--- arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi +8 -0
@@ -254,6 +254,14 @@ range: gpio-range { }; }; + watchdog0: watchdog@8a2c000 { + compatible = "hisilicon,hi3798cv200-wdt", "hisilicon,histb-wdt"; + reg = <0x8a2c000 0x1000>; + interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&crg HISTB_OSC_CLK>; + status = "disabled"; + }; + uart0: serial@8b00000 { compatible = "arm,pl011", "arm,primecell"; reg = <0x8b00000 0x1000>;
Signature · 1 line
2.53.0
PATCH 4/4 MAINTAINERS: Add HiSilicon STB drivers entry
In reply to David YangAdd a MAINTAINERS entry for the HiSilicon STB platform drivers, covering the histb-wdt watchdog driver and the existing histb-rng hardware RNG driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -12187,6 +12187,13 @@ S: Maintained F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml F: drivers/mfd/hi6421-spmi-pmic.c +HISILICON STB DRIVERS +M: David Yang <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/watchdog/hisilicon,histb-wdt.yaml +F: drivers/char/hw_random/histb-rng.c +F: drivers/watchdog/histb_wdt.c + HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Weili Qian <[email protected]> S: Maintained
Signature · 1 line
2.53.0