From patchwork Tue Apr 12 21:06:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 6397 Return-path: Envelope-to: mchehab@pedra Delivery-date: Tue, 12 Apr 2011 18:08:51 -0300 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1Q9kpP-0000XK-GT for mchehab@pedra; Tue, 12 Apr 2011 18:08:51 -0300 Received: from casper.infradead.org [85.118.1.10] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Tue, 12 Apr 2011 18:08:51 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Q9koR-0008QO-2p; Tue, 12 Apr 2011 21:07:51 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932547Ab1DLVHl (ORCPT + 1 other); Tue, 12 Apr 2011 17:07:41 -0400 Received: from d1.icnet.pl ([212.160.220.21]:57684 "EHLO d1.icnet.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932541Ab1DLVHk (ORCPT ); Tue, 12 Apr 2011 17:07:40 -0400 Received: from 87-205-12-81.ip.netia.com.pl ([87.205.12.81] helo=vclass.localnet) by d1.icnet.pl with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Q9koF-0000R0-9J; Tue, 12 Apr 2011 23:07:39 +0200 To: Linux Media Mailing List Subject: [PATCH 2.6.39 v2] V4L: videobuf-dma-contig: fix mmap_mapper broken on ARM Cc: Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Jiri Slaby From: Janusz Krzysztofik Organization: Tele-Info-System, Poznan, PL Date: Tue, 12 Apr 2011 23:06:34 +0200 MIME-Version: 1.0 Message-Id: <201104122306.34909.jkrzyszt@tis.icnet.pl> X-SA-Exim-Scanned: No (on d1.icnet); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: After switching from mem->dma_handle to virt_to_phys(mem->vaddr) used for obtaining page frame number passed to remap_pfn_range() (commit 35d9f510b67b10338161aba6229d4f55b4000f5b), videobuf-dma-contig stopped working on my ARM based board. The ARM architecture maintainer, Russell King, confirmed that using something like virt_to_phys(dma_alloc_coherent()) is not supported on ARM, and can be broken on other architectures as well. The author of the change, Jiri Slaby, also confirmed that his code may not work on all architectures. The patch tries to solve this regression by using virt_to_phys(bus_to_virt(mem->dma_handle)) instead of problematic virt_to_phys(mem->vaddr). I think this should work even if those translations would occure inaccurate for DMA addresses, since possible errors introduced by both translations, performed in opposite directions, should compensate. Tested on ARM OMAP1 based Amstrad Delta board. Signed-off-by: Janusz Krzysztofik Acked-by: Mauro Carvalho Chehab --- v1 -> v2 changes: - drop dma_mmap_coherent() path, it may not work correctly for device memory preallocated with dma_declare_coherent_memory(). drivers/media/video/videobuf-dma-contig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- git/drivers/media/video/videobuf-dma-contig.c.orig 2011-04-09 00:38:45.000000000 +0200 +++ git/drivers/media/video/videobuf-dma-contig.c 2011-04-12 22:36:44.000000000 +0200 @@ -300,8 +300,8 @@ static int __videobuf_mmap_mapper(struct vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); retval = remap_pfn_range(vma, vma->vm_start, - PFN_DOWN(virt_to_phys(mem->vaddr)), - size, vma->vm_page_prot); + PFN_DOWN(virt_to_phys(bus_to_virt(mem->dma_handle))), + size, vma->vm_page_prot); if (retval) { dev_err(q->dev, "mmap: remap failed with error %d. ", retval); dma_free_coherent(q->dev, mem->size,