Commit ea714507 authored by James Bottomley's avatar James Bottomley

Add vmalloc alignment constraints

vmalloc is used by ioremap() to get regions for
remapping I/O space.  To feed these regions back
into a __get_free_pages() type memory allocator,
they are expected to have more alignment than 
get_vm_area() proves.  So add additional alignment
constraints for VM_IOREMAP.
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 29ad27a5
......@@ -179,11 +179,27 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
return err;
}
#define IOREMAP_MAX_ORDER (3 + PAGE_SHIFT) /* 8 pages */
struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
unsigned long start, unsigned long end)
{
struct vm_struct **p, *tmp, *area;
unsigned long addr = start;
unsigned long align = 1;
unsigned long addr;
if (flags & VM_IOREMAP) {
int bit = fls(size);
if (bit > IOREMAP_MAX_ORDER)
bit = IOREMAP_MAX_ORDER;
else if (bit < PAGE_SHIFT)
bit = PAGE_SHIFT;
align = 1ul << bit;
}
addr = ALIGN(start, align);
area = kmalloc(sizeof(*area), GFP_KERNEL);
if (unlikely(!area))
......@@ -206,7 +222,7 @@ struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
goto out;
if (size + addr <= (unsigned long)tmp->addr)
goto found;
addr = tmp->size + (unsigned long)tmp->addr;
addr = ALIGN(tmp->size + (unsigned long)tmp->addr, align);
if (addr > end - size)
goto out;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment