From patchwork Tue Oct 2 14:27:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 11937 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 011481A52FC for ; Tue, 2 Oct 2012 14:29:55 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id A1B56A18672 for ; Tue, 2 Oct 2012 14:29:54 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so14258231iej.11 for ; Tue, 02 Oct 2012 07:29:54 -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=ugAIkVYroUHH2pi07vxiuNhxq2UDqh4QeHItyYuIcKU=; b=A6omjI20+vaR9aZBUzZFbAwcL2LfrsaSX1bbo3of5KR5N06oqGU22vI3hcyQWyxcER m7FM3k1OOjsw433P2QtImqt1YoG2+2N9FcZ7JljdGAf3CQfaJ69DKlW01k40fjod7m9V igAbPz+xA7gf6P0nBftfHaJkafpxHnZa23tRe2+CDij3K7zxQLNQcCn0wMJLyLruOKnn hXYUWw7JGUQc8JzZ6/bap2iNrZywZLF8TLx4npW358vGIiS8StI157i21ExMqXyJvf2X R6MaX6H8sruV4UcUDVsbpk6o5cAZwqlSAfFm+GMR2eeYwLQZFnH4jyn0scScsJlK+Smu J1TA== Received: by 10.50.154.137 with SMTP id vo9mr8370752igb.28.1349188194383; Tue, 02 Oct 2012 07:29:54 -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.184.232 with SMTP id ex8csp85009igc; Tue, 2 Oct 2012 07:29:53 -0700 (PDT) Received: by 10.204.150.210 with SMTP id z18mr6751493bkv.53.1349188192977; Tue, 02 Oct 2012 07:29:52 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id he1si1702828bkc.79.2012.10.02.07.29.51; Tue, 02 Oct 2012 07:29:52 -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 1TJ3Tq-0004nq-KK; Tue, 02 Oct 2012 14:29:50 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TJ3To-0004na-B6 for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 14:29:48 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MB900B5US9MIYB0@mailout3.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 23:29:46 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-7e-506afa5a3d44 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 06.AE.03783.A5AFA605; Tue, 02 Oct 2012 23:29:46 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MB9005A7S65K790@mmp2.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 02 Oct 2012 23:29:46 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Tue, 02 Oct 2012 16:27:27 +0200 Message-id: <1349188056-4886-17-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349188056-4886-1-git-send-email-t.stanislaws@samsung.com> References: <1349188056-4886-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsVy+t9jQd2oX1kBBgsnmlp8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGf8uXGMpuKZU8X0vVwPjM5kuRk4OCQETiQ9fL7BD2GISF+6t Z+ti5OIQEpjOKHFp2UdmCGctk8SPlwvYQKrYgDqOLfnMCGKLCDhInL47C6yIWWANs8SLlTeA ijg4hAViJe5fMAYxWQRUJfqfp4OU8wp4SKy6to8ZYpm8xNP7fWAjOYHiP59cYAGxhQTcJfYs b2KbwMi7gJFhFaNoakFyQXFSeq6hXnFibnFpXrpecn7uJkawx59J7WBc2WBxiFGAg1GJh3fn ycwAIdbEsuLK3EOMEhzMSiK81vezAoR4UxIrq1KL8uOLSnNSiw8xSnOwKInzNnukBAgJpCeW pGanphakFsFkmTg4pRoY5buCDJXkKw59nT/J9MDrO6cebNgguUT4/Mu6NY8ev5URN3TSyblw J+t+LFepZv4v/hxDp4cyf46mfgxfKhFfLBPsV7Rrz2wvW7nKJeppmp+X7mhsU2jo6rqWx1ki LuXcKH/F30wq6Cs787LmPgWv2OMsm+YkP160Idxd7M8G/RUTUp+s1p6jxFKckWioxVxUnAgA nYnfXfQBAAA= 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] [PATCHv9 16/25] 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: ALoCoQl1RoNcCqanVynCsN/x2m9ANAUagH5RcfOZ0mXPhDpCTRa67BrmGOtG6+tcgAfQhMokS/5P 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 --- drivers/media/video/videobuf2-dma-contig.c | 28 +++++++++++++++++-- drivers/media/video/videobuf2-memops.c | 40 ---------------------------- include/media/videobuf2-memops.h | 5 ---- 3 files changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index a5804cf..0e065ce 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/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/video/videobuf2-memops.c b/drivers/media/video/videobuf2-memops.c index 504cd4c..81c1ad8 100644 --- a/drivers/media/video/videobuf2-memops.c +++ b/drivers/media/video/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);