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: 1235701 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EE40640D45 for ; Wed, 25 Jul 2012 06:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932851Ab2GYGbA (ORCPT ); Wed, 25 Jul 2012 02:31:00 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:63520 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932884Ab2GYGaU (ORCPT ); Wed, 25 Jul 2012 02:30:20 -0400 Received: by yenl2 with SMTP id l2so358479yen.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=fJV10U+3iz/gYfhCd/yMNtpPIBAgCeZSUp07++6jIkHcdzkkHJkybO6jgEYaXvNV4t y6lfpPT30d9ceGSpoqYkO4pDmWmtnnybYOSGlvmJXDu9lccjJWK/jZzDxlXym4Wsv0S5 zFE0HF0e/eTnOkb/wBTvrMZhkvxRhmhf8f3/6tBXENncpyJP8h8VNY9brzpfnV9Ifi3o Nhw5BfpXa/tid0jtUkZAXkWUFeatzBgacVwHbDTWw8EV+72zadk1EQmVdD1JYHWFTJOF m9dR3W/GrfSK5neCp+0vS1QJnbUm1D9fG33tPz5LtVxzi+H0PovzU52CntVv5Be4wLiR U5Xg== 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: ALoCoQm0i5TyAFwaNCTuPHEo+rdNStulpPgbi6jW6hGV6xur4BFL/34VbNLkcu1dc0VzH0BxOFso 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,