Skip to content

Commit f720e7e

Browse files
committed
Merge branch 'fixes-for-linus-for-3.6-rc2' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping
Pull three dma-mapping fixes from Marek Szyprowski. * 'fixes-for-linus-for-3.6-rc2' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping: ARM: dma-mapping: fix incorrect freeing of atomic allocations ARM: dma-mapping: fix atomic allocation alignment ARM: mm: fix MMU mapping of CMA regions
2 parents 15fc5de + d9e0d14 commit f720e7e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void __init dma_contiguous_remap(void)
358358
if (end > arm_lowmem_limit)
359359
end = arm_lowmem_limit;
360360
if (start >= end)
361-
return;
361+
continue;
362362

363363
map.pfn = __phys_to_pfn(start);
364364
map.virtual = __phys_to_virt(start);
@@ -423,7 +423,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
423423
unsigned int pageno;
424424
unsigned long flags;
425425
void *ptr = NULL;
426-
size_t align;
426+
unsigned long align_mask;
427427

428428
if (!pool->vaddr) {
429429
WARN(1, "coherent pool not initialised!\n");
@@ -435,11 +435,11 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
435435
* small, so align them to their order in pages, minimum is a page
436436
* size. This helps reduce fragmentation of the DMA space.
437437
*/
438-
align = PAGE_SIZE << get_order(size);
438+
align_mask = (1 << get_order(size)) - 1;
439439

440440
spin_lock_irqsave(&pool->lock, flags);
441441
pageno = bitmap_find_next_zero_area(pool->bitmap, pool->nr_pages,
442-
0, count, (1 << align) - 1);
442+
0, count, align_mask);
443443
if (pageno < pool->nr_pages) {
444444
bitmap_set(pool->bitmap, pageno, count);
445445
ptr = pool->vaddr + PAGE_SIZE * pageno;
@@ -648,12 +648,12 @@ void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
648648

649649
if (arch_is_coherent() || nommu()) {
650650
__dma_free_buffer(page, size);
651+
} else if (__free_from_pool(cpu_addr, size)) {
652+
return;
651653
} else if (!IS_ENABLED(CONFIG_CMA)) {
652654
__dma_free_remap(cpu_addr, size);
653655
__dma_free_buffer(page, size);
654656
} else {
655-
if (__free_from_pool(cpu_addr, size))
656-
return;
657657
/*
658658
* Non-atomic allocations cannot be freed with IRQs disabled
659659
*/

0 commit comments

Comments
 (0)