* [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes
@ 2026-09-02 8:18 Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
` (10 more replies)
0 siblings, 11 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
The first half of the patchset concentrates on the driver initialization
procedure - a number of steps do not clean up after themselves when they
fail. This is for both, HDAudio bus (ext) and the DSP part (avs) and
targets following procedures:
- stream initialization
- link initialization
- bus initialization
The next five are loosely related fixes. First, split topology-loading
error handling from request-firmware one. Currently -ENOENT coming from
topology-loading, which is a real error, is ignored.
Second, with deeper test coverage around corrupted firmware/DSP exception
handling, new issues are unearthed. Switch to async d0ix_work
cancellation to avoid deadlock when D0IX has been scheduled just before
the recovery work.
The 09/10 patch, init_config change fixes possible out-of-bounds bug.
The fix is larger than what one could expect as instead of patching with
if-statements I've decided to refactor the parsing of init_configs.
The scenario that causes the problem no longer exists.
Note: the solution does not impose any changes on the existing topology
files (userspace).
The remaining two, IMHO are self-explanatory.
Chamges in v4:
- replaced error paths for patches 1/10 and 2/10 with
snd_hdac_ext_link_free_all() and snd_hdac_ext_stream_free_all()
respectively, as suggested by Takashi
Changes in v3:
- dropped the patch introduced in v2 as an equivalent change has just
been merged [1]
Changes in v2:
- added patch "ALSA: hda: Clean up pages when stream buffers allocation
fails" to address Mark's review for "ASoC: Intel: avs: Clean up the
bus when its initialization fails" and clean up pages before
collapsing the bus initialization
- removed unused 'acomp' variable as pointed out by Mark
[1]: https://lore.kernel.org/all/tencent_8E5BBBD19D53B1EFCDB6E89F3B6246A70B06@qq.com/
Cezary Rojewski (10):
ALSA: hda: ext: Clean up links if their initialization fails
ALSA: hda: ext: Clean up streams if their initialization fails
ASoC: Intel: avs: Clean up the bus when its initialization fails
ASoC: Intel: avs: Clean up the bus when fetching ML caps fails
ASoC: Intel: avs: Clean up streams if their initialization fails
ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology
ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery
ASoC: Intel: avs: Fix unbalanced module reference count
ASoC: Intel: avs: Refactor and fix init_config access
ASoC: Intel: avs: hda: Constrain MSBs on startup
sound/hda/core/ext/controller.c | 4 +-
sound/hda/core/ext/stream.c | 5 ++-
sound/soc/intel/avs/boards/hdaudio.c | 17 ++++++++
sound/soc/intel/avs/core.c | 59 +++++++++++++++++++---------
sound/soc/intel/avs/debugfs.c | 12 ++++--
sound/soc/intel/avs/ipc.c | 6 +--
sound/soc/intel/avs/path.c | 11 ++----
sound/soc/intel/avs/pcm.c | 34 +++++++++-------
sound/soc/intel/avs/topology.c | 49 +++++++++++++----------
sound/soc/intel/avs/topology.h | 5 ++-
10 files changed, 130 insertions(+), 72 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 13:43 ` Takashi Iwai
2026-09-02 8:18 ` [PATCH v4 02/10] ALSA: hda: ext: Clean up streams " Cezary Rojewski
` (9 subsequent siblings)
10 siblings, 1 reply; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
snd_hdac_ext_bus_get_ml_capabilities() allocates the hlink nodes
one-by-one but the procedure may fails due to -ENOMEM in the middle of
it. Clean up the list before returning the error code to simply the
function usage.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/hda/core/ext/controller.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/hda/core/ext/controller.c b/sound/hda/core/ext/controller.c
index b1f1eff1d181..6d0af7e6f63c 100644
--- a/sound/hda/core/ext/controller.c
+++ b/sound/hda/core/ext/controller.c
@@ -90,8 +90,10 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus)
for (idx = 0; idx < link_count; idx++) {
hlink = kzalloc_obj(*hlink);
- if (!hlink)
+ if (!hlink) {
+ snd_hdac_ext_link_free_all(bus);
return -ENOMEM;
+ }
hlink->index = idx;
hlink->bus = bus;
hlink->ml_addr = bus->mlcap + AZX_ML_BASE +
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 02/10] ALSA: hda: ext: Clean up streams if their initialization fails
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 13:43 ` Takashi Iwai
2026-09-02 8:18 ` [PATCH v4 03/10] ASoC: Intel: avs: Clean up the bus when its " Cezary Rojewski
` (8 subsequent siblings)
10 siblings, 1 reply; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
snd_hdac_ext_stream_init_all() does not rollback changes done when
the allocation fails. Fix that to simplify its usage.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/hda/core/ext/stream.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/hda/core/ext/stream.c b/sound/hda/core/ext/stream.c
index 517bd151fcc3..1f96e0484660 100644
--- a/sound/hda/core/ext/stream.c
+++ b/sound/hda/core/ext/stream.c
@@ -102,8 +102,10 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
for (i = 0; i < num_stream; i++) {
struct hdac_ext_stream *hext_stream = kzalloc_obj(*hext_stream);
- if (!hext_stream)
+ if (!hext_stream) {
+ snd_hdac_ext_stream_free_all(bus);
return -ENOMEM;
+ }
tag = ++stream_tag;
snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag);
idx++;
@@ -111,7 +113,6 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
}
return 0;
-
}
EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init_all);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 03/10] ASoC: Intel: avs: Clean up the bus when its initialization fails
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 02/10] ALSA: hda: ext: Clean up streams " Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails Cezary Rojewski
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
snd_hdac_i915_init() which is part of the initialization may return
-EPROBE_DEFER what fails the procedure and the existing avs_bus_init()
and avs_pci_probe() do not clean up the bus fields with
snd_hdac_ext_bus_exit() when that happens.
Fix avs_bus_init() by rearranging the initialization blocks: allocations
first, snd_hdac_ext_bus_init() last. Such approach generates no
error-path whilst still achieving the goal of cleaning up the bus.
For avs_pci_probe() update the existing error-path instead.
Co-developed-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/core.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index 2afe59646896..f45256ff5bac 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -383,6 +383,18 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const struct
struct device *dev = &pci->dev;
int ret;
+ ipc = devm_kzalloc(dev, sizeof(*ipc), GFP_KERNEL);
+ if (!ipc)
+ return -ENOMEM;
+
+ adev->modcfg_buf = devm_kzalloc(dev, AVS_MAILBOX_SIZE, GFP_KERNEL);
+ if (!adev->modcfg_buf)
+ return -ENOMEM;
+
+ ret = avs_ipc_init(ipc, dev);
+ if (ret < 0)
+ return ret;
+
ret = snd_hdac_ext_bus_init(&bus->core, dev, NULL, &soc_hda_ext_bus_ops);
if (ret < 0)
return ret;
@@ -394,17 +406,6 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const struct
bus->mixer_assigned = -1;
mutex_init(&bus->prepare_mutex);
- ipc = devm_kzalloc(dev, sizeof(*ipc), GFP_KERNEL);
- if (!ipc)
- return -ENOMEM;
- ret = avs_ipc_init(ipc, dev);
- if (ret < 0)
- return ret;
-
- adev->modcfg_buf = devm_kzalloc(dev, AVS_MAILBOX_SIZE, GFP_KERNEL);
- if (!adev->modcfg_buf)
- return -ENOMEM;
-
adev->dev = dev;
adev->spec = (const struct avs_spec *)id->driver_data;
adev->ipc = ipc;
@@ -456,13 +457,14 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
ret = pcim_request_all_regions(pci, "AVS HDAudio");
if (ret < 0)
- return ret;
+ goto err_request_regions;
bus->addr = pci_resource_start(pci, 0);
bus->remap_addr = pci_ioremap_bar(pci, 0);
if (!bus->remap_addr) {
dev_err(bus->dev, "ioremap error\n");
- return -ENXIO;
+ ret = -ENXIO;
+ goto err_request_regions;
}
adev->dsp_ba = pci_ioremap_bar(pci, 4);
@@ -519,6 +521,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
iounmap(adev->dsp_ba);
err_remap_bar4:
iounmap(bus->remap_addr);
+err_request_regions:
+ snd_hdac_ext_bus_exit(bus);
return ret;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (2 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 03/10] ASoC: Intel: avs: Clean up the bus when its " Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 05/10] ASoC: Intel: avs: Clean up streams if their initialization fails Cezary Rojewski
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
snd_hdac_ext_bus_get_ml_capabilities() may fail and its return code
shall be checked and accounted for. Address the issue by updating the
error-path for avs_pci_probe().
At the same time, if the function in question succeeds but the next part
of avs_pci_probe() fails, the hlink list shall be cleaned up before
leaving the scope.
Fixes: 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")
Co-developed-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/core.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index f45256ff5bac..8f27a7d43718 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -475,8 +475,13 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
}
snd_hdac_bus_parse_capabilities(bus);
- if (bus->mlcap)
- snd_hdac_ext_bus_get_ml_capabilities(bus);
+ if (bus->mlcap) {
+ ret = snd_hdac_ext_bus_get_ml_capabilities(bus);
+ if (ret < 0) {
+ dev_err(dev, "failed to get ml capabilities: %d\n", ret);
+ goto err_ml_cap;
+ }
+ }
if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)))
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
@@ -518,6 +523,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
snd_hdac_bus_free_stream_pages(bus);
snd_hdac_ext_stream_free_all(bus);
err_init_streams:
+ snd_hdac_ext_link_free_all(bus);
+err_ml_cap:
iounmap(adev->dsp_ba);
err_remap_bar4:
iounmap(bus->remap_addr);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 05/10] ASoC: Intel: avs: Clean up streams if their initialization fails
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (3 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology Cezary Rojewski
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
When streams are being initialized the memory allocation may fail.
Have an error path and return early if that is the case.
Fixes: 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")
Co-developed-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/core.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index 8f27a7d43718..611ae9f034d4 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -92,16 +92,28 @@ static int avs_hdac_bus_init_streams(struct hdac_bus *bus)
{
unsigned int cp_streams, pb_streams;
unsigned int gcap;
+ int ret;
gcap = snd_hdac_chip_readw(bus, GCAP);
cp_streams = (gcap >> 8) & 0x0F;
pb_streams = (gcap >> 12) & 0x0F;
bus->num_streams = cp_streams + pb_streams;
- snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE);
- snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK);
+ ret = snd_hdac_ext_stream_init_all(bus, 0, cp_streams, SNDRV_PCM_STREAM_CAPTURE);
+ if (ret)
+ return ret;
+ ret = snd_hdac_ext_stream_init_all(bus, cp_streams, pb_streams, SNDRV_PCM_STREAM_PLAYBACK);
+ if (ret)
+ goto err;
- return snd_hdac_bus_alloc_stream_pages(bus);
+ ret = snd_hdac_bus_alloc_stream_pages(bus);
+ if (ret)
+ goto err;
+
+ return 0;
+err:
+ snd_hdac_ext_stream_free_all(bus);
+ return ret;
}
static bool avs_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (4 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 05/10] ASoC: Intel: avs: Clean up streams if their initialization fails Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery Cezary Rojewski
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
avs_load_topology() combines request_firmware() and
snd_soc_tplg_component_load(). The fallback mechanism introduced for
the HDAudio based boards honors -ENOENT and checks for a generic
topology if no specific is found before giving up and failing the
component probing.
However, if -ENOENT is returned by the latter function -
snd_soc_tplg_component_load() - is shall not be ignored. That means
there is an actual problem with the topology file and no fallback shall
be attempted.
Fixes: 739c031110da ("ASoC: Intel: avs: Provide support for fallback topology")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/pcm.c | 34 ++++++++++++++++++++--------------
sound/soc/intel/avs/topology.c | 2 +-
sound/soc/intel/avs/topology.h | 1 +
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index 2b886fae8209..ad25bd355769 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -6,6 +6,7 @@
// Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
//
+#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <sound/hda_register.h>
@@ -987,13 +988,25 @@ static int avs_component_load_libraries(struct avs_soc_component *acomp)
return ret;
}
+static int avs_request_topology(struct snd_soc_component *component, const char *name,
+ const struct firmware **fw)
+{
+ char *fullname __free(kfree) = NULL;
+
+ fullname = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix, name);
+ if (!fullname)
+ return -ENOMEM;
+
+ return request_firmware(fw, fullname, component->dev);
+}
+
static int avs_component_probe(struct snd_soc_component *component)
{
struct snd_soc_card *card = component->card;
struct snd_soc_acpi_mach *mach;
struct avs_soc_component *acomp;
+ const struct firmware *fw;
struct avs_dev *adev;
- char *filename;
int ret;
dev_dbg(card->dev, "probing %s card %s\n", component->name, card->name);
@@ -1009,13 +1022,7 @@ static int avs_component_probe(struct snd_soc_component *component)
goto finalize;
/* Load specified topology and create debugfs for it. */
- filename = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix,
- mach->tplg_filename);
- if (!filename)
- return -ENOMEM;
-
- ret = avs_load_topology(component, filename);
- kfree(filename);
+ ret = avs_request_topology(component, mach->tplg_filename, &fw);
if (ret == -ENOENT && !strncmp(mach->tplg_filename, "hda-", 4)) {
unsigned int vendor_id;
@@ -1030,18 +1037,17 @@ static int avs_component_probe(struct snd_soc_component *component)
"hda-generic-tplg.bin");
if (!mach->tplg_filename)
return -ENOMEM;
- filename = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix,
- mach->tplg_filename);
- if (!filename)
- return -ENOMEM;
dev_info(card->dev, "trying to load fallback topology %s\n", mach->tplg_filename);
- ret = avs_load_topology(component, filename);
- kfree(filename);
+ ret = avs_request_topology(component, mach->tplg_filename, &fw);
}
if (ret < 0)
return ret;
+ ret = snd_soc_tplg_component_load(component, &avs_tplg_ops, fw);
+ if (ret)
+ return ret;
+
ret = avs_component_load_libraries(acomp);
if (ret < 0) {
dev_err(card->dev, "libraries loading failed: %d\n", ret);
diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c
index 673ac31f2fea..d5e641c73faf 100644
--- a/sound/soc/intel/avs/topology.c
+++ b/sound/soc/intel/avs/topology.c
@@ -2194,7 +2194,7 @@ avs_control_load(struct snd_soc_component *comp, int index, struct snd_kcontrol_
return 0;
}
-static const struct snd_soc_tplg_ops avs_tplg_ops = {
+const struct snd_soc_tplg_ops avs_tplg_ops = {
.io_ops = avs_control_ops,
.io_ops_count = ARRAY_SIZE(avs_control_ops),
.control_load = avs_control_load,
diff --git a/sound/soc/intel/avs/topology.h b/sound/soc/intel/avs/topology.h
index 1cf7455b6c01..b5799c994b88 100644
--- a/sound/soc/intel/avs/topology.h
+++ b/sound/soc/intel/avs/topology.h
@@ -230,6 +230,7 @@ struct avs_tplg_module {
struct list_head node;
};
+extern const struct snd_soc_tplg_ops avs_tplg_ops;
struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp);
int avs_load_topology(struct snd_soc_component *comp, const char *filename);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (5 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 08/10] ASoC: Intel: avs: Fix unbalanced module reference count Cezary Rojewski
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
Tests with corrupted firmware binaries prove that the recovery procedure
can hit deadlock with d0ix_work if the work has been scheduled shortly
before the event that triggered the recovery e.g.: timeouts on
communication with a dead AudioDSP firmware.
At the same time, the ready-check shall be done after acquiring the
msg_mutex as the flag might have been modified by the time the lock is
granted. The recovery case is one of such examples.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/ipc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/avs/ipc.c b/sound/soc/intel/avs/ipc.c
index 39b0de9831da..5010b0f5be47 100644
--- a/sound/soc/intel/avs/ipc.c
+++ b/sound/soc/intel/avs/ipc.c
@@ -172,7 +172,7 @@ static void avs_dsp_exception_caught(struct avs_dev *adev, union avs_notify_msg
/* Avoid deadlock as the exception may be the response to SET_D0IX. */
if (current_work() != &ipc->d0ix_work.work)
- cancel_delayed_work_sync(&ipc->d0ix_work);
+ cancel_delayed_work(&ipc->d0ix_work);
ipc->in_d0ix = false;
/* Re-enabled on recovery completion. */
pm_runtime_disable(adev->dev);
@@ -395,11 +395,11 @@ static int avs_dsp_do_send_msg(struct avs_dev *adev, struct avs_ipc_msg *request
struct avs_ipc *ipc = adev->ipc;
int ret;
+ guard(mutex)(&ipc->msg_mutex);
+
if (!ipc->ready)
return -EPERM;
- guard(mutex)(&ipc->msg_mutex);
-
spin_lock(&ipc->rx_lock);
avs_ipc_msg_init(ipc, reply);
avs_dsp_send_tx(adev, request, true);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 08/10] ASoC: Intel: avs: Fix unbalanced module reference count
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (6 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 09/10] ASoC: Intel: avs: Refactor and fix init_config access Cezary Rojewski
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
strace_open() invokes try_module_get() which on success takes
the module reference. If any follow up operation causes
strace_open() to fail, the refcount shall be put down.
Fixes: 0a5fb3cc28fd ("ASoC: Intel: avs: Keep module refcount up when gathering traces")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/debugfs.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/avs/debugfs.c b/sound/soc/intel/avs/debugfs.c
index 9ab503da3b75..bc02737720ab 100644
--- a/sound/soc/intel/avs/debugfs.c
+++ b/sound/soc/intel/avs/debugfs.c
@@ -9,6 +9,7 @@
#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/kfifo.h>
+#include <linux/module.h>
#include <linux/wait.h>
#include <linux/sched/signal.h>
#include <linux/string_helpers.h>
@@ -236,15 +237,20 @@ static int strace_open(struct inode *inode, struct file *file)
if (!try_module_get(adev->dev->driver->owner))
return -ENODEV;
- if (kfifo_initialized(&adev->trace_fifo))
- return -EBUSY;
+ if (kfifo_initialized(&adev->trace_fifo)) {
+ ret = -EBUSY;
+ goto err;
+ }
ret = kfifo_alloc(&adev->trace_fifo, PAGE_SIZE, GFP_KERNEL);
if (ret < 0)
- return ret;
+ goto err;
file->private_data = adev;
return 0;
+err:
+ module_put(adev->dev->driver->owner);
+ return ret;
}
static int strace_release(struct inode *inode, struct file *file)
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 09/10] ASoC: Intel: avs: Refactor and fix init_config access
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (7 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 08/10] ASoC: Intel: avs: Fix unbalanced module reference count Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup Cezary Rojewski
2026-09-03 21:53 ` [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Mark Brown
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
Existing code accesses enties found in ->init_configs array through
indexes that are part of ->config_ids array. Those two are limited by:
->num_init_configs and ->num_config_ids respectively. Using ID larger
or equal to ->num_init_configs leads to out-of-bounds access:
avs_path_module_send_init_configs()
loop:
(...) &acomp->tplg->init_configs[ids[i]]
^ out-of-bounds candidate
Rather than adding another if-statement, refactor the code. There is no
need to store the IDs, have a list of pointers to actual config-entries
instead. As the verification of ->init_config entries does not differ from
verification of other types that are part of the topology.c file, simply
reuse the code.
Fixes: 8a49ef789b1b ("ASoC: Intel: avs: Send initial config to module if present")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/path.c | 11 +++-----
sound/soc/intel/avs/topology.c | 47 +++++++++++++++++++---------------
sound/soc/intel/avs/topology.h | 4 +--
3 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index 213d6ecdd7cc..a8a2b3484338 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -836,15 +836,10 @@ static int avs_path_module_type_create(struct avs_dev *adev, struct avs_path_mod
static int avs_path_module_send_init_configs(struct avs_dev *adev, struct avs_path_module *mod)
{
- struct avs_soc_component *acomp;
+ struct avs_tplg_module *template = mod->template;
- acomp = to_avs_soc_component(mod->template->owner->owner->owner->owner->comp);
-
- u32 num_ids = mod->template->num_config_ids;
- u32 *ids = mod->template->config_ids;
-
- for (int i = 0; i < num_ids; i++) {
- struct avs_tplg_init_config *config = &acomp->tplg->init_configs[ids[i]];
+ for (int i = 0; i < template->num_init_configs; i++) {
+ struct avs_tplg_init_config *config = template->init_configs[i];
size_t len = config->length;
void *data = config->data;
u32 param = config->param;
diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c
index d5e641c73faf..5d70be63a4a7 100644
--- a/sound/soc/intel/avs/topology.c
+++ b/sound/soc/intel/avs/topology.c
@@ -350,6 +350,7 @@ AVS_DEFINE_PTR_PARSER(modcfg_base, struct avs_tplg_modcfg_base, modcfgs_base);
AVS_DEFINE_PTR_PARSER(modcfg_ext, struct avs_tplg_modcfg_ext, modcfgs_ext);
AVS_DEFINE_PTR_PARSER(pplcfg, struct avs_tplg_pplcfg, pplcfgs);
AVS_DEFINE_PTR_PARSER(binding, struct avs_tplg_binding, bindings);
+AVS_DEFINE_PTR_PARSER(init_config, struct avs_tplg_init_config, init_configs);
AVS_DEFINE_PTR_PARSER(nhlt_config, struct avs_tplg_nhlt_config, nhlt_configs);
static int
@@ -1198,7 +1199,7 @@ static const struct avs_tplg_token_parser module_parsers[] = {
{
.token = AVS_TKN_MOD_INIT_CONFIG_NUM_IDS_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
- .offset = offsetof(struct avs_tplg_module, num_config_ids),
+ .offset = offsetof(struct avs_tplg_module, num_init_configs),
.parse = avs_parse_byte_token,
},
{
@@ -1214,10 +1215,32 @@ static const struct avs_tplg_token_parser init_config_parsers[] = {
.token = AVS_TKN_MOD_INIT_CONFIG_ID_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = 0,
- .parse = avs_parse_word_token,
+ .parse = avs_parse_init_config_ptr,
},
};
+static int avs_tplg_module_init_configs(struct snd_soc_component *comp,
+ struct avs_tplg_module *module,
+ struct snd_soc_tplg_vendor_array *tuples, u32 block_size)
+{
+ struct avs_tplg_init_config **cfgs;
+ int ret;
+
+ if (!module->num_init_configs)
+ return -EINVAL;
+
+ cfgs = devm_kcalloc(comp->card->dev, module->num_init_configs, sizeof(*cfgs), GFP_KERNEL);
+ if (!cfgs)
+ return -ENOMEM;
+
+ ret = parse_dictionary_entries(comp, tuples, block_size, cfgs, module->num_init_configs,
+ sizeof(*cfgs), AVS_TKN_MOD_INIT_CONFIG_ID_U32,
+ init_config_parsers, ARRAY_SIZE(init_config_parsers));
+ if (!ret)
+ module->init_configs = cfgs;
+ return ret;
+}
+
static struct avs_tplg_module *
avs_tplg_module_create(struct snd_soc_component *comp, struct avs_tplg_pipeline *owner,
struct snd_soc_tplg_vendor_array *tuples, u32 block_size)
@@ -1244,27 +1267,11 @@ avs_tplg_module_create(struct snd_soc_component *comp, struct avs_tplg_pipeline
block_size -= esize;
/* Parse trailing config ids if any. */
if (block_size) {
- u32 num_config_ids = module->num_config_ids;
- u32 *config_ids;
-
- if (!num_config_ids)
- return ERR_PTR(-EINVAL);
-
- config_ids = devm_kcalloc(comp->card->dev, num_config_ids, sizeof(*config_ids),
- GFP_KERNEL);
- if (!config_ids)
- return ERR_PTR(-ENOMEM);
-
tuples = avs_tplg_vendor_array_at(tuples, esize);
- ret = parse_dictionary_entries(comp, tuples, block_size,
- config_ids, num_config_ids, sizeof(*config_ids),
- AVS_TKN_MOD_INIT_CONFIG_ID_U32,
- init_config_parsers,
- ARRAY_SIZE(init_config_parsers));
+
+ ret = avs_tplg_module_init_configs(comp, module, tuples, block_size);
if (ret)
return ERR_PTR(ret);
-
- module->config_ids = config_ids;
}
module->owner = owner;
diff --git a/sound/soc/intel/avs/topology.h b/sound/soc/intel/avs/topology.h
index b5799c994b88..189984ce7b51 100644
--- a/sound/soc/intel/avs/topology.h
+++ b/sound/soc/intel/avs/topology.h
@@ -221,8 +221,8 @@ struct avs_tplg_module {
u8 domain;
struct avs_tplg_modcfg_ext *cfg_ext;
u32 ctl_id;
- u32 num_config_ids;
- u32 *config_ids;
+ u32 num_init_configs;
+ struct avs_tplg_init_config **init_configs;
struct avs_tplg_nhlt_config *nhlt_config;
struct avs_tplg_pipeline *owner;
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (8 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 09/10] ASoC: Intel: avs: Refactor and fix init_config access Cezary Rojewski
@ 2026-09-02 8:18 ` Cezary Rojewski
2026-09-03 21:53 ` [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Mark Brown
10 siblings, 0 replies; 14+ messages in thread
From: Cezary Rojewski @ 2026-09-02 8:18 UTC (permalink / raw)
To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski
Front-end DAI links are marked as dynamic for the card thus the
__soc_pcm_open() function never gets to soc_pcm_apply_msb() step which
performs MSBs-constraint rule. Do that on link startup instead.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
sound/soc/intel/avs/boards/hdaudio.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/sound/soc/intel/avs/boards/hdaudio.c b/sound/soc/intel/avs/boards/hdaudio.c
index 03cfd91202d3..2e15a293298d 100644
--- a/sound/soc/intel/avs/boards/hdaudio.c
+++ b/sound/soc/intel/avs/boards/hdaudio.c
@@ -15,6 +15,22 @@
#include "../../../codecs/hda.h"
#include "../utils.h"
+static int avs_link_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ const struct snd_soc_pcm_stream *stream_info;
+ struct snd_soc_dai *codec_dai;
+
+ codec_dai = snd_soc_rtd_to_codec(rtd, 0);
+ stream_info = snd_soc_dai_get_pcm_stream(codec_dai, substream->stream);
+
+ return snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, stream_info->sig_bits);
+}
+
+static const struct snd_soc_ops avs_link_ops = {
+ .startup = avs_link_startup,
+};
+
static int avs_create_dai_links(struct device *dev, struct hda_codec *codec, int pcm_count,
struct snd_soc_dai_link **links)
{
@@ -43,6 +59,7 @@ static int avs_create_dai_links(struct device *dev, struct hda_codec *codec, int
dl[i].platforms = platform;
dl[i].num_platforms = 1;
dl[i].ignore_pmdown_time = 1;
+ dl[i].ops = &avs_link_ops;
dl[i].codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL);
dl[i].cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails
2026-09-02 8:18 ` [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
@ 2026-09-02 13:43 ` Takashi Iwai
0 siblings, 0 replies; 14+ messages in thread
From: Takashi Iwai @ 2026-09-02 13:43 UTC (permalink / raw)
To: Cezary Rojewski; +Cc: broonie, tiwai, perex, amade, linux-sound
On Wed, 02 Sep 2026 10:18:05 +0200,
Cezary Rojewski wrote:
>
> snd_hdac_ext_bus_get_ml_capabilities() allocates the hlink nodes
> one-by-one but the procedure may fails due to -ENOMEM in the middle of
> it. Clean up the list before returning the error code to simply the
> function usage.
>
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
In case the series go through Mark's tree:
Acked-by: Takashi Iwai <tiwai@suse.de>
thanks,
Takashi
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 02/10] ALSA: hda: ext: Clean up streams if their initialization fails
2026-09-02 8:18 ` [PATCH v4 02/10] ALSA: hda: ext: Clean up streams " Cezary Rojewski
@ 2026-09-02 13:43 ` Takashi Iwai
0 siblings, 0 replies; 14+ messages in thread
From: Takashi Iwai @ 2026-09-02 13:43 UTC (permalink / raw)
To: Cezary Rojewski; +Cc: broonie, tiwai, perex, amade, linux-sound
On Wed, 02 Sep 2026 10:18:06 +0200,
Cezary Rojewski wrote:
>
> snd_hdac_ext_stream_init_all() does not rollback changes done when
> the allocation fails. Fix that to simplify its usage.
>
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
In case the series go through Mark's tree:
Acked-by: Takashi Iwai <tiwai@suse.de>
thanks,
Takashi
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
` (9 preceding siblings ...)
2026-09-02 8:18 ` [PATCH v4 10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup Cezary Rojewski
@ 2026-09-03 21:53 ` Mark Brown
10 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2026-09-03 21:53 UTC (permalink / raw)
To: Cezary Rojewski; +Cc: tiwai, perex, amade, linux-sound
On Wed, 02 Sep 2026 10:18:04 +0200, Cezary Rojewski wrote:
> ALSA/ASoC: Intel: avs: HDAudio bus and general fixes
>
> The first half of the patchset concentrates on the driver initialization
> procedure - a number of steps do not clean up after themselves when they
> fail. This is for both, HDAudio bus (ext) and the DSP part (avs) and
> targets following procedures:
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[01/10] ALSA: hda: ext: Clean up links if their initialization fails
https://git.kernel.org/broonie/sound/c/35af118326b2
[02/10] ALSA: hda: ext: Clean up streams if their initialization fails
https://git.kernel.org/broonie/sound/c/48afc07c4f1b
[03/10] ASoC: Intel: avs: Clean up the bus when its initialization fails
https://git.kernel.org/broonie/sound/c/ce4d7356660a
[04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails
https://git.kernel.org/broonie/sound/c/559ea14b7ae7
[05/10] ASoC: Intel: avs: Clean up streams if their initialization fails
https://git.kernel.org/broonie/sound/c/f4ba00bb56a8
[06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology
https://git.kernel.org/broonie/sound/c/c6dceca9f78f
[07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery
https://git.kernel.org/broonie/sound/c/363a6969f7f8
[08/10] ASoC: Intel: avs: Fix unbalanced module reference count
https://git.kernel.org/broonie/sound/c/d4fa6f94b911
[09/10] ASoC: Intel: avs: Refactor and fix init_config access
https://git.kernel.org/broonie/sound/c/681e91035dc7
[10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup
https://git.kernel.org/broonie/sound/c/99f5566a1a88
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-09-03 23:11 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 8:18 [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 01/10] ALSA: hda: ext: Clean up links if their initialization fails Cezary Rojewski
2026-09-02 13:43 ` Takashi Iwai
2026-09-02 8:18 ` [PATCH v4 02/10] ALSA: hda: ext: Clean up streams " Cezary Rojewski
2026-09-02 13:43 ` Takashi Iwai
2026-09-02 8:18 ` [PATCH v4 03/10] ASoC: Intel: avs: Clean up the bus when its " Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 04/10] ASoC: Intel: avs: Clean up the bus when fetching ML caps fails Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 05/10] ASoC: Intel: avs: Clean up streams if their initialization fails Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 06/10] ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 07/10] ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 08/10] ASoC: Intel: avs: Fix unbalanced module reference count Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 09/10] ASoC: Intel: avs: Refactor and fix init_config access Cezary Rojewski
2026-09-02 8:18 ` [PATCH v4 10/10] ASoC: Intel: avs: hda: Constrain MSBs on startup Cezary Rojewski
2026-09-03 21:53 ` [PATCH v4 00/10] ALSA/ASoC: Intel: avs: HDAudio bus and general fixes Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox