Skip to content

Commit 84a9eb9

Browse files
microchip1gregkh
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]>
1 parent fcda74c commit 84a9eb9

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
@@ -1710,6 +1710,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
17101710
ret = -EINVAL;
17111711
goto cleanup;
17121712
}
1713+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1714+
DMA_BIT_MASK(64))) {
1715+
if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
1716+
DMA_BIT_MASK(32))) {
1717+
dev_warn(&tx->adapter->pdev->dev,
1718+
"lan743x_: No suitable DMA available\n");
1719+
ret = -ENOMEM;
1720+
goto cleanup;
1721+
}
1722+
}
17131723
ring_allocation_size = ALIGN(tx->ring_size *
17141724
sizeof(struct lan743x_tx_descriptor),
17151725
PAGE_SIZE);
@@ -2258,6 +2268,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
22582268
ret = -EINVAL;
22592269
goto cleanup;
22602270
}
2271+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2272+
DMA_BIT_MASK(64))) {
2273+
if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
2274+
DMA_BIT_MASK(32))) {
2275+
dev_warn(&rx->adapter->pdev->dev,
2276+
"lan743x_: No suitable DMA available\n");
2277+
ret = -ENOMEM;
2278+
goto cleanup;
2279+
}
2280+
}
22612281
ring_allocation_size = ALIGN(rx->ring_size *
22622282
sizeof(struct lan743x_rx_descriptor),
22632283
PAGE_SIZE);

0 commit comments

Comments
 (0)