Lines Matching defs:cma

10 #include <linux/cma.h>
16 #include "cma.h"
36 struct cma *cma = data;
39 spin_lock_irq(&cma->lock);
41 used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma));
42 spin_unlock_irq(&cma->lock);
43 *val = (u64)used << cma->order_per_bit;
51 struct cma *cma = data;
54 unsigned long bitmap_maxno = cma_bitmap_maxno(cma);
56 spin_lock_irq(&cma->lock);
58 start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end);
61 end = find_next_bit(cma->bitmap, bitmap_maxno, start);
64 spin_unlock_irq(&cma->lock);
65 *val = (u64)maxchunk << cma->order_per_bit;
71 static void cma_add_to_cma_mem_list(struct cma *cma, struct cma_mem *mem)
73 spin_lock(&cma->mem_head_lock);
74 hlist_add_head(&mem->node, &cma->mem_head);
75 spin_unlock(&cma->mem_head_lock);
78 static struct cma_mem *cma_get_entry_from_list(struct cma *cma)
82 spin_lock(&cma->mem_head_lock);
83 if (!hlist_empty(&cma->mem_head)) {
84 mem = hlist_entry(cma->mem_head.first, struct cma_mem, node);
87 spin_unlock(&cma->mem_head_lock);
92 static int cma_free_mem(struct cma *cma, int count)
97 mem = cma_get_entry_from_list(cma);
102 cma_release(cma, mem->p, mem->n);
105 } else if (cma->order_per_bit == 0) {
106 cma_release(cma, mem->p, count);
110 cma_add_to_cma_mem_list(cma, mem);
112 pr_debug("cma: cannot release partial block when order_per_bit != 0\n");
113 cma_add_to_cma_mem_list(cma, mem);
125 struct cma *cma = data;
127 return cma_free_mem(cma, pages);
131 static int cma_alloc_mem(struct cma *cma, int count)
140 p = cma_alloc(cma, count, 0, false);
149 cma_add_to_cma_mem_list(cma, mem);
157 struct cma *cma = data;
159 return cma_alloc_mem(cma, pages);
163 static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
167 tmp = debugfs_create_dir(cma->name, root_dentry);
169 debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
170 debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
172 &cma->base_pfn, &cma_debugfs_fops);
173 debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops);
175 &cma->order_per_bit, &cma_debugfs_fops);
176 debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops);
177 debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops);
179 cma->dfs_bitmap.array = (u32 *)cma->bitmap;
180 cma->dfs_bitmap.n_elements = DIV_ROUND_UP(cma_bitmap_maxno(cma),
182 debugfs_create_u32_array("bitmap", 0444, tmp, &cma->dfs_bitmap);
190 cma_debugfs_root = debugfs_create_dir("cma", NULL);