Messages in this thread Patch in this message | | | Date | Sat, 21 Apr 2007 13:01:14 +0200 (CEST) | From | Guennadi Liakhovetski <> | Subject | Re: [PATCH] dma_declare_coherent_memory wrong allocation |
| |
On Sat, 21 Apr 2007, Andrew Morton wrote:
> On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote: > > > Hi > > > > Either I've finally gone blind on this Friday 13th or... Looks like this > > almost 3 year old function has a bug. Patch below compile-tested... in a > > way.
[patch skipped]
> Looks that way to me, too.
Then I'll dare suggest arch/cris - the second and last arch implementing this API - has the same problem. Maintainer added to cc:, patch below.
> It also hopes like hell that `size' was a multiple of PAGE_SIZE.
Well, this API seems to have a bigger problem: it is difficult to get to SoC/bus-local memory from several child devices. Even if I do implement that DMA_MEMORY_INCLUDES_CHILDREN flag, 1) you do not always have the desired device as your immediate parent, 2) you have to ref-count it. For example, I was trying to use SoC-local SRAM on PXA270 from the framebuffer, but fb-devices on PXA are either platform devices, or sometimes get other parents. So, looks like another way to get to the SoC node is needed...
Thanks Guennadi --- Guennadi Liakhovetski
Fix dma_declare_coherent_memory wrong allocation for cris/arch-v32 arch/cris/arch-v32 seems to have copy-pasted the bug from arch/i386 fixed with an earlier patch - allocate bitmap in bytes, not words. Signed-off-by: G. Liakhovetski <g.liakhovetski@gmx.de>
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c index 70d3bf0..d634347 100644 --- a/arch/cris/arch-v32/drivers/pci/dma.c +++ b/arch/cris/arch-v32/drivers/pci/dma.c @@ -76,7 +76,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, { void __iomem *mem_base; int pages = size >> PAGE_SHIFT; - int bitmap_size = (pages + 31)/32; + int bitmap_size = DIV_ROUND_UP(pages, 8); if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0) goto out; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |