Skip to contentSkip to conversation

watchdog: aspeed: Add sysfs attributes for reset mask bits

PATCH In review Zev Weiss 3 participants 4 messages Sep 22, 2023

Subsystems (2)
lore
Share & tools
lore

Zev Weiss

author
#0 lore raw

PATCH 1/1 watchdog: aspeed: Add sysfs attributes for reset mask bits

The AST2500 and AST2600 watchdog timers provide the ability to control which devices are reset by the watchdog timer via a reset mask resgister. Previously the driver ignored that register, leaving whatever configuration it found at boot and offering no way of altering its settings. Add a 'reset_ctrl' sysfs subdirectory with a file per bit so that userspace can determine which devices the reset is applied to.

Note that not all bits in the hardware register are exposed -- in particular, the ARM CPU and SOC/misc reset bits are left hidden since clearing them can render the system unable to reboot.

---

I'm porting OpenBMC to a platform that requires that the LPC controller remain un-reset by a BMC reboot. With this patch userspace can control the reset mask of the Aspeed watchdog timer, with a few bits remaining unexposed so as to prevent some almost-certainly undesirable situations. If there are other bits that people feel shouldn't be exposed (or conversely if someone feels strongly that the "dangerous" bits _should_ be exposed) I can adjust accordingly.

Also, I was a little unsure about appropriately-concise names for some of the bits, and am not hugely attached to the ones currently in this patch, so suggestions on better alternatives there would also be welcome.

I've tested this on ast2500 hardware and a qemu ast2600 model (since I don't have any ast2600 hardware) and it appears to be working as intended, but if anyone can verify on actual ast2600 hardware that would of course be nice to confirm.

 .../ABI/testing/sysfs-class-watchdog          |  10 +
 drivers/watchdog/aspeed_wdt.c                 | 290 ++++++++++++++++--
 2 files changed, 272 insertions(+), 28 deletions(-)
Documentation/ABI/testing/sysfs-class-watchdog +10 -0
index 94fb74615951..a2f4bb6a4263 100644
@@ -127,3 +127,13 @@ Description:
 		shown. When written with any non-zero value, it clears
 		the boot code selection and the timeout counter, which results
 		in chipselect reset for AST2400/AST2500.
+
+What:		/sys/class/watchdog/watchdogn/reset_ctrl/*
+Date:		September 2023
+Contact:	Zev Weiss <[email protected]>
+Description:
+		The read/write files in this subdirectory (present on Aspeed
+		AST2500 and AST2600 only) control which devices and SoC
+		components are reset when the watchdog timer expires.  When set
+		to '1', the device indicated by the name of the file will be
+		reset; when set to '0' it will not.
drivers/watchdog/aspeed_wdt.c +262 -28

348 lines not on this page · raw message

Signature · 1 line
2.42.0
maintainer
#1 lore raw
Quoted 15 lines · Zev Weiss

The AST2500 and AST2600 watchdog timers provide the ability to control which devices are reset by the watchdog timer via a reset mask resgister. Previously the driver ignored that register, leaving whatever configuration it found at boot and offering no way of altering its settings. Add a 'reset_ctrl' sysfs subdirectory with a file per bit so that userspace can determine which devices the reset is applied to.

Note that not all bits in the hardware register are exposed -- in particular, the ARM CPU and SOC/misc reset bits are left hidden since clearing them can render the system unable to reboot.

---

Quoted 7 lines

I'm porting OpenBMC to a platform that requires that the LPC controller remain un-reset by a BMC reboot. With this patch userspace can control the reset mask of the Aspeed watchdog timer, with a few bits remaining unexposed so as to prevent some almost-certainly undesirable situations. If there are other bits that people feel shouldn't be exposed (or conversely if someone feels strongly that the "dangerous" bits _should_ be exposed) I can adjust accordingly.

Is there a reason this has to be managed by userspace? It sounds a lot like a property of platform design, in which case exposing this feature in the devicetree might be a better approach.

Andrew

maintainer
#2 lore raw
Quoted 25 lines · Andrew Jeffery
Quoted 15 lines · Zev Weiss

The AST2500 and AST2600 watchdog timers provide the ability to control which devices are reset by the watchdog timer via a reset mask resgister. Previously the driver ignored that register, leaving whatever configuration it found at boot and offering no way of altering its settings. Add a 'reset_ctrl' sysfs subdirectory with a file per bit so that userspace can determine which devices the reset is applied to.

Note that not all bits in the hardware register are exposed -- in particular, the ARM CPU and SOC/misc reset bits are left hidden since clearing them can render the system unable to reboot.

---

Quoted 7 lines

I'm porting OpenBMC to a platform that requires that the LPC controller remain un-reset by a BMC reboot. With this patch userspace can control the reset mask of the Aspeed watchdog timer, with a few bits remaining unexposed so as to prevent some almost-certainly undesirable situations. If there are other bits that people feel shouldn't be exposed (or conversely if someone feels strongly that the "dangerous" bits _should_ be exposed) I can adjust accordingly.

Quoted 4 lines

Is there a reason this has to be managed by userspace? It sounds a lot like a property of platform design, in which case exposing this feature in the devicetree might be a better approach.

Same sentiment here.

Guenter

author
#3 lore raw
Quoted 26 lines · Guenter Roeck
Quoted 25 lines · Andrew Jeffery
Quoted 22 lines · Zev Weiss

The AST2500 and AST2600 watchdog timers provide the ability to control which devices are reset by the watchdog timer via a reset mask resgister. Previously the driver ignored that register, leaving whatever configuration it found at boot and offering no way of altering its settings. Add a 'reset_ctrl' sysfs subdirectory with a file per bit so that userspace can determine which devices the reset is applied to.

Note that not all bits in the hardware register are exposed -- in particular, the ARM CPU and SOC/misc reset bits are left hidden since clearing them can render the system unable to reboot.

---

I'm porting OpenBMC to a platform that requires that the LPC controller remain un-reset by a BMC reboot. With this patch userspace can control the reset mask of the Aspeed watchdog timer, with a few bits remaining unexposed so as to prevent some almost-certainly undesirable situations. If there are other bits that people feel shouldn't be exposed (or conversely if someone feels strongly that the "dangerous" bits _should_ be exposed) I can adjust accordingly.

Quoted 10 lines
Quoted 4 lines

Is there a reason this has to be managed by userspace? It sounds a lot like a property of platform design, in which case exposing this feature in the devicetree might be a better approach.

Same sentiment here.

Guenter

Yes, and indeed the same thing occurred to me, too, though unfortunately not until just *after* I sent the patch...I'll rework it as a DT thing instead.

Thanks,
Zev