Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'dma-contig-for-7.1-modules-prep-v4' into dma-mapping-for-next

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

+71 -47
+2 -17
drivers/dma-buf/heaps/cma_heap.c
··· 14 14 15 15 #include <linux/cma.h> 16 16 #include <linux/dma-buf.h> 17 - #include <linux/dma-buf/heaps/cma.h> 18 17 #include <linux/dma-heap.h> 19 18 #include <linux/dma-map-ops.h> 20 19 #include <linux/err.h> ··· 28 29 #include <linux/vmalloc.h> 29 30 30 31 #define DEFAULT_CMA_NAME "default_cma_region" 31 - 32 - static struct cma *dma_areas[MAX_CMA_AREAS] __initdata; 33 - static unsigned int dma_areas_num __initdata; 34 - 35 - int __init dma_heap_cma_register_heap(struct cma *cma) 36 - { 37 - if (dma_areas_num >= ARRAY_SIZE(dma_areas)) 38 - return -EINVAL; 39 - 40 - dma_areas[dma_areas_num++] = cma; 41 - 42 - return 0; 43 - } 44 32 45 33 struct cma_heap { 46 34 struct dma_heap *heap; ··· 400 414 static int __init add_cma_heaps(void) 401 415 { 402 416 struct cma *default_cma = dev_get_cma_area(NULL); 417 + struct cma *cma; 403 418 unsigned int i; 404 419 int ret; 405 420 ··· 410 423 return ret; 411 424 } 412 425 413 - for (i = 0; i < dma_areas_num; i++) { 414 - struct cma *cma = dma_areas[i]; 415 - 426 + for (i = 0; (cma = dma_contiguous_get_area_by_idx(i)) != NULL; i++) { 416 427 ret = __add_cma_heap(cma, cma_get_name(cma)); 417 428 if (ret) { 418 429 pr_warn("Failed to add CMA heap %s", cma_get_name(cma));
-16
include/linux/dma-buf/heaps/cma.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef DMA_BUF_HEAP_CMA_H_ 3 - #define DMA_BUF_HEAP_CMA_H_ 4 - 5 - struct cma; 6 - 7 - #ifdef CONFIG_DMABUF_HEAPS_CMA 8 - int dma_heap_cma_register_heap(struct cma *cma); 9 - #else 10 - static inline int dma_heap_cma_register_heap(struct cma *cma) 11 - { 12 - return 0; 13 - } 14 - #endif // CONFIG_DMABUF_HEAPS_CMA 15 - 16 - #endif // DMA_BUF_HEAP_CMA_H_
+6 -8
include/linux/dma-map-ops.h
··· 91 91 #endif /* CONFIG_ARCH_HAS_DMA_OPS */ 92 92 93 93 #ifdef CONFIG_DMA_CMA 94 - extern struct cma *dma_contiguous_default_area; 95 - 96 - static inline struct cma *dev_get_cma_area(struct device *dev) 97 - { 98 - if (dev && dev->cma_area) 99 - return dev->cma_area; 100 - return dma_contiguous_default_area; 101 - } 94 + struct cma *dev_get_cma_area(struct device *dev); 95 + struct cma *dma_contiguous_get_area_by_idx(unsigned int idx); 102 96 103 97 void dma_contiguous_reserve(phys_addr_t addr_limit); 104 98 int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, ··· 108 114 void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size); 109 115 #else /* CONFIG_DMA_CMA */ 110 116 static inline struct cma *dev_get_cma_area(struct device *dev) 117 + { 118 + return NULL; 119 + } 120 + static inline struct cma *dma_contiguous_get_area_by_idx(unsigned int idx) 111 121 { 112 122 return NULL; 113 123 }
+60 -6
kernel/dma/contiguous.c
··· 42 42 #include <linux/memblock.h> 43 43 #include <linux/err.h> 44 44 #include <linux/sizes.h> 45 - #include <linux/dma-buf/heaps/cma.h> 46 45 #include <linux/dma-map-ops.h> 47 46 #include <linux/cma.h> 48 47 #include <linux/nospec.h> ··· 52 53 #define CMA_SIZE_MBYTES 0 53 54 #endif 54 55 55 - struct cma *dma_contiguous_default_area; 56 + static struct cma *dma_contiguous_areas[MAX_CMA_AREAS]; 57 + static unsigned int dma_contiguous_areas_num; 58 + 59 + static int dma_contiguous_insert_area(struct cma *cma) 60 + { 61 + if (dma_contiguous_areas_num >= ARRAY_SIZE(dma_contiguous_areas)) 62 + return -EINVAL; 63 + 64 + dma_contiguous_areas[dma_contiguous_areas_num++] = cma; 65 + 66 + return 0; 67 + } 68 + 69 + /** 70 + * dma_contiguous_get_area_by_idx() - Get contiguous area at given index 71 + * @idx: index of the area we query 72 + * 73 + * Queries for the contiguous area located at index @idx. 74 + * 75 + * Returns: 76 + * A pointer to the requested contiguous area, or NULL otherwise. 77 + */ 78 + struct cma *dma_contiguous_get_area_by_idx(unsigned int idx) 79 + { 80 + if (idx >= dma_contiguous_areas_num) 81 + return NULL; 82 + 83 + return dma_contiguous_areas[idx]; 84 + } 85 + EXPORT_SYMBOL_GPL(dma_contiguous_get_area_by_idx); 86 + 87 + static struct cma *dma_contiguous_default_area; 56 88 57 89 /* 58 90 * Default global CMA area size can be defined in kernel's .config. ··· 120 90 return 0; 121 91 } 122 92 early_param("cma", early_cma); 93 + 94 + struct cma *dev_get_cma_area(struct device *dev) 95 + { 96 + if (dev && dev->cma_area) 97 + return dev->cma_area; 98 + 99 + return dma_contiguous_default_area; 100 + } 101 + EXPORT_SYMBOL_GPL(dev_get_cma_area); 123 102 124 103 #ifdef CONFIG_DMA_NUMA_CMA 125 104 ··· 293 254 if (ret) 294 255 return; 295 256 296 - ret = dma_heap_cma_register_heap(dma_contiguous_default_area); 257 + /* 258 + * We need to insert the new area in our list to avoid 259 + * any inconsistencies between having the default area 260 + * listed in the DT or not. 261 + * 262 + * The DT case is handled by rmem_cma_setup() and will 263 + * always insert all its areas in our list. However, if 264 + * it didn't run (because OF_RESERVED_MEM isn't set, or 265 + * there's no DT region specified), then we don't have a 266 + * default area yet, and no area in our list. 267 + * 268 + * This block creates the default area in such a case, 269 + * but we also need to insert it in our list to avoid 270 + * having a default area but an empty list. 271 + */ 272 + ret = dma_contiguous_insert_area(dma_contiguous_default_area); 297 273 if (ret) 298 - pr_warn("Couldn't register default CMA heap."); 274 + pr_warn("Couldn't queue default CMA region for heap creation."); 299 275 } 300 276 } 301 277 ··· 583 529 pr_info("Reserved memory: created CMA memory pool at %pa, size %ld MiB\n", 584 530 &rmem->base, (unsigned long)rmem->size / SZ_1M); 585 531 586 - ret = dma_heap_cma_register_heap(cma); 532 + ret = dma_contiguous_insert_area(cma); 587 533 if (ret) 588 - pr_warn("Couldn't register CMA heap."); 534 + pr_warn("Couldn't store CMA reserved area."); 589 535 590 536 return 0; 591 537 }
+3
mm/cma.c
··· 52 52 { 53 53 return cma->name; 54 54 } 55 + EXPORT_SYMBOL_GPL(cma_get_name); 55 56 56 57 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, 57 58 unsigned int align_order) ··· 952 951 953 952 return page; 954 953 } 954 + EXPORT_SYMBOL_GPL(cma_alloc); 955 955 956 956 static struct cma_memrange *find_cma_memrange(struct cma *cma, 957 957 const struct page *pages, unsigned long count) ··· 1029 1027 1030 1028 return true; 1031 1029 } 1030 + EXPORT_SYMBOL_GPL(cma_release); 1032 1031 1033 1032 bool cma_release_frozen(struct cma *cma, const struct page *pages, 1034 1033 unsigned long count)