From 1ac2a435750bdb7b9be769d59d9d6a104bf39e5e Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Fri, 7 Aug 2026 21:59:15 +0000 Subject: [PATCH] [nexthop] watchdog implementation: temporary workaround to arm 2 watchdogs #### Why I did it This is a temporary workaround to arm hardware watchdog that triggers power cycle. The workaround is needed until full SW support of both watchdog 1 and 2. Also updates the arm value to 300 seconds as this is what [platform_tests /test_hw_watchdog.py](https://github.com/sonic-net/sonic-mgmt/blob/7a73917c813d20b62e72e47a15d9c4825fe8c2f8/tests/platform_tests/test_hw_watchdog.py#L90) expects ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Arm watchdog 2 by writing to `0x1d8` register before arming watchdog 1. #### How to verify it Arm watchdog using `watchdogutil`. sonic-mgmt test `tests/platform_tests/api/test_watchdog.py` #### Which release branch to backport (provide reason below if selected) - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [x] 202511 - [x] 202512 - [x] 202605 - [ ] 202608 Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): Failure type: #### Tested branch - [x] master - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [x] 202511 - [x] 202512 - [x] 202605 - [ ] 202608 - [ ] N/A #### Test result ``` sudo watchdogutil status sudo watchdogutil arm -s 10 sudo watchdogutil status sudo watchdogutil disarm ``` #### Description for the changelog #### Link to config_db schema for YANG module changes Signed-off-by: Sonic Build Admin #### A picture of a cute animal (not mandatory but encouraged) --- .../common/sonic_platform/watchdog.py | 8 +++++++- .../test/unit/sonic_platform/test_watchdog.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-nexthop/common/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-nexthop/common/sonic_platform/watchdog.py index 10c03aede1..4507278fa6 100644 --- a/platform/broadcom/sonic-platform-modules-nexthop/common/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-nexthop/common/sonic_platform/watchdog.py @@ -15,7 +15,7 @@ # Watchdog punching is paused if file is present _WATCHDOG_PAUSE_FILE_PATH = Path("/var/lock/pddf-locks/watchdog.pause") # How long the watchdog is armed for by the watchdog.timer -_WATCHDOG_PUNCH_DAEMON_ARM_SECONDS = 360 +_WATCHDOG_PUNCH_DAEMON_ARM_SECONDS = 300 def _pause_watchdog_punching(duration: datetime.timedelta) -> None: @@ -126,6 +126,12 @@ def _do_real_arm(self, seconds: int) -> int: self._toggle_watchdog_counter_enable(True) self._toggle_watchdog_reboot(True) self._update_watchdog_countdown_value(milliseconds=seconds*1_000) + # TODO: workaround: arm watchdog 2 to trigger watchdog 1 + fpga_lib.write_32( + pci_address=self.fpga_pci_addr, + offset=0x1d8, + val=0x80000001, + ) except Exception as e: _logger.log_error(f"cannot arm watchdog: {e}") return -1 diff --git a/platform/broadcom/sonic-platform-modules-nexthop/test/unit/sonic_platform/test_watchdog.py b/platform/broadcom/sonic-platform-modules-nexthop/test/unit/sonic_platform/test_watchdog.py index 6d48e5e55e..5a882cd441 100644 --- a/platform/broadcom/sonic-platform-modules-nexthop/test/unit/sonic_platform/test_watchdog.py +++ b/platform/broadcom/sonic-platform-modules-nexthop/test/unit/sonic_platform/test_watchdog.py @@ -195,6 +195,7 @@ def test_arm_seconds_out_of_bound_error(self, seconds): def test_arm_should_update_counter( self, + watchdog_module, mock_update_watchdog_countdown_value, mock_toggle_watchdog_reboot, mock_toggle_watchdog_counter_enable, @@ -211,7 +212,9 @@ def test_arm_should_update_counter( ) # Act - actual_return_value = self.watchdog.arm(timeout_seconds) + # TODO: workaround: arm watchdog 2 to trigger watchdog 1 + with patch.object(watchdog_module.fpga_lib, "write_32", autospec=True): + actual_return_value = self.watchdog.arm(timeout_seconds) # Assert assert (