Re: [alsa-devel] [PATCH] ASoC: snd_dmaengine: add common api for pcm_mmap
On 06/28/2012 09:01 AM, Laxman Dewangan wrote:
The pcm mmap for the substream dma buffer is done using the dma_mmap_writecombine(). Some of the chip sound driver like Spear, Tegra, Davinci, ep93xx,snd_imx, snd_mxs, NUC900, OMAP, Samsung are doing this mapping locally. Add api in the snd dmaengine driver so that different client of snd dmaengine can use this rather than implementing locally.
This is not really related to the dmaengine pcm driver. It's more of a coincidence that all upstream drivers which use the dmaengine pcm driver also use write-combined memory. In my opinion it would be better to add this to the ALSA core. Now that there is a generic dma_mmap_writecombine it may make sense to integrate this with snd_pcm_lib_default_mmap.
- Lars
Signed-off-by: Laxman Dewangan ldewangan@nvidia.com
include/sound/dmaengine_pcm.h | 2 ++ sound/soc/soc-dmaengine-pcm.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index b877334..15c0d3c 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -47,4 +47,6 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
+int snd_dmaengine_pcm_mmap_writecombine(struct snd_pcm_substream *substream,
struct vm_area_struct *vma);
#endif diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index 5df529e..6535eb3 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -21,6 +21,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/dmaengine.h> +#include <linux/dma-mapping.h> #include <linux/slab.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -313,3 +314,19 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream) return 0; } EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
+/**
- snd_dmaengine_pcm_mmap_writecombine - mmap stream dma buffer using
- dma_mmap_writecombine().
- @substream: PCM substream
- @vma: VM area.
- */
+int snd_dmaengine_pcm_mmap_writecombine(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)
+{
- struct snd_pcm_runtime *runtime = substream->runtime;
- return dma_mmap_writecombine(substream->pcm->card->dev, vma,
runtime->dma_area, runtime->dma_addr, runtime->dma_bytes);
+} +EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_mmap_writecombine);
At Thu, 28 Jun 2012 13:09:36 +0200, Lars-Peter Clausen wrote:
On 06/28/2012 09:01 AM, Laxman Dewangan wrote:
The pcm mmap for the substream dma buffer is done using the dma_mmap_writecombine(). Some of the chip sound driver like Spear, Tegra, Davinci, ep93xx,snd_imx, snd_mxs, NUC900, OMAP, Samsung are doing this mapping locally. Add api in the snd dmaengine driver so that different client of snd dmaengine can use this rather than implementing locally.
This is not really related to the dmaengine pcm driver. It's more of a coincidence that all upstream drivers which use the dmaengine pcm driver also use write-combined memory. In my opinion it would be better to add this to the ALSA core. Now that there is a generic dma_mmap_writecombine it may make sense to integrate this with snd_pcm_lib_default_mmap.
Agreed.
Also, it must be portable. So far, only ARM has dma_mmap_writecombine(), thus the build on other arch would fail as is.
thanks,
Takashi
- Lars
Signed-off-by: Laxman Dewangan ldewangan@nvidia.com
include/sound/dmaengine_pcm.h | 2 ++ sound/soc/soc-dmaengine-pcm.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index b877334..15c0d3c 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -47,4 +47,6 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream);
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream);
+int snd_dmaengine_pcm_mmap_writecombine(struct snd_pcm_substream *substream,
struct vm_area_struct *vma);
#endif diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c index 5df529e..6535eb3 100644 --- a/sound/soc/soc-dmaengine-pcm.c +++ b/sound/soc/soc-dmaengine-pcm.c @@ -21,6 +21,7 @@ #include <linux/module.h> #include <linux/init.h> #include <linux/dmaengine.h> +#include <linux/dma-mapping.h> #include <linux/slab.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -313,3 +314,19 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream) return 0; } EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
+/**
- snd_dmaengine_pcm_mmap_writecombine - mmap stream dma buffer using
- dma_mmap_writecombine().
- @substream: PCM substream
- @vma: VM area.
- */
+int snd_dmaengine_pcm_mmap_writecombine(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)
+{
- struct snd_pcm_runtime *runtime = substream->runtime;
- return dma_mmap_writecombine(substream->pcm->card->dev, vma,
runtime->dma_area, runtime->dma_addr, runtime->dma_bytes);
+} +EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_mmap_writecombine);
On Thu, Jun 28, 2012 at 02:15:38PM +0200, Takashi Iwai wrote:
Lars-Peter Clausen wrote:
to the ALSA core. Now that there is a generic dma_mmap_writecombine it may make sense to integrate this with snd_pcm_lib_default_mmap.
Agreed.
Also, it must be portable. So far, only ARM has dma_mmap_writecombine(), thus the build on other arch would fail as is.
Oh, dear - this means we don't actually have a generic API at all. Is there any effort being made to make this generally available?
On 06/28/2012 02:18 PM, Mark Brown wrote:
On Thu, Jun 28, 2012 at 02:15:38PM +0200, Takashi Iwai wrote:
Lars-Peter Clausen wrote:
to the ALSA core. Now that there is a generic dma_mmap_writecombine it may make sense to integrate this with snd_pcm_lib_default_mmap.
Agreed.
Also, it must be portable. So far, only ARM has dma_mmap_writecombine(), thus the build on other arch would fail as is.
Oh, dear - this means we don't actually have a generic API at all. Is there any effort being made to make this generally available?
Yes there is, and in fact in next/master there is generic dma_mmap_writecombine. I'm not quite sure how it behaves on non ARM archs though. But in theory it should fallback to a normal coherent mapping. Marek did a lot of work on this, I've put him on Cc.
- Lars
On Thu, Jun 28, 2012 at 02:30:26PM +0200, Lars-Peter Clausen wrote:
On 06/28/2012 02:18 PM, Mark Brown wrote:
Oh, dear - this means we don't actually have a generic API at all. Is there any effort being made to make this generally available?
Yes there is, and in fact in next/master there is generic dma_mmap_writecombine. I'm not quite sure how it behaves on non ARM archs though. But in theory it should fallback to a normal coherent mapping. Marek did a lot of work on this, I've put him on Cc.
OK, that's not so bad. Where is this code, can we merge it into ALSA? If not it's probably best to punt until after the merge window.
Mark Brown wrote:
On Thu, Jun 28, 2012 at 02:15:38PM +0200, Takashi Iwai wrote:
So far, only ARM has dma_mmap_writecombine(), thus the build on other arch would fail as is.
Oh, dear - this means we don't actually have a generic API at all. Is there any effort being made to make this generally available?
http://lkml.org/lkml/2012/6/15/27: | Commit 9adc5374 ('common: dma-mapping: introduce mmap method') added a | generic method for implementing mmap user call to dma_map_ops structure. | | This patch converts ARM and PowerPC architectures (the only providers of | dma_mmap_coherent/dma_mmap_writecombine calls) to use this generic | dma_map_ops based call and adds a generic cross architecture | definition for dma_mmap_attrs, dma_mmap_coherent, dma_mmap_writecombine | functions. | | The generic mmap virt_to_page-based fallback implementation is provided for | architectures which don't provide their own implementation for mmap method. | | Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com | Reviewed-by: Kyungmin Park kyungmin.park@samsung.com | --- | Hello, | This patch is a continuation of my works on dma-mapping cleanup and | unification. Previous works (commit 58bca4a8fa ('Merge branch | 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping') | has been merged to v3.4-rc2. Now I've focuses on providing implementation | for all architectures so the drivers and some cross-architecture common | helpers (like for example videobuf2) can start using this new api. | | I'm not 100% sure if the PowerPC changes are correct. The cases of | dma_iommu_ops and vio_dma_mapping_ops are a bit suspicious for me, but I | have no way to test and check if my changes works for that hardware. | | Best regards | Marek Szyprowski | Samsung Poland R&D Center
Regards, Clemens
participants (4)
-
Clemens Ladisch
-
Lars-Peter Clausen
-
Mark Brown
-
Takashi Iwai