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 tag 'dma-mapping-5.3-5' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:
"Two fixes for regressions in this merge window:

- select the Kconfig symbols for the noncoherent dma arch helpers on
arm if swiotlb is selected, not just for LPAE to not break then Xen
build, that uses swiotlb indirectly through swiotlb-xen

- fix the page allocator fallback in dma_alloc_contiguous if the CMA
allocation fails"

* tag 'dma-mapping-5.3-5' of git://git.infradead.org/users/hch/dma-mapping:
dma-direct: fix zone selection after an unaddressable CMA allocation
arm: select the dma-noncoherent symbols for all swiotlb builds

+19 -15
+4
arch/arm/Kconfig
··· 7 7 select ARCH_HAS_BINFMT_FLAT 8 8 select ARCH_HAS_DEBUG_VIRTUAL if MMU 9 9 select ARCH_HAS_DEVMEM_IS_ALLOWED 10 + select ARCH_HAS_DMA_COHERENT_TO_PFN if SWIOTLB 11 + select ARCH_HAS_DMA_MMAP_PGPROT if SWIOTLB 10 12 select ARCH_HAS_ELF_RANDOMIZE 11 13 select ARCH_HAS_FORTIFY_SOURCE 12 14 select ARCH_HAS_KEEPINITRD ··· 20 18 select ARCH_HAS_SET_MEMORY 21 19 select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL 22 20 select ARCH_HAS_STRICT_MODULE_RWX if MMU 21 + select ARCH_HAS_SYNC_DMA_FOR_DEVICE if SWIOTLB 22 + select ARCH_HAS_SYNC_DMA_FOR_CPU if SWIOTLB 23 23 select ARCH_HAS_TEARDOWN_DMA_OPS if MMU 24 24 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 25 25 select ARCH_HAVE_CUSTOM_GPIO_H
-4
arch/arm/mm/Kconfig
··· 664 664 !CPU_32v4 && !CPU_32v3 665 665 select PHYS_ADDR_T_64BIT 666 666 select SWIOTLB 667 - select ARCH_HAS_DMA_COHERENT_TO_PFN 668 - select ARCH_HAS_DMA_MMAP_PGPROT 669 - select ARCH_HAS_SYNC_DMA_FOR_DEVICE 670 - select ARCH_HAS_SYNC_DMA_FOR_CPU 671 667 help 672 668 Say Y if you have an ARMv7 processor supporting the LPAE page 673 669 table format and you would like to access memory beyond the
+3
drivers/iommu/dma-iommu.c
··· 965 965 { 966 966 bool coherent = dev_is_dma_coherent(dev); 967 967 size_t alloc_size = PAGE_ALIGN(size); 968 + int node = dev_to_node(dev); 968 969 struct page *page = NULL; 969 970 void *cpu_addr; 970 971 971 972 page = dma_alloc_contiguous(dev, alloc_size, gfp); 973 + if (!page) 974 + page = alloc_pages_node(node, gfp, get_order(alloc_size)); 972 975 if (!page) 973 976 return NULL; 974 977
+1 -4
include/linux/dma-contiguous.h
··· 160 160 static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size, 161 161 gfp_t gfp) 162 162 { 163 - int node = dev ? dev_to_node(dev) : NUMA_NO_NODE; 164 - size_t align = get_order(PAGE_ALIGN(size)); 165 - 166 - return alloc_pages_node(node, gfp, align); 163 + return NULL; 167 164 } 168 165 169 166 static inline void dma_free_contiguous(struct device *dev, struct page *page,
+2 -6
kernel/dma/contiguous.c
··· 230 230 */ 231 231 struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp) 232 232 { 233 - int node = dev ? dev_to_node(dev) : NUMA_NO_NODE; 234 - size_t count = PAGE_ALIGN(size) >> PAGE_SHIFT; 235 - size_t align = get_order(PAGE_ALIGN(size)); 233 + size_t count = size >> PAGE_SHIFT; 236 234 struct page *page = NULL; 237 235 struct cma *cma = NULL; 238 236 ··· 241 243 242 244 /* CMA can be used only in the context which permits sleeping */ 243 245 if (cma && gfpflags_allow_blocking(gfp)) { 246 + size_t align = get_order(size); 244 247 size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT); 245 248 246 249 page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN); 247 250 } 248 251 249 - /* Fallback allocation of normal pages */ 250 - if (!page) 251 - page = alloc_pages_node(node, gfp, align); 252 252 return page; 253 253 } 254 254
+9 -1
kernel/dma/direct.c
··· 85 85 struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, 86 86 dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) 87 87 { 88 + size_t alloc_size = PAGE_ALIGN(size); 89 + int node = dev_to_node(dev); 88 90 struct page *page = NULL; 89 91 u64 phys_mask; 90 92 ··· 97 95 gfp &= ~__GFP_ZERO; 98 96 gfp |= __dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask, 99 97 &phys_mask); 98 + page = dma_alloc_contiguous(dev, alloc_size, gfp); 99 + if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { 100 + dma_free_contiguous(dev, page, alloc_size); 101 + page = NULL; 102 + } 100 103 again: 101 - page = dma_alloc_contiguous(dev, size, gfp); 104 + if (!page) 105 + page = alloc_pages_node(node, gfp, get_order(alloc_size)); 102 106 if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { 103 107 dma_free_contiguous(dev, page, size); 104 108 page = NULL;