From patchwork Wed May 23 13:07:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 8920 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 BA03B23F04 for ; Wed, 23 May 2012 13:07:58 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 56D54A18103 for ; Wed, 23 May 2012 13:07:58 +0000 (UTC) Received: by vcbfk26 with SMTP id fk26so1257413vcb.11 for ; Wed, 23 May 2012 06:07:57 -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 :mime-version:date:from:in-reply-to:to:message-id:x-mailer :references:cc:subject:x-beenthere:x-mailman-version:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:content-type:content-transfer-encoding:sender :errors-to:x-gm-message-state; bh=6Qt0qV3S/H3KDPmf4eiYZogcIBbneN4dvm4EgWrUhUc=; b=mjnU4mRxksKMyx3m4WCnd2Gbp6UnGRq7wviDQeV2wFfvpXBr6eSzkScPf1Q4O6bZuj ZnkpjJ8UHJ2tOwA/W8o6mfw4cTDNhLk1fRUK8wCeQd/8NgWfu3ZxFNqvRHr/mDBpGreX N+g3+ESBYw00jGI32efXsKZEyNOT5dlJ95qxbhalxga99JxgIWGi/xR/bmsi+Yq1Xc0j nH9PEnUCHHIZ0GcTchXkUIjet55UOFMoHUB7ttKEChRIL3hUjOxYzCnYVd5FgmvRUelJ vIwnD5FIT2O/PtPR6hV9dfvni02Frpn9dfp2n1euajRS8Otb4PwFrP5IiNqw6uR9Euy8 26+A== Received: by 10.50.222.202 with SMTP id qo10mr1818934igc.0.1337778477515; Wed, 23 May 2012 06:07:57 -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.231.35.72 with SMTP id o8csp443445ibd; Wed, 23 May 2012 06:07:54 -0700 (PDT) Received: by 10.213.14.198 with SMTP id h6mr1159765eba.99.1337778473055; Wed, 23 May 2012 06:07:53 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id n19si8392945wee.90.2012.05.23.06.07.51; Wed, 23 May 2012 06:07:53 -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 1SXBI5-0006Ur-Gu; Wed, 23 May 2012 13:07:49 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SXBI3-0006Tt-C5 for linaro-mm-sig@lists.linaro.org; Wed, 23 May 2012 13:07:47 +0000 MIME-version: 1.0 Received: from euspt2 ([210.118.77.13]) by mailout3.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0M4H00AS18FI9A60@mailout3.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 23 May 2012 14:06:54 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M4H003TV8GUN0@spt2.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 23 May 2012 14:07:42 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id C784127004E; Wed, 23 May 2012 15:19:01 +0200 (CEST) Date: Wed, 23 May 2012 15:07:24 +0200 From: Tomasz Stanislawski In-reply-to: <1337778455-27912-1-git-send-email-t.stanislaws@samsung.com> To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Message-id: <1337778455-27912-2-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 References: <1337778455-27912-1-git-send-email-t.stanislaws@samsung.com> Cc: pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCH 01/12] 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: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQkEJjH+0Fb7JXDVgzF8nQIt/81fkJg2WlyQDtOsYSqfFvVF1sMtZ0y/AaqXUUgxG9TkaD9b From: Marek Szyprowski Let mmap method to use dma_mmap_coherent call. This patch depends on DMA mapping redesign patches because the usage of dma_mmap_coherent breaks dma-contig allocator for architectures other than ARM and AVR. Signed-off-by: Marek Szyprowski Acked-by: Laurent Pinchart --- drivers/media/video/videobuf2-dma-contig.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 9c213bc..52b4f59 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -224,14 +224,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) { + printk(KERN_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); + + printk(KERN_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; } /*********************************************/