Skip to content

Commit 48ab6d5

Browse files
geertuChristoph Hellwig
authored and
Christoph Hellwig
committed
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: e0d0727 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset") Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent ed8780e commit 48ab6d5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/of/device.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
9393
{
9494
const struct iommu_ops *iommu;
9595
const struct bus_dma_region *map = NULL;
96-
dma_addr_t dma_start = 0;
96+
u64 dma_start = 0;
9797
u64 mask, end, size = 0;
9898
bool coherent;
9999
int ret;
@@ -109,10 +109,10 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
109109
return ret == -ENODEV ? 0 : ret;
110110
} else {
111111
const struct bus_dma_region *r = map;
112-
dma_addr_t dma_end = 0;
112+
u64 dma_end = 0;
113113

114114
/* Determine the overall bounds of all DMA regions */
115-
for (dma_start = ~(dma_addr_t)0; r->size; r++) {
115+
for (dma_start = ~0ULL; r->size; r++) {
116116
/* Take lower and upper limits */
117117
if (r->dma_start < dma_start)
118118
dma_start = r->dma_start;

0 commit comments

Comments
 (0)