1
0
Fork 0
alistair23-linux/arch/arm
Chen-Yu Tsai ad7c38abe8 ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
commit f3cc4e1d44 upstream.

max_pfn, as set in arch/arm/mm/init.c:

    static void __init find_limits(unsigned long *min,
				   unsigned long *max_low,
				   unsigned long *max_high)
    {
	    *max_low = PFN_DOWN(memblock_get_current_limit());
	    *min = PFN_UP(memblock_start_of_DRAM());
	    *max_high = PFN_DOWN(memblock_end_of_DRAM());
    }

with memblock_end_of_DRAM() pointing to the next byte after DRAM.  As
such, max_pfn points to the PFN after the end of DRAM.

Thus when using max_pfn to check DMA masks, we should subtract one when
checking DMA ranges against it.

Commit 8bf1268f48 ("ARM: dma-api: fix off-by-one error in
__dma_supported()") fixed the same issue, but missed this spot.

This issue was found while working on the sun4i-csi v4l2 driver on the
Allwinner R40 SoC.  On Allwinner SoCs, DRAM is offset at 0x40000000, and
we are starting to use of_dma_configure() with the "dma-ranges" property
in the device tree to have the DMA API handle the offset.

In this particular instance, dma-ranges was set to the same range as the
actual available (2 GiB) DRAM.  The following error appeared when the
driver attempted to allocate a buffer:

    sun4i-csi 1c09000.csi: Coherent DMA mask 0x7fffffff (pfn 0x40000-0xc0000)
    covers a smaller range of system memory than the DMA zone pfn 0x0-0xc0001
    sun4i-csi 1c09000.csi: dma_alloc_coherent of size 307200 failed

Fixing the off-by-one error makes things work.

Link: http://lkml.kernel.org/r/20191224030239.5656-1-wens@kernel.org
Fixes: 11a5aa3256 ("ARM: dma-mapping: check DMA mask against available memory")
Fixes: 9f28cde0bc ("ARM: another fix for the DMA mapping checks")
Fixes: ab746573c4 ("ARM: dma-mapping: allow larger DMA mask than supported")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-11 04:35:25 -08:00
..
boot ARM: dts: am43x-epos-evm: set data pin directions for spi0 and spi1 2020-02-05 21:22:50 +00:00
common ARM: scoop: Use the right include 2019-09-03 22:09:46 +02:00
configs ARM: config: aspeed-g5: Enable 8250_DW quirks 2020-02-01 09:34:49 +00:00
crypto crypto: arm/aes-ce - add dependency on AES library 2019-10-01 23:06:43 +10:00
include KVM: arm64: Only sign-extend MMIO up to register width 2020-02-11 04:35:16 -08:00
kernel ARM: 8955/1: virt: Relax arch timer version check during early boot 2020-02-05 21:22:49 +00:00
kvm kbuild: change *FLAGS_<basetarget>.o to take the path relative to $(obj) 2019-09-04 23:12:50 +09:00
lib Merge branch 'misc' into fixes 2019-10-22 17:37:29 +01:00
mach-actions treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mach-alpine treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mach-artpec treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-asm9260 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-aspeed ARM: SoC fixes 2019-09-30 10:04:28 -07:00
mach-at91 ARM: at91: move platform-specific asm-offset.h to arch/arm/mach-at91 2019-08-23 21:50:10 +02:00
mach-axxia treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-bcm ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-berlin treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-clps711x treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mach-cns3xxx treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 418 2019-06-05 17:37:15 +02:00
mach-davinci ARM: davinci: select CONFIG_RESET_CONTROLLER 2020-01-23 08:22:32 +01:00
mach-digicolor treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-dove ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-ebsa110 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-efm32 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-ep93xx Merge branch 'spi-5.4' into spi-next 2019-09-15 10:32:06 +01:00
mach-exynos ARM: exynos: Enable support for ARM architected timers 2019-09-09 20:56:43 +02:00
mach-footbridge treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-gemini treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-highbank ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-hisi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-imx ARM: imx: stop adjusting ar8031 phy tx delay 2019-08-24 20:30:22 +02:00
mach-integrator treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-iop32x ARM: iop32x: merge everything into mach-iop32x/ 2019-08-14 15:36:22 +02:00
mach-ixp4xx docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
mach-keystone ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-lpc18xx treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-lpc32xx ARM: lpc32xx: allow multiplatform build 2019-08-15 21:34:08 +02:00
mach-mediatek treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mach-meson treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mach-milbeaut treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-mmp irqchip/mmp: Mask off interrupts from other cores 2019-08-30 15:23:30 +01:00
mach-moxart treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
mach-mv78xx0 ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-mvebu treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 406 2019-06-05 17:37:13 +02:00
mach-mxs treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-nomadik treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
mach-npcm treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-nspire ARM: mach-nspire: Kill off CLCD auxdata 2019-08-13 15:48:23 +02:00
mach-omap1 Merge branch 'asoc-5.3' into asoc-linus 2019-09-09 14:55:18 +01:00
mach-omap2 hwrng: omap3-rom - Fix missing clock by probing with device tree 2020-01-26 10:01:03 +01:00
mach-orion5x ARM: orion/mvebu: unify debug-ll virtual addresses 2019-08-14 19:24:58 +02:00
mach-oxnas treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-picoxcell treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-prima2 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 4 2019-05-21 11:28:40 +02:00
mach-pxa ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-qcom treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-rda treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mach-realview treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-rockchip Another missing of_node_put 2019-06-17 05:14:24 -07:00
mach-rpc ARM: riscpc: Mark expected switch fall-through 2019-08-20 19:42:48 -05:00
mach-s3c24xx docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
mach-s3c64xx ARM: s3c64xx: squash samsung_usb_phy.h into setup-usb-phy.c 2019-08-21 19:50:40 +02:00
mach-s5pv210
mach-sa1100 ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-shmobile ARM: mach-shmobile: Don't init CNTVOFF/counter if PSCI is available 2019-05-31 11:38:01 +02:00
mach-socfpga treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-spear treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-sti treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-stm32 ARM: SoC platform updates 2019-07-19 17:05:08 -07:00
mach-sunxi ARM: sunxi: Fix CPU powerdown on A83T 2019-10-29 09:09:56 +01:00
mach-tango ARM: use arch_extension directive instead of arch argument 2019-06-19 09:44:25 -07:00
mach-tegra ARM: tegra: Fix FLOW_CTLR_HALT register clobbering by tegra_resume() 2019-12-21 11:04:48 +01:00
mach-u300 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
mach-uniphier
mach-ux500 ARM: ux500: Stop populating the PRCMU devices early 2019-07-23 09:17:06 +02:00
mach-versatile Versatile platform updates for the v5.3 kernel cycle: 2019-06-17 05:11:53 -07:00
mach-vexpress ARM: vexpress: Set-up shared OPP table instead of individual for each CPU 2020-01-12 12:21:17 +01:00
mach-vt8500 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
mach-zx treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mach-zynq ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up 2019-08-14 09:40:43 +02:00
mm ARM: dma-api: fix max_pfn off-by-one error in __dma_supported() 2020-02-11 04:35:25 -08:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-06-17 20:20:36 -07:00
nwfpe treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
oprofile
plat-omap ARM: OMAP: dma: Mark expected switch fall-throughs 2019-08-13 04:53:37 -07:00
plat-orion treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
plat-pxa treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
plat-samsung ARM: samsung: Fix system restart on S3C6410 2019-09-09 20:54:35 +02:00
plat-versatile treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
probes treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
tools docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
vdso kbuild: add --hash-style= and --build-id unconditionally 2019-07-17 22:37:51 +09:00
vfp treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
xen xen: fixes and cleanups for 5.4-rc2 2019-10-04 11:13:09 -07:00
Kconfig arm: Implement copy_thread_tls 2020-01-14 20:08:34 +01:00
Kconfig-nommu
Kconfig.debug ARM updates for 5.4-rc1: 2019-09-22 09:39:09 -07:00
Makefile ARM updates for 5.4-rc1: 2019-09-22 09:39:09 -07:00