diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index a90aba3d6afb..bc8a70a7c5a1 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -929,6 +929,15 @@ static inline int is_highmem_idx(enum zone_type idx) #endif } +#ifdef CONFIG_ZONE_DMA +bool has_managed_dma(void); +#else +static inline bool has_managed_dma(void) +{ + return false; +} +#endif + /** * is_highmem - helper function to quickly check if a struct zone is a * highmem zone or not. This is an attempt to keep references diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 283ac9d9f6dd..db5c0af8be2d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8694,3 +8694,18 @@ bool set_hwpoison_free_buddy_page(struct page *page) return hwpoisoned; } #endif + +#ifdef CONFIG_ZONE_DMA +bool has_managed_dma(void) +{ + struct pglist_data *pgdat; + + for_each_online_pgdat(pgdat) { + struct zone *zone = &pgdat->node_zones[ZONE_DMA]; + + if (managed_zone(zone)) + return true; + } + return false; +} +#endif /* CONFIG_ZONE_DMA */