Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-mips@linux-mips.org
Cc: ralf@linux-mips.org
Subject: [PATCH] mips: Add dma_mmap_coherent()
Date: Mon, 18 Aug 2008 15:21:25 +0200	[thread overview]
Message-ID: <s5hk5eezcfe.wl%tiwai@suse.de> (raw)

Hi,

I've been trying to fix a long-standing bug in ALSA, the mmap of
pages via dma_mmap_coherent().  Since the sound drivers need to expose
the whole buffer via mmap and the buffers are allocated via
dma_alloc_coherent(), it causes Oops on some architectures like MIPS.
One of the fix patches is this one, the addition of
dma_mmap_coherent() to MIPS architecture.

This implementation is pretty lazy (and untested) as you see below.

The whole patches are found on topic/dma-fix branch on sound-2.6 git
tree
  git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

The gitweb URL of the branch is:
  http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;h=topic/dma-fix

Any review and comments would be appreciated.


Thanks in advance,

Takashi


[PATCH] mips: implement dma_mmap_coherent()

A lazy version of dma_mmap_coherent() implementation for MIPS.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 891312f..723dd64 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -387,3 +387,15 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 }
 
 EXPORT_SYMBOL(dma_cache_sync);
+
+int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+		      void *cpu_addr, dma_addr_t handle, size_t size)
+{
+	struct page *pg;
+	cpu_addr = (void *)dma_addr_to_virt(handle);
+	pg = virt_to_page(cpu_addr);
+	return remap_pfn_range(vma, vma->vm_start,
+			       page_to_pfn(pg) + vma->vm_pgoff,
+			       size, vma->vm_page_prot);
+}
+EXPORT_SYMBOL(dma_mmap_coherent);
diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index c64afb4..ab12cd4 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -68,6 +68,9 @@ extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 	       enum dma_data_direction direction);
 
+extern int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
+			     void *cpu_addr, dma_addr_t handle, size_t size);
+
 #if 0
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 

             reply	other threads:[~2008-08-18 13:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 13:21 Takashi Iwai [this message]
2008-08-20 16:27 ` [PATCH] mips: Add dma_mmap_coherent() James Bottomley
2008-08-20 16:53   ` Takashi Iwai
2008-08-20 17:58     ` James Bottomley
2008-08-21 10:19       ` Takashi Iwai
2008-08-21 13:55         ` James Bottomley
2008-08-21 16:01           ` Takashi Iwai
2008-08-21 16:03             ` Takashi Iwai
2008-08-21 21:41               ` Thomas Bogendoerfer
2008-08-22  6:07                 ` Takashi Iwai
2008-08-22  6:07                   ` Takashi Iwai
2008-08-22  9:41                   ` Thomas Bogendoerfer
2008-08-22 10:23                     ` Takashi Iwai
2008-08-22 10:23                       ` Takashi Iwai
2008-08-22 14:36                       ` Thomas Bogendoerfer
2008-08-22 14:47                         ` Takashi Iwai
2008-08-22 14:47                           ` Takashi Iwai
2008-08-21 10:20       ` Ralf Baechle
2008-08-21 10:25         ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2008-08-22 12:04 Joel Soete
2008-08-22 12:04 ` Joel Soete
2008-08-22 12:17 ` Takashi Iwai
2008-08-23 19:39   ` Joel Soete
2008-08-26 15:25     ` Takashi Iwai
2008-08-26 21:01       ` Grant Grundler
2008-08-27  5:42         ` Takashi Iwai
2008-08-27 10:38           ` Ralf Baechle
2008-08-27 14:06           ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hk5eezcfe.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox