dma-coherent: per-device coherent area is in pages, not bytes.

Commit 58c6d3dfe4 ("dma-coherent: catch
oversized requests to dma_alloc_from_coherent()") attempted to add a
sanity check to bail out on allocations larger than the coherent area.

Unfortunately when this was implemented, the fact the coherent area
is tracked in pages rather than bytes was overlooked, which subsequently
broke every single dma_alloc_from_coherent() user, forcing the allocation
silently through generic memory instead.

Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk >
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
Adrian McMenamin 2009-01-21 18:47:38 +09:00 committed by Paul Mundt
parent 2afb447f33
commit cdf57cab27

View file

@ -118,7 +118,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
mem = dev->dma_mem; mem = dev->dma_mem;
if (!mem) if (!mem)
return 0; return 0;
if (unlikely(size > mem->size)) if (unlikely(size > (mem->size << PAGE_SHIFT)))
return 0; return 0;
pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); pageno = bitmap_find_free_region(mem->bitmap, mem->size, order);