From patchwork Wed Oct 10 14:46:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 12125 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4BA8623EFB for ; Wed, 10 Oct 2012 14:58:30 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id DCA13A18F35 for ; Wed, 10 Oct 2012 14:58:29 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so422494iag.11 for ; Wed, 10 Oct 2012 07:58:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=BuIwZ4zHNshVePtjmMR7zt2zIM0afKeXsDDDtbuHysw=; b=kjakN+IIkv0lyhgdviehju7KNGIx+hrLB+UfmHC/MgflrGGlrJ0whad/rhmB9NIjVZ K7wSy8VB6C5t6MF8NCmKYFC/BO7Aiuhhmc+K/Dr5S4Z7pf47+dX0ei+IhYz+agLeMOyM F/EPiEOOgWqDM9hi0695QW4Fj4J3f0PJA3Ulo0fY2T9oPNClCkwBnztmxPuUqjBzMdeY yqh9aRrGGfrtTwtWFa04PwTyQ/Tdcsg/xOpU58U16eO9GtTbpArxfSV9nbS285LWAWjF 6BhD+EBu/pADwTUywoaqIHQaryVkNQsqbuiy222PkM+8c1fG8YZLmJA0WqB1+glZ4kHc P2qA== Received: by 10.50.77.138 with SMTP id s10mr5484970igw.70.1349881109323; Wed, 10 Oct 2012 07:58:29 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp236872igt; Wed, 10 Oct 2012 07:58:27 -0700 (PDT) Received: by 10.204.128.89 with SMTP id j25mr8229601bks.23.1349881106626; Wed, 10 Oct 2012 07:58:26 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id ie15si2811399bkc.143.2012.10.10.07.58.25; Wed, 10 Oct 2012 07:58:26 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TLxjr-00029s-VK; Wed, 10 Oct 2012 14:58:24 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TLxjq-00029e-G5 for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 14:58:23 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MBO002UGMWVZT10@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:58:20 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-36-50758d0c53c9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BD.4A.03783.C0D85705; Wed, 10 Oct 2012 23:58:20 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MBO002YDME0EC70@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:58:20 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Wed, 10 Oct 2012 16:46:35 +0200 Message-id: <1349880405-26049-17-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> References: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAV2e3tIAg4XnuC2+XHnI5MDocfvf Y+YAxigum5TUnMyy1CJ9uwSujD+3V7AXrFGuONO2hL2BcbNsFyMnh4SAicT87feYIGwxiQv3 1rN1MXJxCAksYpR4tPgMO4Szlkli89RLjCBVbEAdx5Z8BrNFBBwkTt+dxQxSxCywhlnixcob bCAJYYE4if0zDgEVcXCwCKhKbD3iBhLmFfCUWP7lIjvENnmJp/f7wMo5geIX5k1nBrGFBDwk /q/fzDSBkXcBI8MqRtHUguSC4qT0XEO94sTc4tK8dL3k/NxNjGCvP5PawbiyweIQowAHoxIP b0ZUSYAQa2JZcWXuIUYJDmYlEV5Tn9IAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzNHikBQgLp iSWp2ampBalFMFkmDk6pBsZC8YP38vddWJaweJn77NNBiWEMStOsTj6df1WfsWWif8S5zb+s GTZWd2QKiYU6vVmXUH3F7mq512Pblj+p8iWrvp85lL1+n73uWnehorav0iUrbp7dem/1r9wn oSf1d7w3kTK4+OuKfLZoacZilW9hQm8FX+WJP1842a7x04ZFzBP+dHIulVinxFKckWioxVxU nAgATz9q1PYBAAA= Cc: k.debski@samsung.com, s.nawrocki@samsung.com, pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, airlied@redhat.com, remi@remlab.net Subject: [Linaro-mm-sig] [PATCHv10 16/26] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQnRlVdPa/mDhxFe3sJc0BP5OfsTHYX5iWC5Yyw7HX+vGUjdRZmFTnbhcoqmDFFN216qWAOY From: Marek Szyprowski Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent Pinchart. The function is no longer used in vb2 code. Signed-off-by: Marek Szyprowski Signed-off-by: Tomasz Stanislawski Acked-by: Laurent Pinchart Acked-by: Hans Verkuil --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 28 +++++++++++++++-- drivers/media/v4l2-core/videobuf2-memops.c | 40 ------------------------ include/media/videobuf2-memops.h | 5 --- 3 files changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index a5804cf..0e065ce 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -178,14 +178,38 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma) { struct vb2_dc_buf *buf = buf_priv; + int ret; if (!buf) { printk(KERN_ERR "No buffer to map\n"); return -EINVAL; } - return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size, - &vb2_common_vm_ops, &buf->handler); + /* + * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to + * map whole buffer + */ + vma->vm_pgoff = 0; + + ret = dma_mmap_coherent(buf->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); + + pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %ld\n", + __func__, (unsigned long)buf->dma_addr, vma->vm_start, + buf->size); + + return 0; } /*********************************************/ diff --git a/drivers/media/v4l2-core/videobuf2-memops.c b/drivers/media/v4l2-core/videobuf2-memops.c index 504cd4c..81c1ad8 100644 --- a/drivers/media/v4l2-core/videobuf2-memops.c +++ b/drivers/media/v4l2-core/videobuf2-memops.c @@ -137,46 +137,6 @@ int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size, EXPORT_SYMBOL_GPL(vb2_get_contig_userptr); /** - * vb2_mmap_pfn_range() - map physical pages to userspace - * @vma: virtual memory region for the mapping - * @paddr: starting physical address of the memory to be mapped - * @size: size of the memory to be mapped - * @vm_ops: vm operations to be assigned to the created area - * @priv: private data to be associated with the area - * - * Returns 0 on success. - */ -int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr, - unsigned long size, - const struct vm_operations_struct *vm_ops, - void *priv) -{ - int ret; - - size = min_t(unsigned long, vma->vm_end - vma->vm_start, size); - - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT, - size, vma->vm_page_prot); - if (ret) { - printk(KERN_ERR "Remapping memory failed, error: %d\n", ret); - return ret; - } - - vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED; - vma->vm_private_data = priv; - vma->vm_ops = vm_ops; - - vma->vm_ops->open(vma); - - pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n", - __func__, paddr, vma->vm_start, size); - - return 0; -} -EXPORT_SYMBOL_GPL(vb2_mmap_pfn_range); - -/** * vb2_common_vm_open() - increase refcount of the vma * @vma: virtual memory region for the mapping * diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h index 84e1f6c..f05444c 100644 --- a/include/media/videobuf2-memops.h +++ b/include/media/videobuf2-memops.h @@ -33,11 +33,6 @@ extern const struct vm_operations_struct vb2_common_vm_ops; int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size, struct vm_area_struct **res_vma, dma_addr_t *res_pa); -int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr, - unsigned long size, - const struct vm_operations_struct *vm_ops, - void *priv); - struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma); void vb2_put_vma(struct vm_area_struct *vma);