From patchwork Mon Aug 6 09:55: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: 1277851 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 E5B3A40B2A for ; Mon, 6 Aug 2012 09:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755793Ab2HFJ4g (ORCPT ); Mon, 6 Aug 2012 05:56:36 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:64887 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755737Ab2HFJ4V (ORCPT ); Mon, 6 Aug 2012 05:56:21 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so2350022pbb.19 for ; Mon, 06 Aug 2012 02:56:20 -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=4VQJ0AP+ElgGADRdsK+rDAPTxojwLQFlsg0q5ytFrjE=; b=ONIoDwKRT8IbKZdVkF0itJ7EiajwWFpgVE8qgQDrcHneMqkoszmF9hDNlqvhfzdg0g PI4O2Nqefw5eA+tMxeMclvx4VnuoHNGr4+F0Ns7dLDpS4SI4gZ2kcGo6IqfxXZBwVcCI yNp5Z0xFhl5nw0Fsu6Zw6iEebqyjCUGz65pZP8zRVmbJQ+EpXzkUuuKpfJJYYL4IVM67 DCj+lOPgpjW24h0rB9ZaPleKoO/XpUK9Tv/U5mb5Wyh6fAfg2I/TqsJcIYipKoFf1+Qr SIka5PkmB02bv/J3BgKRJM8d0/oogW7fJybIkKYLxZjAnTdZJL/Wo1oBR9UJdX+VP2oE ZB6g== Received: by 10.68.223.35 with SMTP id qr3mr17961730pbc.83.1344246980790; Mon, 06 Aug 2012 02:56:20 -0700 (PDT) Received: from localhost.localdomain ([219.106.231.132]) by mx.google.com with ESMTPS id qd10sm8650359pbb.38.2012.08.06.02.56.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 02:56:20 -0700 (PDT) From: Hideki EIRAKU To: Russell King , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , Florian Tobias Schandinat , Jaroslav Kysela , Takashi Iwai Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, Katsuya MATSUBARA , Hideki EIRAKU Subject: [PATCH v3 3/4] media: videobuf2-dma-contig: use dma_mmap_coherent if available Date: Mon, 6 Aug 2012 18:55:23 +0900 Message-Id: <1344246924-32620-4-git-send-email-hdk@igel.co.jp> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1344246924-32620-1-git-send-email-hdk@igel.co.jp> References: <1344246924-32620-1-git-send-email-hdk@igel.co.jp> X-Gm-Message-State: ALoCoQktAt11pWjs1Dq9r17KAiiCuuJOlej87PZqbDcm6ZQWi75bfsfBnBfsrD7qo4L0q6H32ltg 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 | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index 4b71326..7eee9c5 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -101,14 +101,31 @@ 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 + 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,