@@ -66,6 +66,15 @@ static inline bool cma_free_folio(struct cma *cma, const struct folio *folio)
{
return false;
}
#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
@@ -49,10 +49,17 @@ unsigned long cma_get_size(const struct cma *cma)
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)
{
if (align_order <= cma->order_per_bit)
return 0;
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 <mripard@kernel.org> --- include/linux/cma.h | 9 +++++++++ mm/cma.c | 7 +++++++ 2 files changed, 16 insertions(+)