]> git.baikalelectronics.ru Git - kernel.git/commit
dma-mapping: fix 32-bit overflow with CONFIG_ARM_LPAE=n
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 26 Oct 2020 15:27:55 +0000 (16:27 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 29 Oct 2020 15:59:34 +0000 (16:59 +0100)
commit36947e2e0612a3c19864eec570b7d2096d86a387
tree9ea2fc1ffdf3242038e3c384393a8a7efdf30232
parentaaacfeee6649b5e192d8375d4f40db8049a4d710
dma-mapping: fix 32-bit overflow with CONFIG_ARM_LPAE=n

On r8a7791/koelsch and shmobile_defconfig, PCIe probing fails with:

    rcar-pcie fe000000.pcie: Adjusted size 0x0 invalid
    rcar-pcie: probe of fe000000.pcie failed with error -22

of_dma_get_range() returns the following map:

    cpu_start 0x40000000 dma_start 0x40000000 size 0x080000000 offset 0
    cpu_start 0x00000000 dma_start 0x00000000 size 0x100000000 offset 0

If CONFIG_ARM_LPAE=n, dma_addr_t is 32-bit.  Hence when assigning
r->dma_start + r->size to dma_end, this value will be truncated to
32-bit, yielding zero when processing the second table entry.
Consequently, both dma_start and dma_end will be zero, leading to a zero
size.

Fix this by changing the dma_start and dma_end variables from dma_addr_t
to u64.

Fixes: 2e951a2ee581fd12 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/of/device.c