From: Maxime Ripard Consumers of the CMA API will have to know which CMA region their device allocate from in order for them to charge the memory allocation in the right one. Let's provide an accessor for that region. Signed-off-by: Maxime Ripard Signed-off-by: Eric Chanudet --- include/linux/cma.h | 9 +++++++++ mm/cma.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/cma.h b/include/linux/cma.h index 62d9c1cf632652489ccd9e01bf1370f2b1f3c249..8ece66c35e9e640b98db4b24a9bd118ad07ec082 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -77,4 +77,13 @@ static inline bool cma_validate_zones(struct cma *cma) } #endif +#if IS_ENABLED(CONFIG_CGROUP_DMEM) +struct dmem_cgroup_region *cma_get_dmem_cgroup_region(struct cma *cma); +#else /* CONFIG_CGROUP_DMEM */ +static inline struct dmem_cgroup_region *cma_get_dmem_cgroup_region(struct cma *cma) +{ + return NULL; +} +#endif /* CONFIG_CGROUP_DMEM */ + #endif diff --git a/mm/cma.c b/mm/cma.c index 78016647d512868cd87bc2c1a52dd2295acaaf01..c8b0de1da3e71bd6b8ab749ab58eb27446a1657e 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -53,6 +53,13 @@ const char *cma_get_name(const struct cma *cma) return cma->name; } +#if IS_ENABLED(CONFIG_CGROUP_DMEM) +struct dmem_cgroup_region *cma_get_dmem_cgroup_region(struct cma *cma) +{ + return cma->dmem_cgrp_region; +} +#endif /* CONFIG_CGROUP_DMEM */ + static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, unsigned int align_order) { -- 2.52.0