mbox series

[0/5] ASoC: Fix reference to PCM buffer address

Message ID 20210728112353.6675-1-tiwai@suse.de
Headers show
Series ASoC: Fix reference to PCM buffer address | expand

Message

Takashi Iwai July 28, 2021, 11:23 a.m. UTC
Hi,

while updating the memory allocation API for WC pages, I casually
stumbled on quite a few drivers dealing with the PCM buffer address
wrongly via substream->dma_buffer.addr.  This patch series corrects
those usages.


Takashi

===

Takashi Iwai (5):
  ASoC: amd: Fix reference to PCM buffer address
  ASoC: intel: atom: Fix reference to PCM buffer address
  ASoC: xilinx: Fix reference to PCM buffer address
  ASoC: uniphier: Fix reference to PCM buffer address
  ASoC: kirkwood: Fix reference to PCM buffer address

 sound/soc/amd/acp-pcm-dma.c                  |  2 +-
 sound/soc/amd/raven/acp3x-pcm-dma.c          |  2 +-
 sound/soc/amd/renoir/acp3x-pdm-dma.c         |  2 +-
 sound/soc/intel/atom/sst-mfld-platform-pcm.c |  3 +--
 sound/soc/kirkwood/kirkwood-dma.c            | 26 ++++++++++++++------
 sound/soc/uniphier/aio-dma.c                 |  2 +-
 sound/soc/xilinx/xlnx_formatter_pcm.c        |  4 +--
 7 files changed, 25 insertions(+), 16 deletions(-)

Comments

Cezary Rojewski Aug. 2, 2021, 8:14 a.m. UTC | #1
On 2021-07-28 1:23 PM, Takashi Iwai wrote:
> PCM buffers might be allocated dynamically when the buffer
> preallocation failed or a larger buffer is requested, and it's not
> guaranteed that substream->dma_buffer points to the actually used
> buffer.  The address should be retrieved from runtime->dma_addr,
> instead of substream->dma_buffer (and shouldn't use virt_to_phys).
> 
> Also, remove the line overriding runtime->dma_area superfluously,
> which was already set up at the PCM buffer allocation.
> 
> Cc: Cezary Rojewski <cezary.rojewski@intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>   sound/soc/intel/atom/sst-mfld-platform-pcm.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> index 4124aa2fc247..5db2f4865bbb 100644
> --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> @@ -127,7 +127,7 @@ static void sst_fill_alloc_params(struct snd_pcm_substream *substream,
>   	snd_pcm_uframes_t period_size;
>   	ssize_t periodbytes;
>   	ssize_t buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
> -	u32 buffer_addr = virt_to_phys(substream->dma_buffer.area);
> +	u32 buffer_addr = substream->runtime->dma_addr;
>   
>   	channels = substream->runtime->channels;
>   	period_size = substream->runtime->period_size;
> @@ -233,7 +233,6 @@ static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
>   	/* set codec params and inform SST driver the same */
>   	sst_fill_pcm_params(substream, &param);
>   	sst_fill_alloc_params(substream, &alloc_params);
> -	substream->runtime->dma_area = substream->dma_buffer.area;
>   	str_params.sparams = param;
>   	str_params.aparams = alloc_params;
>   	str_params.codec = SST_CODEC_TYPE_PCM;
> 

Hello,

Changes look good. Can't verify these due to lack of test vehicles, 
unfortunately.

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