The patch tries to implement a solution suggested by Russell King, http://lists.infradead.org/pipermail/linux-arm-kernel/2010-December/035264.html. It is expected to solve video buffer allocation issues for at least a few soc_camera I/O memory less host interface drivers, designed around the videobuf_dma_contig layer, which allocates video buffers using dma_alloc_coherent(). Created against linux-2.6.37-rc5. Tested on ARM OMAP1 based Amstrad Delta with a WIP OMAP1 camera patch, patterned upon two mach-mx3 machine types which already try to use the dma_declare_coherent_memory() method for reserving a region of system RAM preallocated with another dma_alloc_coherent(). Compile tested for all modified files except arch/sh/drivers/pci/fixups-dreamcast.c. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> --- I intended to quote Russell in my commit message and even asked him for his permission, but since he didn't respond, I decided to include a link to his original message only. Documentation/DMA-API.txt | 18 +++++++---- arch/arm/mach-mx3/mach-mx31moboard.c | 2 - arch/arm/mach-mx3/mach-pcm037.c | 2 - arch/sh/drivers/pci/fixups-dreamcast.c | 6 +++ drivers/base/dma-coherent.c | 12 +------ drivers/base/dma-mapping.c | 4 +- drivers/media/video/sh_mobile_ceu_camera.c | 20 +++++++++++- drivers/scsi/NCR_Q720.c | 15 +++++++-- drivers/usb/gadget/langwell_udc.c | 25 ++++++++++++---- drivers/usb/gadget/langwell_udc.h | 1 drivers/usb/host/ohci-sm501.c | 45 ++++++++++++++++++++--------- drivers/usb/host/ohci-tmio.c | 14 ++++++++- include/asm-generic/dma-coherent.h | 2 - include/linux/dma-mapping.h | 6 +-- 14 files changed, 122 insertions(+), 50 deletions(-) --- linux-2.6.37-rc5/include/linux/dma-mapping.h.orig 2010-12-09 23:09:05.000000000 +0100 +++ ...
There's no problem quoting messages which were sent to public mailing lists, especially when there's a record of what was said in public archives too. A side note for the mx3 folk: although it's not specified in DMA-API, memory allocated from dma_alloc_coherent() on ARM is already memset I didn't see anything changing the dev->dma_mem->virt_base type to drop the __iomem attribute (which I suspect shouldn't be there - we're returning it via a void pointer anyway, so I think the whole coherent part of the DMA API should be __iomem-less. It also pushes the sparse address space warnings to the right place IMHO too. --
The -tip folks have started using LKML-Reference tags to help with this, although I don't believe its usage is officially documented anywhere. --
There was no __iomem attribute specified for the .virt_base member of the struct dma_coherent_mem, pure (void *), so nothing to be changed there. Thanks, --
The arch/sh/drivers/pci/fixups-dreamcast.c build fine. Acked-by: Paul Mundt <lethal@linux-sh.org> --
Another note: with the pair of patches I've sent to the linux-arm-kernel list earlier today changing the DMA coherent allocator to steal memory from the system at boot. This means there's less need to pre-allocate DMA memory - if there's sufficient contiguous space in the DMA region to satisfy the allocation, then the allocation will succeed. It's also independent of the maximum page size from the kernel's memory allocators too. So I suspect that mach-mx3 (and others) no longer need to do their own pre-allocation anymore if both of these patches go in. --
Then, my rationale will no longer be valid. So, either drop my patch if you think you have finally come out with a better solution which doesn't touch any system-wide API, or suggest a new justification for use in the commit log if you think still the patch solves something important. Thanks, Janusz --
No. It's not clear whether my pair of patches are both going to make it into the kernel, or even what timeframe they're going to make it in. Irrespective of that, we do need a solution to this problem so that this stuff starts working again. In any case, your patch makes complete sense through and through: 1. if other architecture/machine wants to reserve a chunk of DMA-able memory for a specific device (eg, because of a restriction on the number of DMA address bits available) and it's completely DMA coherent, it shouldn't have to go through the pains of having that memory unconditionally ioremap'd. 2. What if the memory being provided from some source where you already have the mapping setup in a specific way for a reason? For example, say I have an ARM design, and all peripherals are in a single 256MB memory region, which includes a chunk of SRAM set aside for DMA purposes. Let's say I can map that really efficiently by a few page table entries, which means relatively little TLB usage for accessing this region. With the current API, it becomes difficult to pass that mapping through the dma_declare_coherent_memory() because the physical address goes through ioremap(), which obfuscates what's going on. However, if I could pass the bus and virtual address, then there's no ambiguity over what I want to do. What if I want to declare memory to the DMA coherent allocator with attributes different from what ioremap() gives me, maybe with write combining properties (because it happens to be safe for the specific device) ? Passing the virtual address allows the API to become much more flexible. Not only that, it allows it to be used on ARM, rather than becoming (as it currently stands) prohibited on ARM. I believe that putting ioremap() inside this API was the wrong thing to do, and moving it outside makes the API much more flexible and usable. It's something I still fully support. --
Thanks, this is what I was missing, having my point of view rather my machine centric, with not much wider experience. I'll quote your argumentation in next iteration of this patch if required. Thanks, Janusz --
On Sat, 25 Dec 2010, Janusz Krzysztofik wrote: AFAIU, this patch is similar to the previous two attempts: http://www.spinics.net/lists/linux-sh/msg05482.html and http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/22271 but is even more intrusive, because those two previous attempts added new functions, whereas this one is modifying an existing one. Both those two attempts have been NACKed by FUJITA Tomonori, btw, he is not on the otherwise extensive CC list for this patch. Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ --
Hi Guennadi, I composed that extensive CC list based on what I was able to find in MAINTAINERS for any files being modified, additionally adding Catalin Marinas as one of the idea promoters. FUJITA Tomonori's name was not specified there, nor was he mentioned as an author of any of those files. Adding him per your advice. NB, the rationale quoted above is provided by courtesy of Russell King, and not of my authoriship, as it may look like at a first glance from your snip result. Thanks, Janusz --
