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

dma-mapping: remove bogus test for pfn_valid from dma_map_resource

dma_map_resource() uses pfn_valid() to ensure the range is not RAM.
However, pfn_valid() only checks for availability of the memory map for a
PFN but it does not ensure that the PFN is actually backed by RAM.

As dma_map_resource() is the only method in DMA mapping APIs that has this
check, simply drop the pfn_valid() test from dma_map_resource().

Link: https://lore.kernel.org/all/20210824173741.GC623@arm.com/
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20210930013039.11260-2-rppt@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Mike Rapoport and committed by
Will Deacon
a9c38c5d 5816b3e6

-4
-4
kernel/dma/mapping.c
··· 296 296 if (WARN_ON_ONCE(!dev->dma_mask)) 297 297 return DMA_MAPPING_ERROR; 298 298 299 - /* Don't allow RAM to be mapped */ 300 - if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr)))) 301 - return DMA_MAPPING_ERROR; 302 - 303 299 if (dma_map_direct(dev, ops)) 304 300 addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs); 305 301 else if (ops->map_resource)