linux icon indicating copy to clipboard operation
linux copied to clipboard

ASoC: SOF: (Intel HDA) Add support for DSPless debug mode

Open ujfalusi opened this issue 3 years ago • 13 comments

Replacing #3958, now with the correct branch!

Hi,

this series will enable the use of the SOF Linux stack without DSP offloading.

In this mode no firmware loading will happen, the topology parsing is going to be reduced to only look for the DAI widget(s) and the IPC dependent callbacks are going to be ignored.

This mode can give another level of hardware verification on platforms where the DSP can be ignored and the audio interfaces can be tested directly.

On Intel platforms we can use this mode to verify programming flows against the legacy HDA stack if there is a need to debug in that level and don't have the DSP programming sequences interfering.

The use of DSPless mode is governed by the SOF_DBG_DSPLESS_MODE flag which is only going to be set if the user sets sof_debg=0x8000 and the platform advertises that the DSPless mode is supported on them.

ujfalusi avatar Oct 26 '22 08:10 ujfalusi

Changes since v1:

  • Use sdev->dspless_mode_selected runtime for decisions instead of the sof_debug flag
  • all minor comments addressed with the exception of the use of a temporary tplg pointer

ujfalusi avatar Oct 26 '22 08:10 ujfalusi

Changes since v2:

  • set constraint on the supported formats for HDA in DSPless mode: Only S16 and S32 formats are supported (S24_LE is not supported).

ujfalusi avatar Oct 26 '22 11:10 ujfalusi

Changes since v3:

  • do not allow DSPless mode to be enabled if the NOCODEC mode is selected
  • Do not connect non HDA DAIs to allow mixed topology loading but make sure that the PCMs with non HDA DAIs are not usable by user.
  • Use the correct CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC in hda-dai.c

ujfalusi avatar Oct 27 '22 11:10 ujfalusi

  • do not allow DSPless mode to be enabled if the NOCODEC mode is selected

This needs to be platform-dependent @ujfalusi. If we hard-code this we are going to un-hard-code it soon.

plbossart avatar Oct 27 '22 12:10 plbossart

Changes since v4:

  • Lift additional restriction in core on the DSPless mode (NOCODEC and INTEL_HDA dai)
  • Introduce hda_get_interface_mask() in intel/hda.c to get an interface mask about the currently supported interfaces
  • the mask is Intel audio IP and DSPless mode dependent.
  • Only do discovery of I2S, DMIC and SDW if they are supported.

The only issue with the implementation is that if the DSPless mode is selected and also the NOCODEC is forced we will end up with a card which is not usable as nocodec topologies usually falling back to use SSP and DMIC and they are not usable without DSP.

Anyways, this PR works OK on UP2 when using the pcm512x ACPI patching and the resulting card will fall back to a generic HDA card:

[12958.191985] sof-audio-pci-intel-apl 0000:00:0e.0: Switching to DSPless mode
...
[12958.249559] snd_sof:sof_machine_register: sof-audio-pci-intel-apl 0000:00:0e.0: created machine skl_hda_dsp_generic
[12958.249580] snd_sof_pci:sof_pci_probe_complete: sof-audio-pci-intel-apl 0000:00:0e.0: Completing SOF PCI probe
[12958.267497] snd_sof:snd_sof_load_topology: sof-audio-pci-intel-apl 0000:00:0e.0: loading topology:intel/sof-tplg/sof-hda-generic-idisp.tplg

and

# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sofhdadsp [sof-hda-dsp], device 1: HDMI1 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 2: HDMI2 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 3: HDMI3 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

ujfalusi avatar Oct 28 '22 12:10 ujfalusi

@ujfalusi we're going to need some more time to review the last patches, so can we push the initial 13-odd patches in a separate PR to reduce the volume of patches to carry in this draft?

I have separated the ops optionality patches s they are one topic (but in itself it does not have much reason to exist): https://github.com/thesofproject/linux/pull/3986

ujfalusi avatar Nov 02 '22 11:11 ujfalusi

@ujfalusi can you rebase so that we look at the latest and greatest code on this branch?

plbossart avatar Nov 07 '22 17:11 plbossart

Changes since v5:

  • rebased
  • Separated the skip unsupported interfaces from the DSPless mode patch to make it easier to focus on the real changes.

ujfalusi avatar Nov 08 '22 08:11 ujfalusi

@ujfalusi would you be able to rebase this PR on top of #/3972? It'd be good if @ranj063 and I can take a look tomorrow morning (Nov 18) before the week-end and the Turkey break. Thanks!

plbossart avatar Nov 17 '22 19:11 plbossart

https://github.com/thesofproject/linux/pull/3972 is merged, please rebase @ujfalusi

plbossart avatar Nov 18 '22 00:11 plbossart

Changes since v6:

  • reworked on top of sof-dev with #3972 merged
  • Things might need to be revisited since #3972 made IPC mode semi mandatory for the HDA code.
  • If there is no swidget allocated, it implies that no IPC is used, which is the case of the DSPless mode

ujfalusi avatar Nov 18 '22 12:11 ujfalusi

Oops, something is not quite how it should be in DSP mode...

ujfalusi avatar Nov 18 '22 14:11 ujfalusi

Changes since v7:

  • DSP mode fixed (broke due to returning uninitialized 'ops' from hda_dai_get_ops() on the second call)
  • dropped the 'error:' prefix from a print in core

ujfalusi avatar Nov 18 '22 14:11 ujfalusi

Changes since v8:

  • separate patch to correct the hda-stream use before NULL check of hstream
  • use dspless_mode_selected flag instead of !swidget check where it is possible to make the code easier to follow
  • minor comments addressed

ujfalusi avatar Nov 21 '22 14:11 ujfalusi

and oh time to undraft this PR I think

ranj063 avatar Nov 28 '22 18:11 ranj063

@ujfalusi can you please rebase and solve conflicts?

plbossart avatar Nov 29 '22 17:11 plbossart

Changes since v9:

  • patch for sof/pm.c dropped
  • patches to allow DSPless mode on all Intel platforms with HDA support added
  • Commit message updates
  • comment update for the nonatomic flag revised
  • rebased on topic/sof-dev (obviously)

ujfalusi avatar Dec 01 '22 10:12 ujfalusi

Changes since v10:

  • Update the correct comment about the nonatomic flag
  • Fix the typo in the comment for skipping sndw if it is not available on the platform.

ujfalusi avatar Dec 01 '22 14:12 ujfalusi

Changes since v11:

  • correct the use_count test which was carried over from an old revision (in patch 2).

ujfalusi avatar Dec 01 '22 19:12 ujfalusi