mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	dma-mapping: reject __GFP_COMP in dma_alloc_attrs
DMA allocations can never be turned back into a page pointer, so requesting compound pages doesn't make sense and it can't even be supported at all by various backends. Reject __GFP_COMP with a warning in dma_alloc_attrs, and stop clearing the flag in the arm dma ops and dma-iommu. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
This commit is contained in:
		
							parent
							
								
									3306877aff
								
							
						
					
					
						commit
						ffcb754584
					
				
					 3 changed files with 8 additions and 20 deletions
				
			
		| 
						 | 
					@ -564,14 +564,6 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
 | 
				
			||||||
	if (mask < 0xffffffffULL)
 | 
						if (mask < 0xffffffffULL)
 | 
				
			||||||
		gfp |= GFP_DMA;
 | 
							gfp |= GFP_DMA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Following is a work-around (a.k.a. hack) to prevent pages
 | 
					 | 
				
			||||||
	 * with __GFP_COMP being passed to split_page() which cannot
 | 
					 | 
				
			||||||
	 * handle them.  The real problem is that this flag probably
 | 
					 | 
				
			||||||
	 * should be 0 on ARM as it is not supported on this
 | 
					 | 
				
			||||||
	 * platform; see CONFIG_HUGETLBFS.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	gfp &= ~(__GFP_COMP);
 | 
					 | 
				
			||||||
	args.gfp = gfp;
 | 
						args.gfp = gfp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*handle = DMA_MAPPING_ERROR;
 | 
						*handle = DMA_MAPPING_ERROR;
 | 
				
			||||||
| 
						 | 
					@ -1093,15 +1085,6 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
 | 
				
			||||||
		return __iommu_alloc_simple(dev, size, gfp, handle,
 | 
							return __iommu_alloc_simple(dev, size, gfp, handle,
 | 
				
			||||||
					    coherent_flag, attrs);
 | 
										    coherent_flag, attrs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Following is a work-around (a.k.a. hack) to prevent pages
 | 
					 | 
				
			||||||
	 * with __GFP_COMP being passed to split_page() which cannot
 | 
					 | 
				
			||||||
	 * handle them.  The real problem is that this flag probably
 | 
					 | 
				
			||||||
	 * should be 0 on ARM as it is not supported on this
 | 
					 | 
				
			||||||
	 * platform; see CONFIG_HUGETLBFS.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	gfp &= ~(__GFP_COMP);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	pages = __iommu_alloc_buffer(dev, size, gfp, attrs, coherent_flag);
 | 
						pages = __iommu_alloc_buffer(dev, size, gfp, attrs, coherent_flag);
 | 
				
			||||||
	if (!pages)
 | 
						if (!pages)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -744,9 +744,6 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
 | 
				
			||||||
	/* IOMMU can map any pages, so himem can also be used here */
 | 
						/* IOMMU can map any pages, so himem can also be used here */
 | 
				
			||||||
	gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
 | 
						gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* It makes no sense to muck about with huge pages */
 | 
					 | 
				
			||||||
	gfp &= ~__GFP_COMP;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (count) {
 | 
						while (count) {
 | 
				
			||||||
		struct page *page = NULL;
 | 
							struct page *page = NULL;
 | 
				
			||||||
		unsigned int order_size;
 | 
							unsigned int order_size;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -498,6 +498,14 @@ void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	WARN_ON_ONCE(!dev->coherent_dma_mask);
 | 
						WARN_ON_ONCE(!dev->coherent_dma_mask);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * DMA allocations can never be turned back into a page pointer, so
 | 
				
			||||||
 | 
						 * requesting compound pages doesn't make sense (and can't even be
 | 
				
			||||||
 | 
						 * supported at all by various backends).
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (WARN_ON_ONCE(flag & __GFP_COMP))
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
 | 
						if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
 | 
				
			||||||
		return cpu_addr;
 | 
							return cpu_addr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue