@@ -145,6 +145,8 @@ void dma_direct_free_pages(struct device *dev, size_t size,
enum dma_data_direction dir);
int dma_direct_supported(struct device *dev, u64 mask);
dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,
size_t size, enum dma_data_direction dir, unsigned long attrs);
+struct dmem_cgroup_region *dma_direct_get_dmem_cgroup_region(struct device *dev);
+
#endif /* _LINUX_DMA_DIRECT_H */
@@ -42,10 +42,18 @@ u64 dma_direct_get_required_mask(struct device *dev)
u64 max_dma = phys_to_dma_direct(dev, phys);
return (1ULL << (fls64(max_dma) - 1)) * 2 - 1;
}
+#if IS_ENABLED(CONFIG_CGROUP_DMEM)
+struct dmem_cgroup_region *
+dma_direct_get_dmem_cgroup_region(struct device *dev)
+{
+ return dma_contiguous_get_dmem_cgroup_region(dev);
+}
+#endif
+
static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 *phys_limit)
{
u64 dma_limit = min_not_zero(
dev->coherent_dma_mask,
dev->bus_dma_limit);
Consumers of the direct DMA API will have to know which 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/dma-direct.h | 2 ++ kernel/dma/direct.c | 8 ++++++++ 2 files changed, 10 insertions(+)