summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZhao Qiang <qiang.zhao@freescale.com>2015-11-30 10:48:53 +0800
committerScott Wood <scottwood@freescale.com>2015-12-22 17:10:17 -0600
commitb26981c8f743d3cb64a6907eb1f5c6c4ba6ca672 (patch)
tree60c2eb0964020d0ffe5fbe51f68d9bc03d89655c /lib
parentde2dd0eb30af55d3893979d5641c50c7a8969c99 (diff)
downloadlinux-b26981c8f743d3cb64a6907eb1f5c6c4ba6ca672.tar.gz
linux-b26981c8f743d3cb64a6907eb1f5c6c4ba6ca672.tar.bz2
linux-b26981c8f743d3cb64a6907eb1f5c6c4ba6ca672.zip
genalloc:support allocating specific region
Add new algo for genalloc, it reserve a specific region of memory Signed-off-by: Zhao Qiang <qiang.zhao@freescale.com> Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/genalloc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c
index b8cf89d9e17d..5ec83cd93284 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -556,6 +556,38 @@ unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size,
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
* of memory matching the size requirement. The region will be aligned
* to the order of the size specified.