Skip to content

Commit bfc3ba8

Browse files
microchip1SherryYang1
authored andcommitted
net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent
commit 95a359c upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit b232898c1d4bcade408a0a84229211c5fae5ab5f) Signed-off-by: Sherry Yang <[email protected]>
1 parent 8203676 commit bfc3ba8

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
@@ -1706,6 +1706,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
17061706
ret = -EINVAL;
17071707
goto cleanup;
17081708
}
1709+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1710+
DMA_BIT_MASK(64))) {
1711+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1712+
DMA_BIT_MASK(32))) {
1713+
dev_warn(&tx->adapter->pdev->dev,
1714+
"lan743x_: No suitable DMA available\n");
1715+
ret = -ENOMEM;
1716+
goto cleanup;
1717+
}
1718+
}
17091719
ring_allocation_size = ALIGN(tx->ring_size *
17101720
sizeof(struct lan743x_tx_descriptor),
17111721
PAGE_SIZE);
@@ -2256,6 +2266,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
22562266
ret = -EINVAL;
22572267
goto cleanup;
22582268
}
2269+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2270+
DMA_BIT_MASK(64))) {
2271+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2272+
DMA_BIT_MASK(32))) {
2273+
dev_warn(&rx->adapter->pdev->dev,
2274+
"lan743x_: No suitable DMA available\n");
2275+
ret = -ENOMEM;
2276+
goto cleanup;
2277+
}
2278+
}
22592279
ring_allocation_size = ALIGN(rx->ring_size *
22602280
sizeof(struct lan743x_rx_descriptor),
22612281
PAGE_SIZE);

0 commit comments

Comments
 (0)