Skip to content

Commit 7014c34

Browse files
danieldegrassecfriedt
authored andcommitted
app: smc: pytest: e2e_smoke: add "dirty reset" test
Add test that resets the SMC via the DMC reset line, which is considered a "dirty reset" as the SMC and tt-kmd are not involved. Verify the SMC can boot after this reset Also fix import order of modules used in test to appease pylint Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 11f2e4a commit 7014c34

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

app/smc/pytest/e2e_smoke.py

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
import logging
77
import os
88
import subprocess
9-
10-
import pyluwen
11-
import pytest
129
import re
1310
import sys
1411
import time
15-
1612
from pathlib import Path
17-
from twister_harness import DeviceAdapter
1813

19-
logger = logging.getLogger(__name__)
14+
import pyluwen
15+
import pytest
16+
from twister_harness import DeviceAdapter
2017

2118
sys.path.append(str(Path(__file__).parents[3] / "scripts"))
19+
from pcie_utils import rescan_pcie
20+
import dmc_reset
2221

23-
from pcie_utils import rescan_pcie # noqa: E402
22+
logger = logging.getLogger(__name__)
2423

2524
SCRIPT_DIR = Path(os.path.dirname(os.path.abspath(__file__)))
2625

@@ -186,3 +185,41 @@ def test_smi_reset():
186185

187186
logger.info(f"'tt-smi -r' failed {fail_count}/{total_tries} times.")
188187
assert fail_count == 0, "'tt-smi -r' failed a non-zero number of times."
188+
189+
190+
@pytest.mark.flash
191+
def test_dirty_reset():
192+
"""
193+
Checks that the SMC comes up correctly after a "dirty" reset, where the
194+
DMC resets without the SMC requesting it. This is similar to the conditions
195+
that might be encountered after a NOC hang
196+
"""
197+
total_tries = 10
198+
timeout = 60 # seconds to wait for SMC boot
199+
fail_count = 0
200+
201+
# Use dmc-reset script as a library to reset the DMC
202+
def args():
203+
return None
204+
205+
args.config = dmc_reset.DEFAULT_DMC_CFG
206+
args.debug = 0
207+
args.openocd = dmc_reset.DEFAULT_OPENOCD
208+
args.scripts = dmc_reset.DEFAULT_SCRIPTS_DIR
209+
args.jtag_id = None
210+
args.hexfile = None
211+
for i in range(total_tries):
212+
logger.info(f"Iteration {i}:")
213+
ret = dmc_reset.reset_dmc(args)
214+
if ret != os.EX_OK:
215+
logger.warning(f"DMC reset failed on iteration {i}")
216+
fail_count += 1
217+
continue
218+
ret = dmc_reset.wait_for_smc_boot(timeout)
219+
if ret != os.EX_OK:
220+
logger.warning(f"SMC did not boot after dirty reset on iteration {i}")
221+
fail_count += 1
222+
continue
223+
logger.info(f"Iteration {i} of dirty reset test passed")
224+
logger.info(f"dirty reset failed {fail_count}/{total_tries} times.")
225+
assert fail_count == 0, "dirty reset failed a non-zero number of times."

scripts/dmc_reset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def wait_for_smc_boot(timeout):
247247
if remaining == 0:
248248
print(f"Card did not reappear after {timeout} seconds)")
249249
return os.EX_UNAVAILABLE
250+
return os.EX_OK
250251

251252

252253
def main():

0 commit comments

Comments
 (0)