0001
0002 #ifndef __MM_CMA_H__
0003 #define __MM_CMA_H__
0004
0005 #include <linux/debugfs.h>
0006 #include <linux/kobject.h>
0007
0008 struct cma_kobject {
0009 struct kobject kobj;
0010 struct cma *cma;
0011 };
0012
0013 struct cma {
0014 unsigned long base_pfn;
0015 unsigned long count;
0016 unsigned long *bitmap;
0017 unsigned int order_per_bit;
0018 spinlock_t lock;
0019 #ifdef CONFIG_CMA_DEBUGFS
0020 struct hlist_head mem_head;
0021 spinlock_t mem_head_lock;
0022 struct debugfs_u32_array dfs_bitmap;
0023 #endif
0024 char name[CMA_MAX_NAME];
0025 #ifdef CONFIG_CMA_SYSFS
0026
0027 atomic64_t nr_pages_succeeded;
0028
0029 atomic64_t nr_pages_failed;
0030
0031 struct cma_kobject *cma_kobj;
0032 #endif
0033 bool reserve_pages_on_error;
0034 };
0035
0036 extern struct cma cma_areas[MAX_CMA_AREAS];
0037 extern unsigned cma_area_count;
0038
0039 static inline unsigned long cma_bitmap_maxno(struct cma *cma)
0040 {
0041 return cma->count >> cma->order_per_bit;
0042 }
0043
0044 #ifdef CONFIG_CMA_SYSFS
0045 void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages);
0046 void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages);
0047 #else
0048 static inline void cma_sysfs_account_success_pages(struct cma *cma,
0049 unsigned long nr_pages) {};
0050 static inline void cma_sysfs_account_fail_pages(struct cma *cma,
0051 unsigned long nr_pages) {};
0052 #endif
0053 #endif