• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __MM_CMA_H__
3 #define __MM_CMA_H__
4 
5 #include <linux/debugfs.h>
6 #include <linux/kobject.h>
7 #include <linux/android_vendor.h>
8 
9 struct cma_kobject {
10 	struct kobject kobj;
11 	struct cma *cma;
12 };
13 
14 struct cma {
15 	unsigned long   base_pfn;
16 	unsigned long   count;
17 	unsigned long   *bitmap;
18 	unsigned int order_per_bit; /* Order of pages represented by one bit */
19 	struct mutex    lock;
20 #ifdef CONFIG_CMA_DEBUGFS
21 	struct hlist_head mem_head;
22 	spinlock_t mem_head_lock;
23 	struct debugfs_u32_array dfs_bitmap;
24 #endif
25 	char name[CMA_MAX_NAME];
26 #ifdef CONFIG_CMA_SYSFS
27 	/* the number of CMA page successful allocations */
28 	atomic64_t nr_pages_succeeded;
29 	/* the number of CMA page allocation failures */
30 	atomic64_t nr_pages_failed;
31 	/* kobject requires dynamic object */
32 	struct cma_kobject *cma_kobj;
33 #endif
34 	ANDROID_OEM_DATA_ARRAY(1, 4);
35 };
36 
37 extern struct cma cma_areas[MAX_CMA_AREAS];
38 extern unsigned cma_area_count;
39 
cma_bitmap_maxno(struct cma * cma)40 static inline unsigned long cma_bitmap_maxno(struct cma *cma)
41 {
42 	return cma->count >> cma->order_per_bit;
43 }
44 
45 #ifdef CONFIG_CMA_SYSFS
46 void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages);
47 void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages);
48 #else
cma_sysfs_account_success_pages(struct cma * cma,unsigned long nr_pages)49 static inline void cma_sysfs_account_success_pages(struct cma *cma,
50 						   unsigned long nr_pages) {};
cma_sysfs_account_fail_pages(struct cma * cma,unsigned long nr_pages)51 static inline void cma_sysfs_account_fail_pages(struct cma *cma,
52 						unsigned long nr_pages) {};
53 #endif
54 #endif
55