On Fri, 8 May 2020 at 18:23, Greg Kroah-Hartman
<gregkh(a)linuxfoundation.org> wrote:
>
> From: Christoph Hellwig <hch(a)lst.de>
>
> 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(a)samsung.com>
> Signed-off-by: Christoph Hellwig <hch(a)lst.de>
> Acked-by: Marek Szyprowski <m.szyprowski(a)samsung.com>
> Tested-by: Marek Szyprowski <m.szyprowski(a)samsung.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
<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)
| ^~~~~~~~~~~