Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f712b2b authored by Daniel Mack's avatar Daniel Mack Committed by Mark Brown
Browse files

ALSA: ASoC: move dma_data from snd_soc_dai to snd_soc_pcm_stream



This fixes a memory corruption when ASoC devices are used in
full-duplex mode. Specifically for pxa-ssp code, where this pointer
is dynamically allocated for each direction and destroyed upon each
stream start.

All other platforms are fixed blindly, I couldn't even compile-test
them. Sorry for any breakage I may have caused.

[Note that this is a backported version for 2.6.34.
 Upstream commit is fd23b7de]

Signed-off-by: default avatarDaniel Mack <daniel@caiaq.de>
Reported-by: default avatarSven Neumann <s.neumann@raumfeld.com>
Reported-by: default avatarMichael Hirsch <m.hirsch@raumfeld.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent d522ffbf
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ struct snd_soc_dai {
	struct snd_soc_codec *codec;
	unsigned int active;
	unsigned char pop_wait:1;
	void *dma_data;

	/* DAI private data */
	void *private_data;
@@ -230,4 +229,21 @@ struct snd_soc_dai {
	struct list_head list;
};

static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
					     const struct snd_pcm_substream *ss)
{
	return (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
		dai->playback.dma_data : dai->capture.dma_data;
}

static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
					    const struct snd_pcm_substream *ss,
					    void *data)
{
	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
		dai->playback.dma_data = data;
	else
		dai->capture.dma_data = data;
}

#endif
+1 −0
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@ struct snd_soc_pcm_stream {
	unsigned int channels_min;	/* min channels */
	unsigned int channels_max;	/* max channels */
	unsigned int active:1;		/* stream is in use */
	void *dma_data;			/* used by platform code */
};

/* SoC audio ops */
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
	runtime->dma_bytes = params_buffer_bytes(params);

	prtd->params = rtd->dai->cpu_dai->dma_data;
	prtd->params = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
	prtd->params->dma_intr_handler = atmel_pcm_dma_irq;

	prtd->dma_buffer = runtime->dma_addr;
+3 −3
Original line number Diff line number Diff line
@@ -363,12 +363,12 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
	ssc_p->dma_params[dir] = dma_params;

	/*
	 * The cpu_dai->dma_data field is only used to communicate the
	 * appropriate DMA parameters to the pcm driver hw_params()
	 * The snd_soc_pcm_stream->dma_data field is only used to communicate
	 * the appropriate DMA parameters to the pcm driver hw_params()
	 * function.  It should not be used for other purposes
	 * as it is common to all substreams.
	 */
	rtd->dai->cpu_dai->dma_data = dma_params;
	snd_soc_dai_set_dma_data(rtd->dai->cpu_dai, substream, dma_params);

	channels = params_channels(params);

+2 −1
Original line number Diff line number Diff line
@@ -585,7 +585,8 @@ static int davinci_i2s_probe(struct platform_device *pdev)
	dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start;

	davinci_i2s_dai.private_data = dev;
	davinci_i2s_dai.dma_data = dev->dma_params;
	davinci_i2s_dai.capture.dma_data = dev->dma_params;
	davinci_i2s_dai.playback.dma_data = dev->dma_params;
	ret = snd_soc_register_dai(&davinci_i2s_dai);
	if (ret != 0)
		goto err_free_mem;
Loading