History

dma-pool: add additional coherent pools to map to gfp mask

The single atomic pool is allocated from the lowest zone possible since it is guaranteed to be applicable for any DMA allocation. Devices may allocate through the DMA API but not have a strict reliance on GFP_DMA memory. Since the atomic pool will be used for all non-blockable allocations, returning all memory from ZONE_DMA may unnecessarily deplete the zone. Provision for multiple atomic pools that will map to the optimal gfp mask of the device. When allocating non-blockable memory, determine the optimal gfp mask of the device and use the appropriate atomic pool. The coherent DMA mask will remain the same between allocation and free and, thus, memory will be freed to the same atomic pool it was allocated from. __dma_atomic_pool_init() will be changed to return struct gen_pool * later once dynamic expansion is added.

David Rientjes committed 6 years ago

Commit c84dc6e1 parent e860c295 files · +91 −54Browse files

Showing the changes to include/linux (2 of 5 files). Show all

Unified · Split

2 files
  1. include/linux/dma-direct.h +2 −0
  2. include/linux/dma-mapping.h +3 −3
include/linux/dma-direct.h+2−0
@@ -67,6 +67,8 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size, · 66 unmodified lines
67}67}
68 68
69u64 dma_direct_get_required_mask(struct device *dev);69u64 dma_direct_get_required_mask(struct device *dev);
70gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
71 u64 *phys_mask);
70void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,72void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
71 gfp_t gfp, unsigned long attrs);73 gfp_t gfp, unsigned long attrs);
72void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,74void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
include/linux/dma-mapping.h+3−3
@@ -630,9 +630,9 @@ void *dma_common_pages_remap(struct page **pages, size_t size, · 629 unmodified lines
630 pgprot_t prot, const void *caller);630 pgprot_t prot, const void *caller);
631void dma_common_free_remap(void *cpu_addr, size_t size);631void dma_common_free_remap(void *cpu_addr, size_t size);
632 632
633bool dma_in_atomic_pool(void *start, size_t size);633void *dma_alloc_from_pool(struct device *dev, size_t size,
634void *dma_alloc_from_pool(size_t size, struct page **ret_page, gfp_t flags);634 struct page **ret_page, gfp_t flags);
635bool dma_free_from_pool(void *start, size_t size);635bool dma_free_from_pool(struct device *dev, void *start, size_t size);
636 636
637int637int
638dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr,638dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr,