Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: fsl_asrc_dma: allocate memory from dma device

The dma-coherent property is used to indicate a device is capable of
coherent DMA operations. On i.MX952, one of EDMA devices support such
feature, in order to support the EDMA device, the memory needs to be
allocated from the DMA device.

Make this driver to support both non dma-coherent and dma-coherent dma
engine.

Remove dma coerce_mask_and coherent() because DMA provider already set it
according to its capability.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260206014805.3897764-5-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shengjiu Wang and committed by
Mark Brown
b010c782 6a8c6f55

+41 -7
+41 -7
sound/soc/fsl/fsl_asrc_dma.c
··· 449 449 static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component, 450 450 struct snd_soc_pcm_runtime *rtd) 451 451 { 452 - struct snd_card *card = rtd->card->snd_card; 452 + struct device *dev = component->dev; 453 + struct fsl_asrc *asrc = dev_get_drvdata(dev); 454 + struct fsl_asrc_pair *pair; 453 455 struct snd_pcm *pcm = rtd->pcm; 456 + struct dma_chan *chan; 454 457 int ret; 455 458 456 - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); 457 - if (ret) { 458 - dev_err(card->dev, "failed to set DMA mask\n"); 459 - return ret; 459 + pair = kzalloc(size_add(sizeof(*pair), asrc->pair_priv_size), GFP_KERNEL); 460 + if (!pair) 461 + return -ENOMEM; 462 + 463 + pair->asrc = asrc; 464 + pair->private = (void *)pair + sizeof(struct fsl_asrc_pair); 465 + 466 + /* Request a pair, which will be released later. 467 + * Request pair function needs channel num as input, for this 468 + * pair, we just request "1" channel temporarily. 469 + */ 470 + ret = asrc->request_pair(1, pair); 471 + if (ret < 0) { 472 + dev_err(dev, "failed to request asrc pair\n"); 473 + goto req_pair_err; 460 474 } 461 475 462 - return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 463 - card->dev, FSL_ASRC_DMABUF_SIZE); 476 + /* Request a dma channel, which will be released later. */ 477 + chan = asrc->get_dma_channel(pair, IN); 478 + if (!chan) { 479 + dev_err(dev, "failed to get dma channel\n"); 480 + ret = -EINVAL; 481 + goto dma_chan_err; 482 + } 483 + 484 + ret = snd_pcm_set_fixed_buffer_all(pcm, 485 + SNDRV_DMA_TYPE_DEV, 486 + chan->device->dev, 487 + FSL_ASRC_DMABUF_SIZE); 488 + 489 + dma_release_channel(chan); 490 + 491 + dma_chan_err: 492 + asrc->release_pair(pair); 493 + 494 + req_pair_err: 495 + kfree(pair); 496 + 497 + return ret; 464 498 } 465 499 466 500 struct snd_soc_component_driver fsl_asrc_component = {