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: 1241941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 2417B3FC5A for ; Thu, 26 Jul 2012 11:46:25 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuMO7-00079F-HM; Thu, 26 Jul 2012 11:37:52 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SuM0q-0001nf-V0 for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 11:14:07 +0000 Received: by pbbrq13 with SMTP id rq13so3323084pbb.36 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=KZ1unPeU9YcUeKo9XhOmEyGHqPvrA0DgLJgZ/ESKHVuKyyxCgeCbfyXo7yNjaxwNZE mFBQtbwsNqlLnowqz4RnzYk7vjYX+Hwos17hI7PYRXeZ0LaqUhKhx0wQhlFKGy6lcmDq /8bVLxSiECSndtTRwIlyOBKH5rQelMiRIM/tBsOUpwCxbpt3JywRbrief0QAhr/0Zotw G74vjeoIhzFk1i1hz4kbYSy4w7gZawhf9E4PDWglg/4I9D/52zsILiT8S9zBAtcZ0Xk3 iiw2ju5EIRqu/2l7STV6WYXUK03Tx6t4zymYHxnGwoCFC0+qDeGbgTdpsuOcY75aE61m QHYw== 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 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: ALoCoQkjo5AyDrzz5n/FP8MR00dwyPfGVXiVsgpwT8aVpk08T2AcVd1CYDke3ymBk5hUTjYYJZzV X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Katsuya MATSUBARA , linux-fbdev@vger.kernel.org, Hideki EIRAKU , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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,