Re: [PATCH 5.4 40/50] dma-direct: exclude dma_direct_map_resource from the min_low_pfn check
From: Naresh Kamboju
Date: Fri May 08 2020 - 09:20:24 EST
On Fri, 8 May 2020 at 18:23, Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> From: Christoph Hellwig <hch@xxxxxx>
>
> commit 68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6 upstream.
>
> The valid memory address check in dma_capable only makes sense when mapping
> normal memory, not when using dma_map_resource to map a device resource.
> Add a new boolean argument to dma_capable to exclude that check for the
> dma_map_resource case.
>
> Fixes: b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses")
> Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> Acked-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
<trim>
>
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -327,7 +327,7 @@ static inline bool dma_direct_possible(s
> size_t size)
> {
> return swiotlb_force != SWIOTLB_FORCE &&
> - dma_capable(dev, dma_addr, size);
> + dma_capable(dev, dma_addr, size, true);
While building kernel Image for arm architecture the following error noticed
on stale-rc 5.4 kernel branch.
# make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=arm
CROSS_COMPILE=arm-linux-gnueabihf- HOSTCC=gcc CC="sccache
arm-linux-gnueabihf-gcc" O=build zImage
#
../kernel/dma/direct.c: In function âdma_direct_possibleâ:
../kernel/dma/direct.c:330:3: error: too many arguments to function
âdma_capableâ
330 | dma_capable(dev, dma_addr, size, true);
| ^~~~~~~~~~~
In file included from ../include/linux/dma-direct.h:12,
from ../kernel/dma/direct.c:10:
../arch/arm/include/asm/dma-direct.h:17:20: note: declared here
17 | static inline bool dma_capable(struct device *dev, dma_addr_t
addr, size_t size)
| ^~~~~~~~~~~
In file included from ../include/linux/init.h:5,
from ../include/linux/memblock.h:12,
from ../kernel/dma/direct.c:7:
../kernel/dma/direct.c: In function âdma_direct_map_resourceâ:
../kernel/dma/direct.c:379:16: error: too many arguments to function
âdma_capableâ
379 | if (unlikely(!dma_capable(dev, dma_addr, size, false))) {
| ^~~~~~~~~~~
../include/linux/compiler.h:78:42: note: in definition of macro âunlikelyâ
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
In file included from ../include/linux/dma-direct.h:12,
from ../kernel/dma/direct.c:10:
../arch/arm/include/asm/dma-direct.h:17:20: note: declared here
17 | static inline bool dma_capable(struct device *dev, dma_addr_t
addr, size_t size)
| ^~~~~~~~~~~
make[3]: *** [../scripts/Makefile.build:266: kernel/dma/direct.o] Error 1
In file included from ../include/linux/string.h:6,
from ../include/linux/dma-mapping.h:6,
from ../include/linux/dma-direct.h:5,
from ../kernel/dma/swiotlb.c:24:
../kernel/dma/swiotlb.c: In function âswiotlb_mapâ:
../kernel/dma/swiotlb.c:681:16: error: too many arguments to function
âdma_capableâ
681 | if (unlikely(!dma_capable(dev, *dma_addr, size, true))) {
| ^~~~~~~~~~~
../include/linux/compiler.h:78:42: note: in definition of macro âunlikelyâ
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
In file included from ../include/linux/dma-direct.h:12,
from ../kernel/dma/swiotlb.c:24:
../arch/arm/include/asm/dma-direct.h:17:20: note: declared here
17 | static inline bool dma_capable(struct device *dev, dma_addr_t
addr, size_t size)
| ^~~~~~~~~~~