Watchdog reboot after wake form suspend

Hello,

I’m running Linux (4.14.170-3.0.4+gbaa6c24) on Colibri imx7d
(/etc/issue:TDX X11 2.6-snapshot \n \l)

I have configured the watchdog
(cat /proc/cmdline: rn5t618-wdt.timeout=8 … )
and feed it from an application by writing to /dev/watchdog through system call:
system(“echo 1 > /dev/watchdog”);
Stopping the watchdog in the program flow works well by writing the special character to /dev/watchdog:
system(“echo ‘V’ > /dev/watchdog”);
This way I can pause and resume the watchdog without problems.

However, when I set Linux in standby and pause the watchdog just before:
system(“echo ‘V’ > /dev/watchdog”);
system(“echo standby > /sys/power/state”);
then after wake from standby the watchdog causes a reboot immediately when it gets fed again by:
system(“echo 1 > /dev/watchdog”);
The system can wake from standby and is stable as long as the watchdog is not fed. As soon as I write to /dev/watchdog the reboot happens.

Am I missing something in the combination between watchdog and standby? Does the watchdog need some special disabling before or re-init after the standby?

Many thanks for your suggestions.
Otmar

Correction: stopping and trying to restart the watchdog leads always to reboot.
Watchdog is configured, and after system startup cyclically fed. Then watchdog is paused by writing ‘V’ to /dev/watchdog When writing again anything but ‘V’ to /dev/watchdog the reboot happens. It is independent of system standby.

To update my question: Is it possible to pause and resume the watchdog? If so, what needs to be done?

Many thanks,
Otmar

Dear @Otmar@hexagon,

Thank you for contacting Toradex.

We are currently looking into your issue.

Best Regards
Kevin

I’ve done a quick watchdog test using TDX Wayland with pre-built XWayland 5.2.0-devel-20210409+build.272 (dunfell) Colibri-iMX7-eMMC_Reference-Minimal-Image.

It behaves as expected. Writing “1” to /dev/watchdog after writing ‘V’ to the same file does not causing immediate reboot. It just re-enables watchdog and reboot happens only if /dev/watchdog is not touched for specified period.

Hello Alex,

thanks for the verification. Do you know whether this image is using the internal watchdog of imx7 or an external one?

My image uses the external Ricoh RN5T657 PMIC, as pointed out on this page:
https://developer.toradex.com/knowledge-base/watchdog-linux
We are currebtly trying to switch to the internal watchdog, but had some trouble getting it to correctly reboot the system.

Best regards,
Otmar

Dear @Otmar@hexagon,

the internal watchdog cannot be used due to an errata in the SoC.

More information about it can be found here:

iMX7 Errata

Best Regards
Kevin

Kevin, ah, yes, that is why we could not get the reboot to work with the internal watchdog.

Eventually we got the external watchdog stop and restart to work. It took some changes to the watchdog driver. Not sure, why it would not work out-of-the-box in our image.

Many thanks for looking into this issue.
Otmar

Dear @Otmar@hexagon,

I am glad that your question has been answered.

I wish you a nice day.

Best Regards
Kevin

Hi @Otmar@hexagon

Usually the Watchdog is not meant for stopping after the on trigger and should always lead to reset in case of not writing to it periodically.

Best regards,
Jaski

Hello Jaski,
agreed, but, unfortunately, this conflicts with the feature request that our device shall be sometimes in suspend state. During suspend there is no process active to toggle the watchdog. So either the WD has an input to detect low power mode and stop counting, or WD has a pause/resume feature. Otherwise, suspend state would always lead to reset.
Best regards,
Otmar

Hi @Otmar@hexagon

What is your requirement to have a watchdog?

Best regards,
Jaski

Hello Jaski,
unfortunately, we want to have both: the hardware watchdog that shall restart the system if the application fails to toggle it regularly, i.e. monitoring whether the application is alive. And, occasionally, put the device in standby, i.e. suspending Linux and with it our application - in which case we rather not want the watchdog to trigger a reboot.
In any case, we got it working now. In normal operation the WD triggers a reboot when our applications fails toggling it. Before Linux suspend we pause the WD and re-enable it after waking from suspend. This is not ideal, since it does not protect in case the application does not resume properly after system wake-up, but it seems good enough.
Best regards,
Otmar

Thanks for the information. Could you maybe share how did you do pause the Watchdog?

Thanks and best regards,
Jaski