From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: [PATCH 1/8] mips: implement dma_mmap_coherent() Date: Fri, 10 Jul 2009 15:12:32 +0200 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from cantor.suse.de ([195.135.220.2]:56982 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751580AbZGJNMd (ORCPT ); Fri, 10 Jul 2009 09:12:33 -0400 Sender: linux-arch-owner@vger.kernel.org List-ID: To: linux-arch@vger.kernel.org Cc: Gerhard Pircher A lazy version of dma_mmap_coherent() implementation for MIPS. Signed-off-by: Takashi Iwai --- arch/mips/include/asm/dma-mapping.h | 4 ++++ arch/mips/mm/dma-default.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h index d16afdd..475fad3 100644 --- a/arch/mips/include/asm/dma-mapping.h +++ b/arch/mips/include/asm/dma-mapping.h @@ -73,6 +73,10 @@ 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); +#define ARCH_HAS_DMA_MMAP_COHERENT +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 diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index 7e48e76..6d71a2b 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -367,3 +367,16 @@ 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; + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + 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); -- 1.6.3.2