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 <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2022-07-01 01:47:30 +00:00 committed by Carles Cufí
parent ef4cd76970
commit 08baba2520

View file

@ -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")