Lines Matching refs:cma
36 struct cma *cma = data; in cma_used_get() local
39 spin_lock_irq(&cma->lock); in cma_used_get()
41 used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma)); in cma_used_get()
42 spin_unlock_irq(&cma->lock); in cma_used_get()
43 *val = (u64)used << cma->order_per_bit; in cma_used_get()
51 struct cma *cma = data; in cma_maxchunk_get() local
54 unsigned long bitmap_maxno = cma_bitmap_maxno(cma); in cma_maxchunk_get()
56 spin_lock_irq(&cma->lock); in cma_maxchunk_get()
58 start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end); in cma_maxchunk_get()
61 end = find_next_bit(cma->bitmap, bitmap_maxno, start); in cma_maxchunk_get()
64 spin_unlock_irq(&cma->lock); in cma_maxchunk_get()
65 *val = (u64)maxchunk << cma->order_per_bit; in cma_maxchunk_get()
71 static void cma_add_to_cma_mem_list(struct cma *cma, struct cma_mem *mem) in cma_add_to_cma_mem_list() argument
73 spin_lock(&cma->mem_head_lock); in cma_add_to_cma_mem_list()
74 hlist_add_head(&mem->node, &cma->mem_head); in cma_add_to_cma_mem_list()
75 spin_unlock(&cma->mem_head_lock); in cma_add_to_cma_mem_list()
78 static struct cma_mem *cma_get_entry_from_list(struct cma *cma) in cma_get_entry_from_list() argument
82 spin_lock(&cma->mem_head_lock); in cma_get_entry_from_list()
83 if (!hlist_empty(&cma->mem_head)) { in cma_get_entry_from_list()
84 mem = hlist_entry(cma->mem_head.first, struct cma_mem, node); in cma_get_entry_from_list()
87 spin_unlock(&cma->mem_head_lock); in cma_get_entry_from_list()
92 static int cma_free_mem(struct cma *cma, int count) in cma_free_mem() argument
97 mem = cma_get_entry_from_list(cma); in cma_free_mem()
102 cma_release(cma, mem->p, mem->n); in cma_free_mem()
105 } else if (cma->order_per_bit == 0) { in cma_free_mem()
106 cma_release(cma, mem->p, count); in cma_free_mem()
110 cma_add_to_cma_mem_list(cma, mem); in cma_free_mem()
113 cma_add_to_cma_mem_list(cma, mem); in cma_free_mem()
125 struct cma *cma = data; in cma_free_write() local
127 return cma_free_mem(cma, pages); in cma_free_write()
131 static int cma_alloc_mem(struct cma *cma, int count) in cma_alloc_mem() argument
140 p = cma_alloc(cma, count, 0, false); in cma_alloc_mem()
149 cma_add_to_cma_mem_list(cma, mem); in cma_alloc_mem()
157 struct cma *cma = data; in cma_alloc_write() local
159 return cma_alloc_mem(cma, pages); in cma_alloc_write()
163 static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry) in cma_debugfs_add_one() argument
168 scnprintf(name, sizeof(name), "cma-%s", cma->name); in cma_debugfs_add_one()
172 debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops); in cma_debugfs_add_one()
173 debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops); in cma_debugfs_add_one()
175 &cma->base_pfn, &cma_debugfs_fops); in cma_debugfs_add_one()
176 debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops); in cma_debugfs_add_one()
178 &cma->order_per_bit, &cma_debugfs_fops); in cma_debugfs_add_one()
179 debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops); in cma_debugfs_add_one()
180 debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops); in cma_debugfs_add_one()
182 cma->dfs_bitmap.array = (u32 *)cma->bitmap; in cma_debugfs_add_one()
183 cma->dfs_bitmap.n_elements = DIV_ROUND_UP(cma_bitmap_maxno(cma), in cma_debugfs_add_one()
185 debugfs_create_u32_array("bitmap", 0444, tmp, &cma->dfs_bitmap); in cma_debugfs_add_one()