linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.39 v2] V4L: videobuf-dma-contig: fix mmap_mapper broken on ARM
@ 2011-04-12 21:06 Janusz Krzysztofik
  2011-04-12 21:40 ` Russell King - ARM Linux
  2011-04-13 12:03 ` [PATCH 2.6.39 v2] " Sergei Shtylyov
  0 siblings, 2 replies; 17+ messages in thread
From: Janusz Krzysztofik @ 2011-04-12 21:06 UTC (permalink / raw)
  To: linux-arm-kernel

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 <jkrzyszt@tis.icnet.pl>
---
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(-)

--- 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,

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-04-19 12:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12 21:06 [PATCH 2.6.39 v2] V4L: videobuf-dma-contig: fix mmap_mapper broken on ARM Janusz Krzysztofik
2011-04-12 21:40 ` Russell King - ARM Linux
2011-04-12 22:12   ` Theodore Kilgore
2011-04-13 10:52   ` Janusz Krzysztofik
2011-04-13 18:32     ` Russell King - ARM Linux
2011-04-13 20:56       ` Janusz Krzysztofik
2011-04-13 22:00         ` Russell King - ARM Linux
2011-04-13 22:43           ` Janusz Krzysztofik
2011-04-19  6:08           ` [REVERT] " Jiri Slaby
2011-04-19 12:37             ` Mauro Carvalho Chehab
2011-04-13 12:03 ` [PATCH 2.6.39 v2] " Sergei Shtylyov
2011-04-13 13:11   ` Janusz Krzysztofik
2011-04-13 17:36     ` Sergei Shtylyov
2011-04-13 21:01       ` Janusz Krzysztofik
2011-04-13 21:16         ` Janusz Krzysztofik
2011-04-15 12:25           ` Sergei Shtylyov
2011-04-14 11:17         ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).