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

ASoC: dmaengine_pcm: Make FLAG_NO_RESIDUE internal

Whether residue can be reported or not is not a property of the audio
controller but of the DMA controller. The FLAG_NO_RESIDUE was initially
added when the DMAengine framework had no support for describing the residue
reporting capabilities of the controller. Support for this was added quite a
while ago and recently the DMAengine framework started to complain if a
driver does not describe its capabilities and a lot of patches have been
merged that add support for this where it was missing. So it should be safe
to assume that driver on actively used platforms properly implement the DMA
capabilities API.

This patch makes the FLAG_NO_RESIDUE internal and no longer allows audio
controller drivers to manually set the flag. If a DMA driver against
expectations does not support reporting its capabilities for now the generic
DMAengine PCM driver will now emit a warning and simply assume that residue
reporting is not supported. In the future this might be changed to aborting
with an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Lars-Peter Clausen and committed by
Mark Brown
acde50a7 b787f68c

+16 -22
-5
include/sound/dmaengine_pcm.h
··· 91 91 */ 92 92 #define SND_DMAENGINE_PCM_FLAG_NO_DT BIT(1) 93 93 /* 94 - * The platforms dmaengine driver does not support reporting the amount of 95 - * bytes that are still left to transfer. 96 - */ 97 - #define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(2) 98 - /* 99 94 * The PCM is half duplex and the DMA channel is shared between capture and 100 95 * playback. 101 96 */
+1 -2
sound/soc/atmel/atmel-pcm-dma.c
··· 124 124 125 125 int atmel_pcm_dma_platform_register(struct device *dev) 126 126 { 127 - return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config, 128 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); 127 + return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config, 0); 129 128 } 130 129 EXPORT_SYMBOL(atmel_pcm_dma_platform_register); 131 130
-1
sound/soc/cirrus/ep93xx-pcm.c
··· 60 60 { 61 61 return devm_snd_dmaengine_pcm_register(dev, 62 62 &ep93xx_dmaengine_pcm_config, 63 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 64 63 SND_DMAENGINE_PCM_FLAG_NO_DT | 65 64 SND_DMAENGINE_PCM_FLAG_COMPAT); 66 65 }
+1 -2
sound/soc/fsl/fsl_sai.c
··· 664 664 if (sai->sai_on_imx) 665 665 return imx_pcm_dma_init(pdev); 666 666 else 667 - return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 668 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); 667 + return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 669 668 } 670 669 671 670 static const struct of_device_id fsl_sai_ids[] = {
+14 -11
sound/soc/soc-generic-dmaengine-pcm.c
··· 24 24 25 25 #include <sound/dmaengine_pcm.h> 26 26 27 + /* 28 + * The platforms dmaengine driver does not support reporting the amount of 29 + * bytes that are still left to transfer. 30 + */ 31 + #define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(31) 32 + 27 33 struct dmaengine_pcm { 28 34 struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; 29 35 const struct snd_dmaengine_pcm_config *config; ··· 228 222 return snd_dmaengine_pcm_request_channel(fn, dma_data->filter_data); 229 223 } 230 224 231 - static bool dmaengine_pcm_can_report_residue(struct dma_chan *chan) 225 + static bool dmaengine_pcm_can_report_residue(struct device *dev, 226 + struct dma_chan *chan) 232 227 { 233 228 struct dma_slave_caps dma_caps; 234 229 int ret; 235 230 236 231 ret = dma_get_slave_caps(chan, &dma_caps); 237 - if (ret != 0) 238 - return true; 232 + if (ret != 0) { 233 + dev_warn(dev, "Failed to get DMA channel capabilities, falling back to period counting: %d\n", 234 + ret); 235 + return false; 236 + } 239 237 240 238 if (dma_caps.residue_granularity == DMA_RESIDUE_GRANULARITY_DESCRIPTOR) 241 239 return false; ··· 299 289 if (ret) 300 290 return ret; 301 291 302 - /* 303 - * This will only return false if we know for sure that at least 304 - * one channel does not support residue reporting. If the DMA 305 - * driver does not implement the slave_caps API we rely having 306 - * the NO_RESIDUE flag set manually in case residue reporting is 307 - * not supported. 308 - */ 309 - if (!dmaengine_pcm_can_report_residue(pcm->chan[i])) 292 + if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) 310 293 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; 311 294 } 312 295
-1
sound/soc/ux500/ux500_pcm.c
··· 147 147 pcm_config = &ux500_dmaengine_pcm_config; 148 148 149 149 ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 150 - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 151 150 SND_DMAENGINE_PCM_FLAG_COMPAT); 152 151 if (ret < 0) { 153 152 dev_err(&pdev->dev,