Skip to content

Commit a35551a

Browse files
committed
ASoC: Intel: avs: Set of streaming fixes
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: Small set of patches two of which fix problems observed during shutdown and XRUN scenarios for PCM streaming. These ensure HDAudio HOST stream is reset and re-setup during XRUNs and synchronize avs_dai_fe_shutdown() and period-elapsed work (thread) so that no slab-use-after-free panics occur. The last change makes the 'format' parameter provided by a compress-application taken into account - currently its ignored. Such approach helps us increase the coverage of data probing (debug) functionality.
2 parents 79a6f2d + 64007ad commit a35551a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

sound/soc/intel/avs/pcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ static void avs_dai_fe_shutdown(struct snd_pcm_substream *substream, struct snd_
651651

652652
data = snd_soc_dai_get_dma_data(dai, substream);
653653

654+
disable_work_sync(&data->period_elapsed_work);
654655
snd_hdac_ext_stream_release(data->host_stream, HDAC_EXT_STREAM_TYPE_HOST);
655656
avs_dai_shutdown(substream, dai);
656657
}
@@ -754,6 +755,8 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so
754755
data = snd_soc_dai_get_dma_data(dai, substream);
755756
host_stream = data->host_stream;
756757

758+
if (runtime->state == SNDRV_PCM_STATE_XRUN)
759+
hdac_stream(host_stream)->prepared = false;
757760
if (hdac_stream(host_stream)->prepared)
758761
return 0;
759762

sound/soc/intel/avs/probes.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "debug.h"
1515
#include "messages.h"
1616

17-
static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_id node_id,
18-
size_t buffer_size)
17+
static int avs_dsp_init_probe(struct avs_dev *adev, struct snd_compr_params *params, int bps,
18+
union avs_connector_node_id node_id, size_t buffer_size)
1919
{
2020
struct avs_probe_cfg cfg = {{0}};
2121
struct avs_module_entry mentry;
@@ -27,12 +27,16 @@ static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_id
2727
return ret;
2828

2929
/*
30-
* Probe module uses no cycles, audio data format and input and output
31-
* frame sizes are unused. It is also not owned by any pipeline.
30+
* Probe module uses no cycles, input and output frame sizes are unused.
31+
* It is also not owned by any pipeline.
3232
*/
3333
cfg.base.ibs = 1;
3434
/* BSS module descriptor is always segment of index=2. */
3535
cfg.base.is_pages = mentry.segments[2].flags.length;
36+
cfg.base.audio_fmt.sampling_freq = params->codec.sample_rate;
37+
cfg.base.audio_fmt.bit_depth = bps;
38+
cfg.base.audio_fmt.num_channels = params->codec.ch_out;
39+
cfg.base.audio_fmt.valid_bit_depth = bps;
3640
cfg.gtw_cfg.node_id = node_id;
3741
cfg.gtw_cfg.dma_buffer_size = buffer_size;
3842

@@ -128,8 +132,6 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream,
128132
struct hdac_ext_stream *host_stream = avs_compr_get_host_stream(cstream);
129133
struct snd_compr_runtime *rtd = cstream->runtime;
130134
struct avs_dev *adev = to_avs_dev(dai->dev);
131-
/* compr params do not store bit depth, default to S32_LE. */
132-
snd_pcm_format_t format = SNDRV_PCM_FORMAT_S32_LE;
133135
unsigned int format_val;
134136
int bps, ret;
135137

@@ -142,7 +144,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream,
142144
ret = snd_compr_malloc_pages(cstream, rtd->buffer_size);
143145
if (ret < 0)
144146
return ret;
145-
bps = snd_pcm_format_physical_width(format);
147+
bps = snd_pcm_format_physical_width(params->codec.format);
146148
if (bps < 0)
147149
return bps;
148150
format_val = snd_hdac_stream_format(params->codec.ch_out, bps, params->codec.sample_rate);
@@ -166,7 +168,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream,
166168
node_id.vindex = hdac_stream(host_stream)->stream_tag - 1;
167169
node_id.dma_type = AVS_DMA_HDA_HOST_INPUT;
168170

169-
ret = avs_dsp_init_probe(adev, node_id, rtd->dma_bytes);
171+
ret = avs_dsp_init_probe(adev, params, bps, node_id, rtd->dma_bytes);
170172
if (ret < 0) {
171173
dev_err(dai->dev, "probe init failed: %d\n", ret);
172174
avs_dsp_enable_d0ix(adev);

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
313313
},
314314
{
315315
.part_id = 0x1321,
316+
.name_prefix = "rt1320",
316317
.dais = {
317318
{
318319
.direction = {true, false},

0 commit comments

Comments
 (0)