From patchwork Tue Mar 1 08:21:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 5972 Return-path: Envelope-to: mchehab@pedra Delivery-date: Tue, 01 Mar 2011 07:25:42 -0300 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1PuMlx-0005ej-JM for mchehab@pedra; Tue, 01 Mar 2011 07:25:41 -0300 Received: from casper.infradead.org [85.118.1.10] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Tue, 01 Mar 2011 07:25:41 -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 1PuKqV-0006bQ-Tj; Tue, 01 Mar 2011 08:22:16 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755825Ab1CAIVw (ORCPT + 1 other); Tue, 1 Mar 2011 03:21:52 -0500 Received: from mail.pripojeni.net ([217.66.174.14]:42731 "EHLO smtp.pripojeni.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755519Ab1CAIVv (ORCPT ); Tue, 1 Mar 2011 03:21:51 -0500 Received: from localhost.localdomain ([217.66.174.142]) by smtp.pripojeni.net (Kerio Connect 7.1.3); Tue, 1 Mar 2011 09:21:43 +0100 From: Jiri Slaby To: mchehab@infradead.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jirislaby@gmail.com, Konrad Rzeszutek Wilk Subject: [PATCH v2 1/1] V4L: videobuf, don't use dma addr as physical Date: Tue, 1 Mar 2011 09:21:41 +0100 Message-Id: <1298967701-11889-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 1.7.4.1 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: mem->dma_handle is a dma address obtained by dma_alloc_coherent which needn't be a physical address as a hardware IOMMU can (and most likely will) return a bus address where physical != bus address. So ensure we are remapping (remap_pfn_range) the right page in __videobuf_mmap_mapper by using virt_to_phys(mem->vaddr) and not mem->dma_handle. While at it, use PFN_DOWN instead of explicit shift to obtain a frame number. This was discovered by a random review of the code when looking for something completely different. I'm not aware of any bug reports for this. However it is a bug because many v4l drivers use this layer and have no idea whether IOMMU is in the system and running or not. Signed-off-by: Jiri Slaby Cc: Mauro Carvalho Chehab Cc: Konrad Rzeszutek Wilk Acked-by: Konrad Rzeszutek Wilk --- This is a version with updated changelog. drivers/media/video/videobuf-dma-contig.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index c969111..19d3e4a 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c @@ -300,7 +300,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); retval = remap_pfn_range(vma, vma->vm_start, - mem->dma_handle >> PAGE_SHIFT, + PFN_DOWN(virt_to_phys(mem->vaddr)) size, vma->vm_page_prot); if (retval) { dev_err(q->dev, "mmap: remap failed with error %d. ", retval);