From 08baba2520e9a0a3bdae33db961ffd6c18608b6d Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 1 Jul 2022 01:47:30 +0000 Subject: [PATCH] soc/intel_adsp: cavstool: add support for DSP power state: D3 Change some behaviors when --log-only is passed in order to add support for DSP power state: D3. This makes it possible to keep `cavstool --log-only` running permanently in the "real-world" use case where the Linux kernel loads the firmware and powers down audio when not in use. More specifically: - Do not disable D3 when using --log-only. - Wait forever for the FW at boot time. - Check live status when an invalid IPC is received and wait forever if not alive. Signed-off-by: Marc Herbert --- soc/xtensa/intel_adsp/tools/cavstool.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/soc/xtensa/intel_adsp/tools/cavstool.py b/soc/xtensa/intel_adsp/tools/cavstool.py index bd8cd01b2f..344919f51f 100755 --- a/soc/xtensa/intel_adsp/tools/cavstool.py +++ b/soc/xtensa/intel_adsp/tools/cavstool.py @@ -230,10 +230,10 @@ def map_regs(): else: log.warning(found_msg + ", unloading module") runx(f"rmmod -f {mod}") - - # Disengage runtime power management so the kernel doesn't put it to sleep - with open(f"{pcidir}/power/control", "w") as ctrl: - ctrl.write("on") + # Disengage runtime power management so the kernel doesn't put it to sleep + log.info(f"Forcing {pcidir}/power/control to always 'on'") + with open(f"{pcidir}/power/control", "w") as ctrl: + ctrl.write("on") # Make sure PCI memory space access and busmastering are enabled. # Also disable interrupts so as not to confuse the kernel. @@ -633,6 +633,15 @@ def ipc_command(data, ext_data): hda_str.mem.seek(0) else: log.warning(f"cavstool: Unrecognized IPC command 0x{data:x} ext 0x{ext_data:x}") + if not fw_is_alive(): + if args.log_only: + log.info("DSP power seems off") + wait_fw_entered(timeout_s=None) + else: + log.warning("DSP power seems off?!") + time.sleep(2) # potential spam reduction + + return dsp.HIPCTDR = 1<<31 # Ack local interrupt, also signals DONE on v1.5 if cavs18: @@ -658,7 +667,7 @@ async def _main(server): log.info(f"Detected cAVS {'1.5' if cavs15 else '1.8+'} hardware") if args.log_only: - wait_fw_entered() + wait_fw_entered(timeout_s=None) else: if not fw_file: log.error("Firmware file argument missing")