dma-mapping: treat dev->bus_dma_mask as a DMA limit
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Thu, 21 Nov 2019 09:26:44 +0000 (10:26 +0100)
committerpopcornmix <popcornmix@gmail.com>
Wed, 1 Jul 2020 15:33:26 +0000 (16:33 +0100)
commitd658ce45bc14e56220b9803ec7ffc06d1a65f963
tree18b4d8349e30b36e56303ca899f8d1eb336f638f
parent7a2497a038b322133b5d0570326a3706ab069588
dma-mapping: treat dev->bus_dma_mask as a DMA limit

commit a7ba70f1787f977f970cd116076c6fce4b9e01cc upstream.

Using a mask to represent bus DMA constraints has a set of limitations.
The biggest one being it can only hold a power of two (minus one). The
DMA mapping code is already aware of this and treats dev->bus_dma_mask
as a limit. This quirk is already used by some architectures although
still rare.

With the introduction of the Raspberry Pi 4 we've found a new contender
for the use of bus DMA limits, as its PCIe bus can only address the
lower 3GB of memory (of a total of 4GB). This is impossible to represent
with a mask. To make things worse the device-tree code rounds non power
of two bus DMA limits to the next power of two, which is unacceptable in
this case.

In the light of this, rename dev->bus_dma_mask to dev->bus_dma_limit all
over the tree and treat it as such. Note that dev->bus_dma_limit should
contain the higher accessible DMA address.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
13 files changed:
arch/mips/pci/fixup-sb1250.c
arch/powerpc/sysdev/fsl_pci.c
arch/x86/kernel/pci-dma.c
arch/x86/mm/mem_encrypt.c
arch/x86/pci/sta2x11-fixup.c
drivers/acpi/arm64/iort.c
drivers/ata/ahci.c
drivers/iommu/dma-iommu.c
drivers/of/device.c
include/linux/device.h
include/linux/dma-direct.h
include/linux/dma-mapping.h
kernel/dma/direct.c