Skip to content

Commit 2aeeadb

Browse files
authored
Merge pull request #1321 from kernelkit/cn9130-wdg
CN9130 Watchdog
2 parents 7fcbc88 + 553d659 commit 2aeeadb

File tree

15 files changed

+179
-8
lines changed

15 files changed

+179
-8
lines changed

board/aarch32/linux_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
394394
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
395395
CONFIG_WQ_WATCHDOG=y
396396
CONFIG_WQ_CPU_INTENSIVE_REPORT=y
397+
CONFIG_TEST_LOCKUP=m
397398
# CONFIG_SCHED_DEBUG is not set
398399
# CONFIG_RCU_TRACE is not set
399400
CONFIG_FUNCTION_TRACER=y

board/aarch64/linux_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ CONFIG_WATCHDOG=y
407407
CONFIG_WATCHDOG_SYSFS=y
408408
CONFIG_SOFT_WATCHDOG=y
409409
CONFIG_GPIO_WATCHDOG=y
410+
CONFIG_ARM_SBSA_WATCHDOG=y
410411
CONFIG_ARMADA_37XX_WATCHDOG=y
411412
CONFIG_I6300ESB_WDT=y
412413
CONFIG_MFD_MAX77620=y
@@ -564,6 +565,7 @@ CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
564565
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
565566
CONFIG_WQ_WATCHDOG=y
566567
CONFIG_WQ_CPU_INTENSIVE_REPORT=y
568+
CONFIG_TEST_LOCKUP=m
567569
# CONFIG_SCHED_DEBUG is not set
568570
# CONFIG_RCU_TRACE is not set
569571
CONFIG_FUNCTION_TRACER=y

board/aarch64/styx-dcp-sc-28p/dts/styx/dcp-sc-28p-a.dts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@
5959
XSWP(a, "e13", 13, &sfp0);
6060
};
6161
};
62+
63+
&cp0_spi1 {
64+
spi-flash@0 {
65+
broken-flash-reset;
66+
};
67+
};

board/riscv64/linux_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
481481
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
482482
CONFIG_WQ_WATCHDOG=y
483483
CONFIG_WQ_CPU_INTENSIVE_REPORT=y
484+
CONFIG_TEST_LOCKUP=m
484485
# CONFIG_SCHED_DEBUG is not set
485486
CONFIG_STACKTRACE=y
486487
CONFIG_RCU_CPU_STALL_TIMEOUT=60

board/x86_64/linux_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,5 +270,6 @@ CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
270270
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
271271
CONFIG_WQ_WATCHDOG=y
272272
CONFIG_WQ_CPU_INTENSIVE_REPORT=y
273+
CONFIG_TEST_LOCKUP=m
273274
CONFIG_FUNCTION_TRACER=y
274275
CONFIG_UNWINDER_FRAME_POINTER=y

test/case/hardware/Readme.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Tests verifying hardware monitoring and management:
55

66
- USB device detection and enumeration
77
- Multiple USB port management and device handling
8+
- Watchdog reset capability
89

910
include::usb/Readme.adoc[]
1011

1112
include::usb_two_ports/Readme.adoc[]
13+
14+
include::watchdog/Readme.adoc[]

test/case/hardware/all.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44

55
- name: USB configuration with two USB ports
66
case: usb_two_ports/test.py
7+
8+
- name: Watchdog reset on system lockup
9+
case: watchdog/test.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.adoc
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== Watchdog reset on system lockup
2+
3+
ifdef::topdoc[:imagesdir: {topdoc}../../test/case/hardware/watchdog]
4+
5+
==== Description
6+
7+
Verify that a system's watchdog trips and successfully reboots the
8+
system back to a working state if a lockup occurs.
9+
10+
This is tested by using the Linux kernel's `test_lockup` module to
11+
inject a hard lockup (i.e., blocking servicing of all interrupts) on
12+
all CPU cores that lasts for twice as long as the watchdog's reported
13+
timeout.
14+
15+
==== Topology
16+
17+
image::topology.svg[Watchdog reset on system lockup topology, align=center, scaledwidth=75%]
18+
19+
==== Sequence
20+
21+
. Set up topology and attach to target DUT
22+
. Verify the presence of a watchdog device
23+
. Verify the presence of the test_lockup module
24+
. Trigger a hard lockup on all CPU cores
25+
. Wait for the watchdog to trip
26+
. Verify that the system reboots
27+
28+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
"""Watchdog reset on system lockup
3+
4+
Verify that a system's watchdog trips and successfully reboots the
5+
system back to a working state if a lockup occurs.
6+
7+
This is tested by using the Linux kernel's `test_lockup` module to
8+
inject a hard lockup (i.e., blocking servicing of all interrupts) on
9+
all CPU cores that lasts for twice as long as the watchdog's reported
10+
timeout.
11+
12+
"""
13+
import base64
14+
import infamy
15+
import json
16+
import subprocess
17+
import time
18+
19+
with infamy.Test() as test:
20+
with test.step("Set up topology and attach to target DUT"):
21+
env = infamy.Env()
22+
target = env.attach("target", "mgmt")
23+
tgtssh = env.attach("target", "mgmt", "ssh")
24+
25+
with test.step("Verify the presence of a watchdog device"):
26+
wctl = tgtssh.run(["watchdogctl"], stdout=subprocess.PIPE)
27+
conf = json.loads(wctl.stdout)
28+
29+
dogs = [ dog for dog in conf.get("device", []) if dog.get("name", "") == "/dev/watchdog" ]
30+
if len(dogs) < 1:
31+
test.fail("No watchdog device available")
32+
else:
33+
dog = dogs[0]
34+
35+
print(f"Found {dog['name']} ({dog['identity']}), timeout:{dog['timeout']}s")
36+
37+
with test.step("Verify the presence of the test_lockup module"):
38+
if tgtssh.run(["modprobe", "-q", "-n", "test_lockup"]).returncode != 0:
39+
test.fail("test_lockup module is not available")
40+
41+
with test.step("Trigger a hard lockup on all CPU cores"):
42+
tgtssh.runsh(f"""
43+
lockup()
44+
{{
45+
# Give the SSH session some time to properly shut down
46+
sleep 3
47+
48+
sudo modprobe test_lockup \
49+
disable_irq=1 \
50+
all_cpus=1 \
51+
time_secs={dog['timeout'] * 2}
52+
}}
53+
54+
lockup </dev/null &>/dev/null &
55+
""")
56+
57+
with test.step("Wait for the watchdog to trip"):
58+
time.sleep(dog["timeout"])
59+
60+
with test.step("Verify that the system reboots"):
61+
infamy.util.wait_boot(target, env)
62+
63+
test.succeed()

0 commit comments

Comments
 (0)