• Home
  • Raw
  • Download

Lines Matching refs:cma

44 struct cma cma_areas[MAX_CMA_AREAS];
48 phys_addr_t cma_get_base(const struct cma *cma) in cma_get_base() argument
50 return PFN_PHYS(cma->base_pfn); in cma_get_base()
53 unsigned long cma_get_size(const struct cma *cma) in cma_get_size() argument
55 return cma->count << PAGE_SHIFT; in cma_get_size()
59 const char *cma_get_name(const struct cma *cma) in cma_get_name() argument
61 return cma->name; in cma_get_name()
65 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, in cma_bitmap_aligned_mask() argument
68 if (align_order <= cma->order_per_bit) in cma_bitmap_aligned_mask()
70 return (1UL << (align_order - cma->order_per_bit)) - 1; in cma_bitmap_aligned_mask()
77 static unsigned long cma_bitmap_aligned_offset(const struct cma *cma, in cma_bitmap_aligned_offset() argument
80 return (cma->base_pfn & ((1UL << align_order) - 1)) in cma_bitmap_aligned_offset()
81 >> cma->order_per_bit; in cma_bitmap_aligned_offset()
84 static unsigned long cma_bitmap_pages_to_bits(const struct cma *cma, in cma_bitmap_pages_to_bits() argument
87 return ALIGN(pages, 1UL << cma->order_per_bit) >> cma->order_per_bit; in cma_bitmap_pages_to_bits()
90 static void cma_clear_bitmap(struct cma *cma, unsigned long pfn, in cma_clear_bitmap() argument
96 bitmap_no = (pfn - cma->base_pfn) >> cma->order_per_bit; in cma_clear_bitmap()
97 bitmap_count = cma_bitmap_pages_to_bits(cma, count); in cma_clear_bitmap()
99 spin_lock_irqsave(&cma->lock, flags); in cma_clear_bitmap()
100 bitmap_clear(cma->bitmap, bitmap_no, bitmap_count); in cma_clear_bitmap()
101 spin_unlock_irqrestore(&cma->lock, flags); in cma_clear_bitmap()
104 static void __init cma_activate_area(struct cma *cma) in cma_activate_area() argument
106 unsigned long base_pfn = cma->base_pfn, pfn; in cma_activate_area()
109 cma->bitmap = bitmap_zalloc(cma_bitmap_maxno(cma), GFP_KERNEL); in cma_activate_area()
110 if (!cma->bitmap) in cma_activate_area()
120 for (pfn = base_pfn + 1; pfn < base_pfn + cma->count; pfn++) { in cma_activate_area()
126 for (pfn = base_pfn; pfn < base_pfn + cma->count; in cma_activate_area()
130 spin_lock_init(&cma->lock); in cma_activate_area()
133 INIT_HLIST_HEAD(&cma->mem_head); in cma_activate_area()
134 spin_lock_init(&cma->mem_head_lock); in cma_activate_area()
140 bitmap_free(cma->bitmap); in cma_activate_area()
143 for (pfn = base_pfn; pfn < base_pfn + cma->count; pfn++) in cma_activate_area()
145 totalcma_pages -= cma->count; in cma_activate_area()
146 cma->count = 0; in cma_activate_area()
147 pr_err("CMA area %s could not be activated\n", cma->name); in cma_activate_area()
177 struct cma **res_cma) in cma_init_reserved_mem()
179 struct cma *cma; in cma_init_reserved_mem() local
206 cma = &cma_areas[cma_area_count]; in cma_init_reserved_mem()
209 snprintf(cma->name, CMA_MAX_NAME, name); in cma_init_reserved_mem()
211 snprintf(cma->name, CMA_MAX_NAME, "cma%d\n", cma_area_count); in cma_init_reserved_mem()
213 cma->base_pfn = PFN_DOWN(base); in cma_init_reserved_mem()
214 cma->count = size >> PAGE_SHIFT; in cma_init_reserved_mem()
215 cma->order_per_bit = order_per_bit; in cma_init_reserved_mem()
216 *res_cma = cma; in cma_init_reserved_mem()
246 bool fixed, const char *name, struct cma **res_cma, in cma_declare_contiguous_nid()
397 static void cma_debug_show_areas(struct cma *cma) in cma_debug_show_areas() argument
402 unsigned long nbits = cma_bitmap_maxno(cma); in cma_debug_show_areas()
404 spin_lock_irq(&cma->lock); in cma_debug_show_areas()
407 next_zero_bit = find_next_zero_bit(cma->bitmap, nbits, start); in cma_debug_show_areas()
410 next_set_bit = find_next_bit(cma->bitmap, nbits, next_zero_bit); in cma_debug_show_areas()
412 nr_part = nr_zero << cma->order_per_bit; in cma_debug_show_areas()
418 pr_cont("=> %lu free of %lu total pages\n", nr_total, cma->count); in cma_debug_show_areas()
419 spin_unlock_irq(&cma->lock); in cma_debug_show_areas()
422 static inline void cma_debug_show_areas(struct cma *cma) { } in cma_debug_show_areas() argument
435 struct page *cma_alloc(struct cma *cma, unsigned long count, in cma_alloc() argument
451 trace_android_vh_cma_alloc_bypass(cma, count, align, gfp_mask, in cma_alloc()
458 if (!cma || !cma->count || !cma->bitmap) in cma_alloc()
462 (void *)cma, count, align, gfp_mask); in cma_alloc()
467 trace_cma_alloc_start(cma->name, count, align); in cma_alloc()
469 mask = cma_bitmap_aligned_mask(cma, align); in cma_alloc()
470 offset = cma_bitmap_aligned_offset(cma, align); in cma_alloc()
471 bitmap_maxno = cma_bitmap_maxno(cma); in cma_alloc()
472 bitmap_count = cma_bitmap_pages_to_bits(cma, count); in cma_alloc()
480 spin_lock_irq(&cma->lock); in cma_alloc()
481 bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap, in cma_alloc()
486 spin_unlock_irq(&cma->lock); in cma_alloc()
507 spin_unlock_irq(&cma->lock); in cma_alloc()
511 bitmap_set(cma->bitmap, bitmap_no, bitmap_count); in cma_alloc()
517 spin_unlock_irq(&cma->lock); in cma_alloc()
519 pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit); in cma_alloc()
539 cma_clear_bitmap(cma, pfn, count); in cma_alloc()
547 trace_cma_alloc_busy_retry(cma->name, pfn, pfn_to_page(pfn), in cma_alloc()
553 cma->base_pfn) >> cma->order_per_bit; in cma_alloc()
561 trace_cma_alloc_finish(cma->name, pfn, page, count, align); in cma_alloc()
562 trace_cma_alloc_info(cma->name, page, count, align, &cma_info); in cma_alloc()
576 __func__, cma->name, count, ret); in cma_alloc()
577 cma_debug_show_areas(cma); in cma_alloc()
582 trace_android_vh_cma_alloc_finish(cma, page, count, align, gfp_mask, ts); in cma_alloc()
585 cma_sysfs_account_success_pages(cma, count); in cma_alloc()
588 if (cma) in cma_alloc()
589 cma_sysfs_account_fail_pages(cma, count); in cma_alloc()
606 bool cma_release(struct cma *cma, const struct page *pages, in cma_release() argument
611 if (!cma || !pages) in cma_release()
618 if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) in cma_release()
621 VM_BUG_ON(pfn + count > cma->base_pfn + cma->count); in cma_release()
624 cma_clear_bitmap(cma, pfn, count); in cma_release()
625 trace_cma_release(cma->name, pfn, pages, count); in cma_release()
631 int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data) in cma_for_each_area() argument