# Watchdog

Source: [https://docs.qualcomm.com/doc/80-88500-4/topic/68_Watchdog.html](https://docs.qualcomm.com/doc/80-88500-4/topic/68_Watchdog.html)

A watchdog (WD or WDOG) is a fixed-length counter that enables a system to recover from an unexpected hardware or software catastrophe.

Unless the system periodically resets the watchdog timer, the watchdog timer assumes a catastrophe and resets the subsystem or the entire system depending on which watch dog fires.

In general, there are multiple types of watchdog implementations, hardware and software watchdogs, bark, bite, and so on.

Table : Types of Watchdog

| Type of watchdog | Timeout duration | Owner | Expires during | Result |
| --- | --- | --- | :--- | --- |
| Nonsecure (NS) WD bark | 11 s | HLOS | IRQ to HLOS | HLOS falls to Panic |
| Nonsecure (NS) WD bite | 12 s | HLOS | FIQ to TZ | TZ asserts PS\_HOLD |
| Secure WD bark | 6 s | TZ | FIQ to TZ | TZ just pets secure WD |
| Secure WD bite | 22 s | TZ | asserting PS\_HOLD | PMIC resets the system |
| AOP hardware WD bark | 10 ms | AOP | IRQ to AOP | AOP falls to error fatal |
| AOP hardware WD bite | 30 ms | AOP | IRQ to application processor | HLOS falls to Panic |
| Software WD timeout | 10 s | User tasks on SS | calls Error fatal | SS Error fatal1 2 |
| (SS) hardware WD bark | 2.25 s | Dog task on SS | FIQ to error handler | SS Error fatal/pet WD1 2 |
| (SS) Nonmaskable interrupt (NMI) due to HW WD | 2.4 s | Dog task on SS | NMI to SS | NMI on SS1 |
| (SS) Hardware WD bite | 2.5 s | Dog task on SS | IRQ to HLOS | SS hardware reset1 |

Error fatal, NMI, or hardware reset on subsystem may result in a panic or do a subsystem restart (SSR) depending on the SSR configuration.

Software WD is available on both application DSP (ADSP) and compute DSP (CDSP).

Both software and hardware watchdogs are used in the system.

- The software watchdog is not implemented in all the subsystems. For example, resource power manager hardening (RPMh) does not have software watchdogs, while low-power audio subsystem (LPASS) and modem peripheral subsystem (MPSS) implement software watchdog.
- The hardware watchdog module is a piece of hardware that is used to ensure that the processor is not stuck or overloaded. It consists of a timer that counts down from a predetermined value. If the timer is not reset (also known as a dog\_kick or petting the dog or servicing the dog) by the corresponding CPU core, it eventually counts to 0 and triggers a watchdog timeout.

## Watchdog for application processor CPU

- Non-secure hardware watchdog
    - A timer event fires on HLOS every 10-seconds to pet non-secure WD hardware. If HLOS does not pet it for 11-seconds, non-secure WD bark fires and HLOS needs to handle it. If HLOS can handle it, HLOS goes into Panic mode.
    - If HLOS cannot handle non-secure WD bark, then non-secure WD bite fires to TrustZone (TZ). TZ then falls into fatal error.
- Secure hardware watchdog
    - Secure WD bark fires every 6-seconds to TZ as fast interrupt request (FIQ), and the FIQ handler in TZ pets the secure WD hardware. This is not any error or fatal.
    - If TZ cannot handle secure WD bark for 22-seconds, then secure WD bite expires. It asserts PS\_HOLD in PMIC and eventually the entire system is reset.
- Other hardware watchdog characteristics
    - The hardware WD is automatically stopped when all cores on application processor CPU go into sleep or the hardware debugger is attached to core0.
    - The hardware WD can be disabled by one of the following methods. This disables both secure and nonsecure watchdog. (Watchdog enabled: enable=1, Watchdog disabled: enable=0).
        - Add the kernel command line option

                msm_watchdog.enable=0.Copy to clipboard
        - Turn off the kernel feature CONFIG\_MSM\_WATCHDOG (make kernelconfig, system type submenu, down toward the bottom)
        - If the watchdog is enabled at bootup (enable=1):

                echo 1 > /sys/bus/platform/drivers/msm_watchdog/17C10000.qcom,wdt/disable
                echo 1 > /sys/bus/platform/drivers/msm_watchdog/17C10000.qcom,wdt/disableCopy to clipboard

## MSM watchdog test module

The MSM watchdog test module is a kernel module (compiled as a .ko file) that can be used to trigger applications processor watchdog barks, nonsecure apps processor watchdog bites, and secure apps processor watchdog bites on demand. It is mainly used to verify crash dump collection in these three reset scenarios.

The module is named as msm\_watchdog\_test\_module.ko and is delivered externally as part of the APSS release,

The msm\_watchdog\_test\_module and `msm_watchdog_test.sh` script should reside in the directory at build/vendor/qcom/proprietary/kernel-tests-internal/watchdog

1. Push the module to a desired location on the device to test by using the following ADB command:

        >adb root
        >adb push msm_watchdog_test_module.ko /data/msm_watchdog_test_module.ko
        >adb shell insmod /data/msm_watchdog_test_module.koCopy to clipboard
2. Invoke the module using one of the following commands:
    - Nonsecure watchdog bark:

            echo 1 > /sys/module/msm_watchdog_test_module/parameters/apps_wdog_barkCopy to clipboard
    - Nonsecure watchdog bite:

            echo 1 > /sys/module/msm_watchdog_test_module/parameters/apps_wdog_biteCopy to clipboard
    - Secure watchdog bite:

            echo 1 > /sys/module/msm_watchdog_test_module/parameters/sec_wdog_biteCopy to clipboard
    - Secure watchdog bite from TZ by secure channel manager (SCM) call:

            echo 1 > /sys/module/msm_watchdog_test_module/parameters/sec_wdog_scmCopy to clipboard

- **[Watchdog for always-on processor](https://docs.qualcomm.com/doc/80-88500-4/topic/69_Watchdog_for_AOP.html)**  

There is no software watchdog (WD) for always-on processor (AOP). The hardware WD is     automatically stopped when the hardware debugger is attached to AOP.
- **[Watchdog for other subsystems](https://docs.qualcomm.com/doc/80-88500-4/topic/70_Watchdog_for_other_subsystems.html)**  

There are software and hardware watchdogs on modem peripheral subsystem (MPSS),     application DSP (ADSP), and compute DSP (CDSP).

**Parent Topic:** [Debug](https://docs.qualcomm.com/doc/80-88500-4/topic/58_Debug.html)

Last Published: Aug 18, 2023

[Previous Topic
Log analysis](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/71_Log_analysis.md) [Next Topic
Watchdog for always-on processor](https://docs.qualcomm.com/bundle/publicresource/80-88500-4/topics/69_Watchdog_for_AOP.md)