ALSA/ASoC: Intel: avs: HDAudio bus and general fixes
Subsystems (3)
Cezary Rojewski
maintainerv2 cover 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:
- 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.
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
Cezary Rojewski (11):
ALSA: hda: Clean up pages when stream buffers allocation fails
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/controller.c | 16 ++++++-- sound/hda/core/ext/controller.c | 11 +++++- sound/hda/core/ext/stream.c | 11 +++++- 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 ++- 11 files changed, 156 insertions(+), 75 deletions(-)
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 1/11 ALSA: hda: Clean up pages when stream buffers allocation fails
snd_hdac_bus_alloc_stream_pages() does not clean up after itself when a failure occurs in the middle of the function. Add a proper error path to address that.
--- sound/hda/core/controller.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/hda/core/controller.c +13 -3
@@ -713,7 +713,7 @@ int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus) BDL_SIZE, &s->bdl); num_streams++;if (err <0 ) -return -ENOMEM ; + goto err_bdl; }if (WARN_ON (!num_streams))
@@ -722,12 +722,22 @@ int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus) err =snd_dma_alloc_pages (dma_type, bus->dev, num_streams *8 , &bus->posbuf);if (err <0 ) -return -ENOMEM ; + goto err_bdl;list_for_each_entry (s, &bus->stream_list, list) s->posbuf = (__le32 *)(bus->posbuf.area + s->index *8 );/* single page (at least 4096 bytes) must suffice for both ringbuffes */ -return snd_dma_alloc_pages (dma_type, bus->dev,PAGE_SIZE , &bus->rb); + err =snd_dma_alloc_pages (dma_type, bus->dev,PAGE_SIZE , &bus->rb); +if (err) + goto err_rb; +return 0 ; + +err_rb: +snd_dma_free_pages (&bus->posbuf); +err_bdl: +list_for_each_entry_continue_reverse (s, &bus->stream_list, list) +snd_dma_free_pages (&s->bdl); +return err; }EXPORT_SYMBOL_GPL (snd_hdac_bus_alloc_stream_pages);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 2/11 ALSA: hda: ext: Clean up links if their initialization fails
In reply to Cezary Rojewskisnd_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.
--- sound/hda/core/ext/controller.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/hda/core/ext/controller.c +9 -2
@@ -81,7 +81,7 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus) {int idx;u32 link_count; -struct hdac_ext_link *hlink; +struct hdac_ext_link *hlink, *save;u32 leptr; link_count =readl (bus->mlcap +AZX_REG_ML_MLCD ) +1 ;
@@ -91,7 +91,7 @@ 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) -return -ENOMEM ; + goto err_nomem; hlink->index = idx; hlink->bus = bus; hlink->ml_addr = bus->mlcap + AZX_ML_BASE +
@@ -112,6 +112,13 @@ int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus) }return 0 ; + +err_nomem: +list_for_each_entry_safe (hlink, save, &bus->hlink_list, list) { +list_del (&hlink->list); +kfree (hlink); + } +return -ENOMEM ; }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_get_ml_capabilities);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 3/11 ALSA: hda: ext: Clean up streams if their initialization fails
In reply to Cezary Rojewskisnd_hdac_ext_stream_init_all() does not rollback changes done when the allocation fails. Fix that to simplify its usage.
--- sound/hda/core/ext/stream.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/hda/core/ext/stream.c +10 -1
@@ -94,6 +94,7 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,int (*setup_op)(struct hdac_stream *,bool );int stream_tag =0 ;int i, tag, idx = start_idx; +struct hdac_stream *s, *_s;if (pci->device ==PCI_DEVICE_ID_INTEL_HDA_APL ) setup_op = snd_hdac_apl_host_stream_setup;
@@ -103,7 +104,7 @@ 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) -return -ENOMEM ; + goto err_nomem; tag = ++stream_tag;snd_hdac_ext_stream_init (bus, hext_stream, idx, dir, tag); idx++;
@@ -112,6 +113,14 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,return 0 ; +err_nomem: +list_for_each_entry_safe (s, _s, &bus->stream_list, list) { +struct hdac_ext_stream *hext_stream =stream_to_hdac_ext_stream (s); + +list_del (&s->list); +kfree (hext_stream); + } +return -ENOMEM ; }EXPORT_SYMBOL_GPL (snd_hdac_ext_stream_init_all);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 4/11 ASoC: Intel: avs: Clean up the bus when its initialization fails
In reply to Cezary Rojewskisnd_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.
--- sound/soc/intel/avs/core.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
sound/soc/intel/avs/core.c +17 -13
@@ -383,6 +383,18 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const structstruct 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; }
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 5/11 ASoC: Intel: avs: Clean up the bus when fetching ML caps fails
In reply to Cezary Rojewskisnd_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.
--- sound/soc/intel/avs/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/intel/avs/core.c +9 -2
@@ -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);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 6/11 ASoC: Intel: avs: Clean up streams if their initialization fails
In reply to Cezary RojewskiWhen streams are being initialized the memory allocation may fail. Have an error path and return early if that is the case.
--- sound/soc/intel/avs/core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
sound/soc/intel/avs/core.c +15 -3
@@ -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)
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 7/11 ASoC: Intel: avs: Do not ignore -ENOENT when loading a topology
In reply to Cezary Rojewskiavs_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.
--- 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(-)
sound/soc/intel/avs/pcm.c +20 -14
@@ -6,6 +6,7 @@// Amadeusz Slawinski <[email protected]> // +#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);
sound/soc/intel/avs/topology.c +1 -1
@@ -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,
sound/soc/intel/avs/topology.h +1 -0
@@ -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);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 8/11 ASoC: Intel: avs: Cancel d0ix_work asynchrounously during recovery
In reply to Cezary RojewskiTests 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.
--- sound/soc/intel/avs/ipc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/avs/ipc.c +3 -3
@@ -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 *requeststruct 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);
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 9/11 ASoC: Intel: avs: Fix unbalanced module reference count
In reply to Cezary Rojewskistrace_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.
--- sound/soc/intel/avs/debugfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
sound/soc/intel/avs/debugfs.c +9 -3
@@ -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)
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 10/11 ASoC: Intel: avs: Refactor and fix init_config access
In reply to Cezary RojewskiExisting 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.
--- 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(-)
sound/soc/intel/avs/path.c +3 -8
@@ -836,15 +836,10 @@ static int avs_path_module_type_create(struct avs_dev *adev, struct avs_path_modstatic 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;
sound/soc/intel/avs/topology.c +27 -20
77 lines not on this page · raw message
sound/soc/intel/avs/topology.h +2 -2
@@ -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;
Signature · 1 line
2.34.1
Cezary Rojewski
maintainerPATCH v2 11/11 ASoC: Intel: avs: hda: Constrain MSBs on startup
In reply to Cezary RojewskiFront-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.
--- sound/soc/intel/avs/boards/hdaudio.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
sound/soc/intel/avs/boards/hdaudio.c +17 -0
@@ -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 );
Signature · 1 line
2.34.1
Mark Brown
maintainerQuoted 4 lines · 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:
This doesn't apply against current code, please check and resend.
Cezary Rojewski
maintainerQuoted 7 lines · Mark Brown
Quoted 4 lines · 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:
This doesn't apply against current code, please check and resend.
Looks like I can drop the new patch - literally someone else made the (almost) same change [1].
The goto-label is misleading though, s/error_posbuf/error_rb/ and there's no need for the if-statement within the newly introduced error-path but that's an entirely separate subject, not in the scope of this one.