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