Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma: fix order calculation in dma_mark_declared_memory_occupied()

get_order() takes byte-sized input, not a page-granular one.

Irrespective of this fix I'm inclined to believe that this doesn't work
right anyway - bitmap_allocate_region() has an implicit assumption of
'pos' being suitable for 'order', which this function doesn't seem to
enforce (and since it's being called with a byte-granular value there's no
reason to believe that the callers would make sure device_addr is passed
accordingly - it's also not documented that way).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Beulich and committed by
Linus Torvalds
d2dc1f4a 978cc90c

+2 -3
+2 -3
kernel/dma-coherent.c
··· 77 77 { 78 78 struct dma_coherent_mem *mem = dev->dma_mem; 79 79 int pos, err; 80 - int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1); 81 80 82 - pages >>= PAGE_SHIFT; 81 + size += device_addr & ~PAGE_MASK; 83 82 84 83 if (!mem) 85 84 return ERR_PTR(-EINVAL); 86 85 87 86 pos = (device_addr - mem->device_base) >> PAGE_SHIFT; 88 - err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages)); 87 + err = bitmap_allocate_region(mem->bitmap, pos, get_order(size)); 89 88 if (err != 0) 90 89 return ERR_PTR(err); 91 90 return mem->virt_base + (pos << PAGE_SHIFT);