From: Takashi Iwai Subject: [PATCH 7/8] x86: implement dma_mmap_coherent() Date: Fri, 10 Jul 2009 15:15:45 +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]:57088 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbZGJNPq (ORCPT ); Fri, 10 Jul 2009 09:15:46 -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 x86. Signed-off-by: Takashi Iwai --- arch/x86/include/asm/dma-mapping.h | 16 ++++++++++++++++ include/linux/dma-mapping.h | 2 ++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index 1c3f943..4941ad9 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h @@ -139,4 +139,20 @@ static inline void dma_free_coherent(struct device *dev, size_t size, ops->free_coherent(dev, size, vaddr, bus); } +#define ARCH_HAS_DMA_MMAP_COHERENT +static inline int dma_mmap_coherent(struct device *dev, + struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t handle, + size_t size) +{ + struct dma_map_ops *ops = get_dma_ops(dev); + unsigned long pfn; + + if (ops->mmap_coherent) + return ops->mmap_coherent(dev, vma, cpu_addr, handle, size); + pfn = page_to_pfn(virt_to_page(cpu_addr)); + return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff, + size, vma->vm_page_prot); +} + #endif diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 07dfd46..9ddc6ae 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -58,6 +58,8 @@ struct dma_map_ops { enum dma_data_direction dir); int (*mapping_error)(struct device *dev, dma_addr_t dma_addr); int (*dma_supported)(struct device *dev, u64 mask); + int (*mmap_coherent)(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t handle, size_t size); int is_phys; }; -- 1.6.3.2