From patchwork Thu Jul 26 11:13:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideki EIRAKU X-Patchwork-Id: 1241731 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6C736DFFC1 for ; Thu, 26 Jul 2012 11:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262Ab2GZLOQ (ORCPT ); Thu, 26 Jul 2012 07:14:16 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:47092 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752268Ab2GZLNr (ORCPT ); Thu, 26 Jul 2012 07:13:47 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so3069479pbb.19 for ; Thu, 26 Jul 2012 04:13:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=0VaRkRj8wq5fZdP0Xe82rYGHt4/d2WSdpv09bteYTgY=; b=d97hbnO6EnX7U4jAh35y5AhBlgiCWZJHUlmCmQoOM4178kVd2ebgfo3shf2+FbReao RwR843PR4W/oxSDlk/axoSGHIz9S2EvVtJmkVp8RawyNyQGzRQAlJ3AlwfbBOIsJYEKX 8OFZU3QW1+MuOTQBdaZnosW8wz4GFoaKlyyIiMWShT/Y+RXAm8+savxV/uH8evfBjnJK grCa3JS3w0f3a+uF7FwkF1qA1b6tpn/UaiDa2o4/BnaPzbYQpepa+4tsCoOBE1kOJvWX ddIjd/1xvd7KldknDPv83Gmw/VLPj6bHdQ777Jo0YGhQudkwRCe4E4z0zymGNxuIQPPn rAng== Received: by 10.68.222.9 with SMTP id qi9mr3971783pbc.164.1343301227165; Thu, 26 Jul 2012 04:13:47 -0700 (PDT) Received: from localhost.localdomain ([219.106.231.132]) by mx.google.com with ESMTPS id ru10sm16359210pbc.50.2012.07.26.04.13.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:13:46 -0700 (PDT) From: Hideki EIRAKU To: Russell King , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , Florian Tobias Schandinat , Jaroslav Kysela , Takashi Iwai Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, Katsuya MATSUBARA , Hideki EIRAKU Subject: [PATCH v2 3/4] media: videobuf2-dma-contig: use dma_mmap_coherent if available Date: Thu, 26 Jul 2012 20:13:10 +0900 Message-Id: <1343301191-26001-4-git-send-email-hdk@igel.co.jp> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1343301191-26001-1-git-send-email-hdk@igel.co.jp> References: <1343301191-26001-1-git-send-email-hdk@igel.co.jp> X-Gm-Message-State: ALoCoQnhOAyjwC45t0ml8MHLij1AxiO+8fOEePMnrEvPbQ53Sy8TFqv3hsblyh23xSbhEReFErm0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Previously the vb2_dma_contig_mmap() function was using a dma_addr_t as a physical address. The two addressses are not necessarily the same. For example, when using the IOMMU funtion on certain platforms, dma_addr_t addresses are not directly mappable physical address. dma_mmap_coherent() maps the address correctly. It is available on ARM platforms. Signed-off-by: Hideki EIRAKU --- drivers/media/video/videobuf2-dma-contig.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 4b71326..4dc85ab 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -101,14 +101,32 @@ static unsigned int vb2_dma_contig_num_users(void *buf_priv) static int vb2_dma_contig_mmap(void *buf_priv, struct vm_area_struct *vma) { struct vb2_dc_buf *buf = buf_priv; +#ifdef ARCH_HAS_DMA_MMAP_COHERENT + int ret; +#endif if (!buf) { printk(KERN_ERR "No buffer to map\n"); return -EINVAL; } +#ifdef ARCH_HAS_DMA_MMAP_COHERENT + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + ret = dma_mmap_coherent(buf->conf->dev, vma, buf->vaddr, buf->dma_addr, + buf->size); + if (ret) { + pr_err("Remapping memory failed, error: %d\n", ret); + return ret; + } + vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED; + vma->vm_private_data = &buf->handler; + vma->vm_ops = &vb2_common_vm_ops; + vma->vm_ops->open(vma); + return 0; +#else return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size, &vb2_common_vm_ops, &buf->handler); +#endif } static void *vb2_dma_contig_get_userptr(void *alloc_ctx, unsigned long vaddr,