Skip to content

[DNM] [TEST] ASoC: Intel: avs: Soundwire support - #6019

Draft
bardliao wants to merge 7 commits into
thesofproject:topic/sof-devfrom
bardliao:test-avs-sdw
Draft

bardliao wants to merge 7 commits into
thesofproject:topic/sof-devfrom
bardliao:test-avs-sdw

Conversation

@bardliao

@bardliao bardliao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

The RaptorLake-P and RaptorLake-M based platform used in Automotive area
do utilize SoundWire for streaming audio. This patchset brings such
support to the public domain.

If possible, I'd like the changes to go through Mark's tree.

As the patchset updates drivers/soundwire, I've decided to strip it off
any machine-boards and have here just the changes done to the main
soundwire driver and their user/usage. Machine boards for RPL-P/M will
follow in a separate set and do not touch drivers/soundwire stuff.

The reasoning behind modyfing the soundwire code:

Typically dai->startup() is responsible for checking if all the required
resources are available whereas dai->hw_params() is responsible for
configuring such resources. Existing code does the PDI assignment and
its configuration within one function - intel_hw_params(). The logical
split is not possible. The change provides functions that represent
such logical blocks: assign, release and config. Such division exists
already for the HDAudio interface, see sound/hda/core/stream.c

For the user i.e.: avs-driver (sound/soc/intel/avs) it also makes the
code very cohesive - aligns with that's done on the HDAudio side as all
the HDAudio streams are assignment during dai->startup() and configured
with dai->hw_params().

Also, the existing code fetches the PDIs based on pre-defined "dai_id".
That's not the case for the avs-driver. It simply asks: "is any PDI
free?" and assigns it for the substream if one is found.
No predefining. Again, this aligns with how HDAudio streaming is done.

avs-driver -only patches follow the three soundwire ones. First, they
extend the existing code so it can accommodate SDW interface. With that
done, laverage existing PCM code (sound/soc/intel/avs/pcm.c) and
soundwire-intel to implement DAI operations.

The library defines no stubs when it is disabled so the actual users
have to do it locally to allow the code to compilte or, guard the code
that does interact with soundwire with #if(s). Define simple wrappers to
make the life of soundwire-code users easier.

The change allows for a driver to build against SOUNDWIRE_INTEL=n whilst
still calling the stubs in its common code without compilation failing.
The driver needs not to flank its soundwire-code with #if(s) either.

Not all sdw_intel_xxx()s are part of drivers/soundwire. Some definitions
are located within sound/hda/core instead. With the wrappers done,
update Kconfig for sound/hda/core as currently the ACPI-related function
are compiled regardless if SOUNDWIRE_INTEL is selected or not. By being
dependent on SOUNDWIRE_INTEL those functions are compiled only if the
SoundWire was actually requested.

Cc: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Currently, PDIs are assigned upfront based on the DAI IDs. Some drivers
do not assign anything upfront and request a free PDI when streaming is
about to start.

Provide assign/release() functions to allow them to be assigned
dynamically. This also streamlines the process of assigning/releasing
PDIs with what is done in HDAudio library (sound/hda) for HDAudio
streams, see snd_hdac_stream_assign/release().

As resource availability-check is typically done during dai->startup()
whilst hardware/firmware configuration occurs on dai->hw_params(), add
sdw_intel_pdi_config() to maintain this logical split - assign on
start(), configure on hw_params(). Existing code does all of that in
intel_hw_params() so the logical split is not possible.

Cc: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Not every client of the soundwire-driver needs the secondary
soc-component and full range of DAIs immediately when initializing the
device. As function intel_register_dai() does all of that on top of
initializing PDIs, split it into two logical blocks to accommodate for
both approaches. In consequence, register_dai() callback becomes
optional.

To keep things in status quo for existing users, update
intel_link_startup() to call sdw_intel_init_pdis().

Cc: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Soundwire IRQ thread function requires passing irq as one of the
arguments, as we will want to call it in dsp_interrupt callback, it
needs to be passed throguh.

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
The SoundWire device is part of the Intel HDAudio PCI device. To support
transfer over SoundWire interface it has to be accounted for when
probing the parent device.

