lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 29 Jun 2012 15:53:16 +0530
From:	Laxman Dewangan <ldewangan@...dia.com>
To:	<tiwai@...e.de>, <lrg@...com>,
	<broonie@...nsource.wolfsonmicro.com>, <lars@...afoo.de>,
	<swarren@...dia.com>, <perex@...ex.cz>, <clemens@...isch.de>
CC:	<alsa-devel@...a-project.org>, <linux-kernel@...r.kernel.org>,
	Laxman Dewangan <ldewangan@...dia.com>
Subject: [PATCH 1/3] ALSA: pcm: add apis for writecombine dma buffer allocation

Add APIs for allocation/deallocation of writecombine dma buffer
for pcm substreams.
The write combine dma buffer is not supported on few
architecture like ARM and restricting these APIs support
for ARM specific.

This can be make available to other architecture if they
start supporting this.

Signed-off-by: Laxman Dewangan <ldewangan@...dia.com>
---
 include/sound/pcm.h     |   17 +++++++++++++++
 sound/core/pcm_native.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index e7afcc9..e1c8ac4 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1054,6 +1054,23 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s
 #define snd_pcm_lib_mmap_iomem	NULL
 #endif
 
+/**
+ * Allocate the write combine DMA buffer for the PCM streams.
+ * Not all architecture support the writecombine dma allocation and
+ * hence restricting this to ARM specific. Once all architecture
+ * support the writecombine dma buffer then these APIs will be available
+ * for all architecture.
+ */
+#ifdef CONFIG_ARM
+int snd_pcm_lib_alloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+		size_t size, int stream);
+void snd_pcm_lib_dealloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+		int stream);
+int snd_pcm_lib_mmap_writecombine_dma_buffer(
+		struct snd_pcm_substream *substream,
+		struct vm_area_struct *vma);
+#endif
+
 #define snd_pcm_lib_mmap_vmalloc NULL
 
 static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 53b5ada..fa56ad9 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3213,6 +3213,59 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream,
 EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem);
 #endif /* SNDRV_PCM_INFO_MMAP */
 
+#ifdef CONFIG_ARM
+int snd_pcm_lib_alloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+		size_t size, int stream)
+{
+	struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+	struct snd_dma_buffer *buf = &substream->dma_buffer;
+
+	buf->area = dma_alloc_writecombine(pcm->card->dev, size,
+				&buf->addr, GFP_KERNEL);
+	if (!buf->area)
+		return -ENOMEM;
+
+	buf->dev.type = SNDRV_DMA_TYPE_DEV;
+	buf->dev.dev = pcm->card->dev;
+	buf->private_data = NULL;
+	buf->bytes = size;
+
+	return 0;
+}
+EXPORT_SYMBOL(snd_pcm_lib_alloc_writecombine_dma_buffer);
+
+void snd_pcm_lib_dealloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+		int stream)
+{
+	struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+	struct snd_dma_buffer *buf;
+
+	if (!substream)
+		return;
+
+	buf = &substream->dma_buffer;
+	if (!buf->area)
+		return;
+
+	dma_free_writecombine(pcm->card->dev, buf->bytes,
+			buf->area, buf->addr);
+	buf->area = NULL;
+}
+EXPORT_SYMBOL(snd_pcm_lib_dealloc_writecombine_dma_buffer);
+
+int snd_pcm_lib_mmap_writecombine_dma_buffer(
+		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(snd_pcm_lib_mmap_writecombine_dma_buffer);
+#endif
+
 /*
  * mmap DMA buffer
  */
-- 
1.7.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