Commit b26981c8 authored by Zhao Qiang's avatar Zhao Qiang Committed by Scott Wood

genalloc:support allocating specific region

Add new algo for genalloc, it reserve a specific region of
memory
Signed-off-by: default avatarZhao Qiang <qiang.zhao@freescale.com>
Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
parent de2dd0eb
...@@ -84,6 +84,13 @@ struct genpool_data_align { ...@@ -84,6 +84,13 @@ struct genpool_data_align {
int align; /* alignment by bytes for starting address */ int align; /* alignment by bytes for starting address */
}; };
/*
* gen_pool data descriptor for gen_pool_fixed_alloc.
*/
struct genpool_data_fixed {
unsigned long offset; /* The offset of the specific region */
};
extern struct gen_pool *gen_pool_create(int, int); extern struct gen_pool *gen_pool_create(int, int);
extern phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long); extern phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long);
extern int gen_pool_add_virt(struct gen_pool *, unsigned long, phys_addr_t, extern int gen_pool_add_virt(struct gen_pool *, unsigned long, phys_addr_t,
...@@ -124,6 +131,10 @@ extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size, ...@@ -124,6 +131,10 @@ extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
unsigned long start, unsigned int nr, void *data, unsigned long start, unsigned int nr, void *data,
struct gen_pool *pool); struct gen_pool *pool);
extern unsigned long gen_pool_fixed_alloc(unsigned long *map,
unsigned long size, unsigned long start, unsigned int nr,
void *data, struct gen_pool *pool);
extern unsigned long gen_pool_first_fit_align(unsigned long *map, extern unsigned long gen_pool_first_fit_align(unsigned long *map,
unsigned long size, unsigned long start, unsigned int nr, unsigned long size, unsigned long start, unsigned int nr,
void *data, struct gen_pool *pool); void *data, struct gen_pool *pool);
......
...@@ -555,6 +555,38 @@ unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size, ...@@ -555,6 +555,38 @@ unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size,
} }
EXPORT_SYMBOL(gen_pool_first_fit_align); EXPORT_SYMBOL(gen_pool_first_fit_align);
/**
* gen_pool_fixed_alloc - reserve a specific region
* @map: The address to base the search on
* @size: The bitmap size in bits
* @start: The bitnumber to start searching at
* @nr: The number of zeroed bits we're looking for
* @data: data for alignment
* @pool: pool to get order from
*/
unsigned long gen_pool_fixed_alloc(unsigned long *map, unsigned long size,
unsigned long start, unsigned int nr, void *data,
struct gen_pool *pool)
{
struct genpool_data_fixed *fixed_data;
int order;
unsigned long offset_bit;
unsigned long start_bit;
fixed_data = data;
order = pool->min_alloc_order;
offset_bit = fixed_data->offset >> order;
if (WARN_ON(fixed_data->offset & (1UL << order - 1)))
return size;
start_bit = bitmap_find_next_zero_area(map, size,
start + offset_bit, nr, 0);
if (start_bit != offset_bit)
start_bit = size;
return start_bit;
}
EXPORT_SYMBOL(gen_pool_fixed_alloc);
/** /**
* gen_pool_first_fit_order_align - find the first available region * gen_pool_first_fit_order_align - find the first available region
* of memory matching the size requirement. The region will be aligned * of memory matching the size requirement. The region will be aligned
......
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