Most of the actual job is done by the SoundWire library which is already
part of the kernel. Utilize it in the core functions of the driver to
enumerate SoundWire component and service its interrupts.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
All the PCM operations are currently bundled together within the pcm.c
file regardless of which transfer type they cover. To allow for
splitting them, provide a header that exposes the common operations
outside.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Implement the back-end PCM operations for the SoundWire Link to support
data transfer over SoundWire interface. Most of the actual job is done
by the SoundWire library, thus code added here just invokes them in
correct order.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved teardown defects can leave dangling SoundWire runtime pointers and race with in-flight DSP IRQ handlers, risking NULL dereferences or use-after-free.

4 open issues
What changed in this PR

This PR adds SoundWire infrastructure to the Intel AVS audio driver for Raptor Lake-P/M automotive platforms. It separates PDI allocation from configuration and reuses AVS PCM handling; machine-board support is deferred to a separate patchset.

Changes:

  • Exposes SoundWire PDI assignment, release and configuration APIs.
  • Adds AVS SoundWire PCM operations, interrupt handling and power-management integration.
  • Updates shared interfaces and build configuration for optional SoundWire support.
File Description
sound/​soc/​intel/​Kconfig Adds optional AVS SoundWire configuration.
sound/​soc/​intel/​avs/​soundwire.h Declares SoundWire helpers and disabled-feature stubs.
sound/​soc/​intel/​avs/​soundwire.c Implements SoundWire lifecycle, interrupts and wake handling.
sound/​soc/​intel/​avs/​skl.c Updates the DSP interrupt callback signature.
sound/​soc/​intel/​avs/​registers.h Defines SoundWire interrupt registers and bits.
sound/​soc/​intel/​avs/​pcm.h Exposes shared PCM helpers and SoundWire stream state.
sound/​soc/​intel/​avs/​pcm.c Makes PCM helpers available to the SoundWire implementation.
sound/​soc/​intel/​avs/​pcm_sdw.c Adds SoundWire DAI operations and component registration.
sound/​soc/​intel/​avs/​path.c Supports SoundWire DMA connector identifiers.
sound/​soc/​intel/​avs/​mtl.c Updates the DSP interrupt callback signature.
sound/​soc/​intel/​avs/​messages.h Adds SoundWire DMA types.
sound/​soc/​intel/​avs/​Makefile Conditionally builds SoundWire implementation files.
sound/​soc/​intel/​avs/​loader.c Processes SoundWire wake events during firmware loading.
sound/​soc/​intel/​avs/​core.c Integrates SoundWire startup, teardown and power management.
sound/​soc/​intel/​avs/​cnl.c Dispatches SoundWire interrupts and wake events.
sound/​soc/​intel/​avs/​avs.h Adds SoundWire context and updates shared declarations.
sound/​soc/​intel/​avs/​apl.c Updates the DSP interrupt callback signature.
sound/​hda/​core/​Makefile Guards SoundWire ACPI object composition.
sound/​hda/​core/​Kconfig Adjusts SoundWire ACPI selection conditions.
include/​linux/​soundwire/​sdw_intel.h Exposes PDI configuration and initialization interfaces.
include/​linux/​soundwire/​sdw_cadence.h Publishes PDI structures and allocation APIs.
drivers/​soundwire/​intel.h Adds PDI initialization dispatch and permits optional DAI registration.
drivers/​soundwire/​intel.c Separates PDI initialization and exports configuration support.
drivers/​soundwire/​intel_auxdevice.c Initializes PDIs before registering DAIs.
drivers/​soundwire/​intel_ace2x.c Separates PDI initialization for ACE2.x hardware.
drivers/​soundwire/​cadence_master.h Uses the public PDI definition and adds allocation locking.
drivers/​soundwire/​cadence_master.c Implements synchronized PDI assignment and release.

Review effort: Balanced


snd_soc_dai_set_stream(codec_dai, NULL, substream->stream);
sdw_cdns_release_pdi(codec->bus, data->pdi);
sdw_release_stream(data->sdw_stream);
Comment on lines +76 to +77
adev->sdw = NULL;
sdw_intel_exit(ctx);
Comment on lines +154 to +155
if (!data->sdw_suspended)
sdw_stream_remove_master(codec->bus, data->sdw_stream);
case SNDRV_PCM_TRIGGER_SUSPEND:
if (rtd->dai_link->ignore_suspend)
break;
data->sdw_suspended = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants