From: Andrew Morton Date: Tue, 7 Apr 2015 23:44:37 +0000 (+1000) Subject: mm-cma-add-functions-to-get-region-pages-counters-fix X-Git-Tag: KARO-TXA5-2015-06-26~18^2~264 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=94224fb702bca62a3b8e00313d6232633b6ea817;p=karo-tx-linux.git mm-cma-add-functions-to-get-region-pages-counters-fix move debug code from cma.c into cma_debug.c so it doesn't get included in CONFIG_CMA_DEBUGFS=n builds Cc: Dmitry Safonov Cc: Michal Nazarewicz Cc: Stefan Strogin Cc: Marek Szyprowski Cc: Joonsoo Kim Cc: Pintu Kumar Cc: Weijie Yang Cc: Laurent Pinchart Cc: Vyacheslav Tyrtov Cc: Aleksei Mateosian Signed-off-by: Andrew Morton --- diff --git a/include/linux/cma.h b/include/linux/cma.h index 1231f50f865e..f7ef093ec49a 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -18,8 +18,6 @@ struct cma; extern unsigned long totalcma_pages; extern phys_addr_t cma_get_base(const struct cma *cma); extern unsigned long cma_get_size(const struct cma *cma); -extern unsigned long cma_get_used(struct cma *cma); -extern unsigned long cma_get_maxchunk(struct cma *cma); extern int __init cma_declare_contiguous(phys_addr_t base, phys_addr_t size, phys_addr_t limit, diff --git a/mm/cma.c b/mm/cma.c index d839011e8c6f..3a7a67b93394 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -53,36 +53,6 @@ unsigned long cma_get_size(const struct cma *cma) return cma->count << PAGE_SHIFT; } -unsigned long cma_get_used(struct cma *cma) -{ - unsigned long ret = 0; - - mutex_lock(&cma->lock); - /* pages counter is smaller than sizeof(int) */ - ret = bitmap_weight(cma->bitmap, (int)cma->count); - mutex_unlock(&cma->lock); - - return ret << cma->order_per_bit; -} - -unsigned long cma_get_maxchunk(struct cma *cma) -{ - unsigned long maxchunk = 0; - unsigned long start, end = 0; - - mutex_lock(&cma->lock); - for (;;) { - start = find_next_zero_bit(cma->bitmap, cma->count, end); - if (start >= cma->count) - break; - end = find_next_bit(cma->bitmap, cma->count, start); - maxchunk = max(end - start, maxchunk); - } - mutex_unlock(&cma->lock); - - return maxchunk << cma->order_per_bit; -} - static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, int align_order) { diff --git a/mm/cma_debug.c b/mm/cma_debug.c index 984ceddf8d31..7dd593a4e9dc 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -22,6 +22,37 @@ struct cma_mem { static struct dentry *cma_debugfs_root; +static unsigned long cma_get_used(struct cma *cma) +{ + unsigned long ret = 0; + + mutex_lock(&cma->lock); + /* pages counter is smaller than sizeof(int) */ + ret = bitmap_weight(cma->bitmap, (int)cma->count); + mutex_unlock(&cma->lock); + + return ret << cma->order_per_bit; +} + +static unsigned long cma_get_maxchunk(struct cma *cma) +{ + unsigned long maxchunk = 0; + unsigned long start, end = 0; + + mutex_lock(&cma->lock); + for (;;) { + start = find_next_zero_bit(cma->bitmap, cma->count, end); + if (start >= cma->count) + break; + end = find_next_bit(cma->bitmap, cma->count, start); + maxchunk = max(end - start, maxchunk); + } + mutex_unlock(&cma->lock); + + return maxchunk << cma->order_per_bit; +} + + static int cma_debugfs_get(void *data, u64 *val) { unsigned long *p = data;