Commit 1dc8e8c5 authored by Andy Ross's avatar Andy Ross Committed by Anas Nashif
Browse files

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: default avatarAndy Ross <andrew.j.ross@intel.com>
parent 97fb8fa8
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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")
        if not reset_logged:
            sys.stdout.write("===\n=== [ADSP Device Reset?]\n===\n")
            sys.stdout.flush()
        time.sleep(1)
        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.