Skip to content

Commit 95a359c

Browse files
microchip1davem330
authored andcommitted
net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent
The dma failure was reported in the raspberry pi github (issue #4117). raspberrypi/linux#4117 The use of dma_set_mask_and_coherent fixes the issue. Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430. Fixes: 23f0703 ("lan743x: Add main source files for new lan743x driver") Signed-off-by: Yuiko Oshino <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d6423d2 commit 95a359c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
17431743
ret = -EINVAL;
17441744
goto cleanup;
17451745
}
1746+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1747+
DMA_BIT_MASK(64))) {
1748+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1749+
DMA_BIT_MASK(32))) {
1750+
dev_warn(&tx->adapter->pdev->dev,
1751+
"lan743x_: No suitable DMA available\n");
1752+
ret = -ENOMEM;
1753+
goto cleanup;
1754+
}
1755+
}
17461756
ring_allocation_size = ALIGN(tx->ring_size *
17471757
sizeof(struct lan743x_tx_descriptor),
17481758
PAGE_SIZE);
@@ -2276,6 +2286,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
22762286
ret = -EINVAL;
22772287
goto cleanup;
22782288
}
2289+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2290+
DMA_BIT_MASK(64))) {
2291+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2292+
DMA_BIT_MASK(32))) {
2293+
dev_warn(&rx->adapter->pdev->dev,
2294+
"lan743x_: No suitable DMA available\n");
2295+
ret = -ENOMEM;
2296+
goto cleanup;
2297+
}
2298+
}
22792299
ring_allocation_size = ALIGN(rx->ring_size *
22802300
sizeof(struct lan743x_rx_descriptor),
22812301
PAGE_SIZE);

0 commit comments

Comments
 (0)