Repository navigation
Conversation
PR Summary by Qodovigil: hardware watchdog support for HiSilicon NVR images
AI Description
Merge Risk
|
Code Review by Qodo
1. Untested watchdog reaches NVR images
|
…iled disarm is not a stop From the review of OpenIPC#3029: - The supervisor broke out under sysupgrade's lock without disarming a watchdog the last vigild left armed, and stop_vigil skipped the stop when neither vigild nor the supervisor was left: the flash had a dog counting under it. Each break now disarms it, and stop_vigil runs the stop while /var/run/vigild.watchdog is there. - wdog_release removed the mark and reported success when the disarm failed. It keeps the mark and fails; the stop says FAIL, and sysupgrade refuses the upgrade before writing anything rather than flash under it. - A feed that failed during the restart wait fell back to sleeping the whole wait unfed. It now disarms the dog and sleeps only what is left. - supervising(): a pidfile naming a killed supervisor no longer prints "can't open /proc/<pid>/cmdline" (the failed redirection escaped its 2>/dev/null). Checked in qemu-bench's hi3536dv100 with vigil nvr-dev: a crash under the lock disarms ("upgrade: ... disarmed", HiDog "Watchdog is disabled!"); a crash, the fed wait, then a stop disarms; with vigild and the supervisor killed and the device held elsewhere the stop fails and keeps the mark, and once it is free a stop disarms it. The functions alone under busybox ash with /dev/full: a failed feed disarms and sleeps the rest.
vigild now arms /dev/watchdog (watchdog in /etc/vigil.yaml), feeds it
while its threads turn, and keeps /var/run/vigild.watchdog while it is
armed; a stop it did not ask for disarms it with the magic close. A
vigild that crashed or was killed leaves the dog counting where the
driver has the magic close (the HiSilicon ones), and the supervisor's
waits before a restart (5, 30, 120 s) can outlast its timeout.
So when the mark is there the supervisor feeds the dog through the wait,
on a descriptor of its own that the next vigild takes over; it disarms
it (open, 'V', close) when it gives up after a crash loop -- a board that
rebooted forever would be no easier to reach -- when vigild ends without
a crash, and when it is stopped: a vigild it had to kill under
sysupgrade must not leave a dog that resets the board mid-flash. Without
the mark nothing is opened: that would arm a dog nobody asked for.
Checked in qemu-bench's hi3536dv100 machine (no watchdog model: the
driver's messages): a crash leaves it running and the supervisor holds
it through the wait; a stop during that wait disarms it ("Watchdog is
disabled!"); the feeding and the release on the image's busybox ash.
vigil's vigild feeds the hardware watchdog while its threads turn, but load_hisilicon loads open_wdt and removes it again at once, so there is no /dev/watchdog. On a vigil image (/usr/bin/vigild there) it now stays; its kernel thread feeds the dog until vigild opens the device. Other images load and remove it as before. openhisilicon's hi3536dv100 hi_wdt.c is still the vendor's: a "V" before the close leaves the dog armed and unfed, while a plain close hands it back to the kernel thread -- the magic close inverted, so vigild's clean stop would reset the board and a crash would never -- and the counter is loaded with a whole margin, which the SP805 runs twice. The hi3520dv200 copy in the same tree has those fixed (as hi3516cv200's and cv100's), for the same SP805 and clock gate; vigil images build it at hi3536dv100's addresses (0x12070000, 0x12050000), with a check that the substitution took. The fix belongs in openhisilicon, after which this hook goes. Built (hi3536dv100_lite, kernel 4.9.37) and loaded in qemu-bench's hi3536dv100 machine: /dev/watchdog, vigild arms it with the magic close supported; a clean stop says "Watchdog is disabled!", a crash "Unexpected close, watchdog left running!". The machine has no watchdog model, so no reset was seen; that needs a board.
vigil's vigild feeds the hardware watchdog while its threads turn, and hi3520dv200 has none: the vendor osdrv ships no wdt module and hisilicon-opensdk builds openhisilicon's (the fixed driver: a real magic close, a real timeout, the kernel thread feeding only until the first open) but does not install it. On vigil images it is installed as wdt.ko, and load_hisilicon loads it when it is there (and removes it with the rest); other hi3520dv200 images are unchanged. Built (hi3520dv200_lite): wdt.ko is the fixed driver (3.0.8) and load_hisilicon loads it. Not run: qemu-bench's hi3520dv200 machine has no watchdog model, and no board was at hand.
…con, not a sed at build The vigil images built hi3520dv200's fixed hi_wdt.c at hi3536dv100's addresses with a sed over the source at patch time. The same file is now proposed for openhisilicon itself (OpenIPC/openhisilicon#320); with it merged, the package's pin carries the fix for every hi3536dv100 image and this hook goes.
…iled disarm is not a stop From the review of OpenIPC#3029: - The supervisor broke out under sysupgrade's lock without disarming a watchdog the last vigild left armed, and stop_vigil skipped the stop when neither vigild nor the supervisor was left: the flash had a dog counting under it. Each break now disarms it, and stop_vigil runs the stop while /var/run/vigild.watchdog is there. - wdog_release removed the mark and reported success when the disarm failed. It keeps the mark and fails; the stop says FAIL, and sysupgrade refuses the upgrade before writing anything rather than flash under it. - A feed that failed during the restart wait fell back to sleeping the whole wait unfed. It now disarms the dog and sleeps only what is left. - supervising(): a pidfile naming a killed supervisor no longer prints "can't open /proc/<pid>/cmdline" (the failed redirection escaped its 2>/dev/null). Checked in qemu-bench's hi3536dv100 with vigil nvr-dev: a crash under the lock disarms ("upgrade: ... disarmed", HiDog "Watchdog is disabled!"); a crash, the fed wait, then a stop disarms; with vigild and the supervisor killed and the device held elsewhere the stop fails and keeps the mark, and once it is free a stop disarms it. The functions alone under busybox ash with /dev/full: a failed feed disarms and sleeps the rest.
915fe49 to
8866e5c
Compare
vigil's vigild can now feed the board's hardware watchdog while its threads keep running (
watchdogin/etc/vigil.yaml, on by default). On the HiSilicon NVR images there was no usable/dev/watchdogyet; this PR adds one and makes the init script safe around it.S95vigil (
general/package/vigil/files/S95vigil). vigild arms the watchdog itself and keeps/var/run/vigild.watchdogwhile it is armed; a stop it asked for disarms it with the magic close. A vigild that crashed or was killed leaves the dog counting on drivers that have the magic close (the HiSilicon ones), and the supervisor's waits before a restart (5, 30, 120 s) can be longer than the timeout. So while the mark is there the supervisor:V, close) when it gives up after a crash loop, when vigild ends without a crash, and when it is stopped. A board that reboots forever is no easier to reach, and a stop under sysupgrade must not reset the board mid-flash.Without the mark it opens nothing, so it never arms a watchdog nobody asked for.
hi3536dv100.
load_hisiliconloadedopen_wdtand removed it again at once. On a vigil image (/usr/bin/vigildpresent) it now stays; the driver's kernel thread feeds the dog until vigild opens the device. Other images are unchanged. The driver itself is fixed in openhisilicon (OpenIPC/openhisilicon#320: the magic close was inverted, and the timeout was doubled). Master'shisilicon-opensdkpin (d115067) already includes it, so hi3536dv100 needs no package change here.hi3520dv200. The vendor osdrv ships no watchdog module. hisilicon-opensdk builds openhisilicon's (already the fixed driver) but did not install it. On vigil images it is now installed as
wdt.koandload_hisiliconloads it when it is there. Other hi3520dv200 images are unchanged.Tested:
hi3536dv100_liteandhi3520dv200_litebuild. After the bump,hi3536dv100_lite'sopen_wdt.kois the fixed driver (@Hi3536v100).hi3536dv100machine (no watchdog model there, so only the driver's messages):Needs a board: an actual reset after the timeout, on hi3536dv100 and hi3520dv200.
Until vigil main has the watchdog: vigil's watchdog support is on its integration branch now, not yet in main, which these images build. Until it reaches main, vigild never creates the mark, so S95vigil changes nothing on a running image. On hi3536dv100 the driver's kernel thread then keeps feeding
open_wdt, which is now left loaded.