]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
dma-coherent: per-device coherent area is in pages, not bytes.
authorAdrian McMenamin <adrian@mcmen.demon.co.uk>
Wed, 21 Jan 2009 09:47:38 +0000 (18:47 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Wed, 21 Jan 2009 09:47:38 +0000 (18:47 +0900)
Commit 58c6d3dfe436eb8cfb451981d8fdc9044eaf42da ("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>
kernel/dma-coherent.c

index 038707404b76075866d6bccb5df015d9965762c4..38fa292c6aa92b1b50657f6d336710bd09c42bfd 100644 (file)
@@ -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) {