Skip to content

Commit

Permalink
dma-coherent: per-device coherent area is in pages, not bytes.
Browse files Browse the repository at this point in the history
Commit 58c6d3d ("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>
  • Loading branch information
Adrian McMenamin authored and Paul Mundt committed Jan 21, 2009
1 parent 2afb447 commit cdf57ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/dma-coherent.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
mem = dev->dma_mem;
if (!mem)
return 0;
if (unlikely(size > mem->size))
return 0;
if (unlikely(size > (mem->size << PAGE_SHIFT)))
return 0;

pageno = bitmap_find_free_region(mem->bitmap, mem->size, order);
if (pageno >= 0) {
Expand Down

0 comments on commit cdf57ca

Please sign in to comment.