From patchwork Wed Jul 25 06:29:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideki EIRAKU X-Patchwork-Id: 1235821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 4D0D0E006E for ; Wed, 25 Jul 2012 06:41:51 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1StvDt-0005fO-N7; Wed, 25 Jul 2012 06:37:29 +0000 Received: from mail-yx0-f177.google.com ([209.85.213.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Stv6y-00058u-6K for linux-arm-kernel@lists.infradead.org; Wed, 25 Jul 2012 06:30:22 +0000 Received: by mail-yx0-f177.google.com with SMTP id r9so377073yen.36 for ; Tue, 24 Jul 2012 23:30:19 -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=CzBk2nkWqcrbSFeTQmBkMh9oWhU6iPBPJkd2XqLBwJr4Pnk1YQ3qvNGTufuK92rZ90 cObz371Ek8ipZK3SaZ0IIv21QmWfqz8u4yqE4icd82pv2FDQL84xBRA2E8ifzLWHLOgI UXuzNxai8T24aoFZldMwNz5Rli1EQVbnpQ1eH8ALUAsvF0TVHUIMyOgOmnceebEpaFWJ Le9M/am5TvlDDSboryPzY1K1aD+peNB1d1gAC/GYLMWgOOSAgYNK/TbGtoxgifMLOrAl 4nccjZ7ZWRDrku/p1KcjLVBhMNhA6wgw94RboPusrH3BjPQImN+u7EB0faSZeSxZLdal QBfA== Received: by 10.66.76.226 with SMTP id n2mr10307447paw.67.1343197818777; Tue, 24 Jul 2012 23:30:18 -0700 (PDT) Received: from localhost.localdomain ([219.106.231.132]) by mx.google.com with ESMTPS id jz4sm13740730pbc.17.2012.07.24.23.30.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 23:30:18 -0700 (PDT) From: Hideki EIRAKU To: Russell King , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , Florian Tobias Schandinat Subject: [PATCH 2/3] media: videobuf2-dma-contig: use dma_mmap_coherent if available Date: Wed, 25 Jul 2012 15:29:23 +0900 Message-Id: <1343197764-13659-3-git-send-email-hdk@igel.co.jp> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1343197764-13659-1-git-send-email-hdk@igel.co.jp> References: <1343197764-13659-1-git-send-email-hdk@igel.co.jp> X-Gm-Message-State: ALoCoQldzfrOmonQ3yLWks4JvULd1Kcq1mmQTBnI3nl4p+oAp9pVvfuZcxrY8lsQHac2lyaXMift 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.213.177 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 , 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,