From 1dc8e8c5a03e7cc5e47781ba1523c5e62a451cd0 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Wed, 1 Sep 2021 16:23:45 -0700 Subject: [PATCH] soc: intel_adsp: Handle reset better in adsplog.py When working with the SOF kernel driver, it likes to shut down the DSP on error. That means there is a very small window in which to catch any log output, even with a whiteboxed kernel. So we should be polling much faster (10 Hz) for changes when we detect a reset. Also, don't repeatedly log the device reset detection, it spams the console badly when we crank up the rate. Just log it once and then stay silent until we see output. Signed-off-by: Andy Ross --- boards/xtensa/intel_adsp_cavs15/tools/adsplog.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/boards/xtensa/intel_adsp_cavs15/tools/adsplog.py b/boards/xtensa/intel_adsp_cavs15/tools/adsplog.py index c5efb4cc050..a7446ad269f 100755 --- a/boards/xtensa/intel_adsp_cavs15/tools/adsplog.py +++ b/boards/xtensa/intel_adsp_cavs15/tools/adsplog.py @@ -42,6 +42,8 @@ LOG_OFFSET = WIN_OFFSET + WIN_IDX * WIN_SIZE mem = None sys_devices = "/sys/bus/pci/devices" +reset_logged = False + for dev_addr in os.listdir(sys_devices): class_file = sys_devices + "/" + dev_addr + "/class" pciclass = open(class_file).read() @@ -93,6 +95,7 @@ def read_slot(slot, mem): return (sid, msg.decode(encoding="utf-8", errors="ignore")) def read_hist(start_slot): + global reset_logged id0, msg = read_slot(start_slot, mem) # An invalid slot zero means no data has ever been placed in the @@ -101,11 +104,15 @@ def read_hist(start_slot): # been observed to hang the flash process (which I think can only # be a hardware bug). if start_slot == 0 and id0 < 0: - sys.stdout.write("===\n=== [ADSP Device Reset]\n===\n") - sys.stdout.flush() - time.sleep(1) + if not reset_logged: + sys.stdout.write("===\n=== [ADSP Device Reset?]\n===\n") + sys.stdout.flush() + reset_logged = True + time.sleep(0.1) return (0, 0, "") + reset_logged = False + # Start at zero and read forward to get the last data in the # buffer. We are always guaranteed that slot zero will contain # valid data if any slot contains valid data.