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: 1235711 Return-Path: X-Original-To: patchwork-linux-media@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 BF874DFFC0 for ; Wed, 25 Jul 2012 06:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932876Ab2GYGbJ (ORCPT ); Wed, 25 Jul 2012 02:31:09 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:63170 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932897Ab2GYGaT (ORCPT ); Wed, 25 Jul 2012 02:30:19 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so358402yen.19 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=R3l4TN5oOjCJyoBlbL04uR2zt8MmUfGCj1G930nCAfxOQ3KNEKOCM6kKNwbSIA3BRM EzAy0mKZESA+Y3pizNfCZlWZQrcR8PnZsv6s5T8pq5NJDLfyuEyXG3mMj8ngvrhh/TPP gSAenGv/pws6070Ces89qE+wxCwhWgwEfOv+2tM1RDAYqldmen31e0TK4gT3dkAjD/E9 iK0xIJ7nErewTGnPWBdhyliO3zmGjYKcky46nP1DRq+2zKA4P1qW7cdq6zBHIcdDDuMd dLBGTG+T9qGxfCR9Ei7BGtJf7R2bRlUNiNVdsamEgcQIcp9rByFpdm0PZCSGnD1tqhxI dq8g== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-fbdev@vger.kernel.org, Katsuya MATSUBARA , Hideki EIRAKU 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: ALoCoQmSN/B+1BybQwWoOUbBdVrJvibFdjF6n3ytg/cEXzjZPgM3ajmRQjQnGNvE4msKc/eTieae Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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,