Merge tag 'loongarch-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuaca...
[linux-2.6-block.git] / mm / cma.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
28b24c1f
SL
2#ifndef __MM_CMA_H__
3#define __MM_CMA_H__
4
a2b992c8 5#include <linux/debugfs.h>
43ca106f
MK
6#include <linux/kobject.h>
7
8struct cma_kobject {
9 struct kobject kobj;
10 struct cma *cma;
11};
a2b992c8 12
28b24c1f
SL
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 */
0ef7dcac 18 spinlock_t lock;
26b02a1f
SL
19#ifdef CONFIG_CMA_DEBUGFS
20 struct hlist_head mem_head;
21 spinlock_t mem_head_lock;
a2b992c8 22 struct debugfs_u32_array dfs_bitmap;
26b02a1f 23#endif
18e98e56 24 char name[CMA_MAX_NAME];
43ca106f
MK
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;
b9ad003a
AK
30 /* the number of CMA page released */
31 atomic64_t nr_pages_released;
43ca106f
MK
32 /* kobject requires dynamic object */
33 struct cma_kobject *cma_kobj;
34#endif
27d121d0 35 bool reserve_pages_on_error;
28b24c1f
SL
36};
37
38extern struct cma cma_areas[MAX_CMA_AREAS];
39extern unsigned cma_area_count;
40
f21838e0 41static inline unsigned long cma_bitmap_maxno(struct cma *cma)
28b24c1f
SL
42{
43 return cma->count >> cma->order_per_bit;
44}
45
43ca106f
MK
46#ifdef CONFIG_CMA_SYSFS
47void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages);
48void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages);
b9ad003a 49void cma_sysfs_account_release_pages(struct cma *cma, unsigned long nr_pages);
43ca106f
MK
50#else
51static inline void cma_sysfs_account_success_pages(struct cma *cma,
52 unsigned long nr_pages) {};
53static inline void cma_sysfs_account_fail_pages(struct cma *cma,
54 unsigned long nr_pages) {};
b9ad003a
AK
55static inline void cma_sysfs_account_release_pages(struct cma *cma,
56 unsigned long nr_pages) {};
43ca106f 57#endif
28b24c1f 58#endif