1 From 95a359c9553342d36d408d35331ff0bfce75272f Mon Sep 17 00:00:00 2001
2 From: Yuiko Oshino <yuiko.oshino@microchip.com>
3 Date: Fri, 22 Oct 2021 11:53:43 -0400
4 Subject: net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent
6 From: Yuiko Oshino <yuiko.oshino@microchip.com>
8 commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.
10 The dma failure was reported in the raspberry pi github (issue #4117).
11 https://github.com/raspberrypi/linux/issues/4117
12 The use of dma_set_mask_and_coherent fixes the issue.
13 Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.
15 Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
16 Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
17 Signed-off-by: David S. Miller <davem@davemloft.net>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 drivers/net/ethernet/microchip/lan743x_main.c | 20 ++++++++++++++++++++
21 1 file changed, 20 insertions(+)
23 --- a/drivers/net/ethernet/microchip/lan743x_main.c
24 +++ b/drivers/net/ethernet/microchip/lan743x_main.c
25 @@ -1710,6 +1710,16 @@ static int lan743x_tx_ring_init(struct l
29 + if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
30 + DMA_BIT_MASK(64))) {
31 + if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
32 + DMA_BIT_MASK(32))) {
33 + dev_warn(&tx->adapter->pdev->dev,
34 + "lan743x_: No suitable DMA available\n");
39 ring_allocation_size = ALIGN(tx->ring_size *
40 sizeof(struct lan743x_tx_descriptor),
42 @@ -2258,6 +2268,16 @@ static int lan743x_rx_ring_init(struct l
46 + if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
47 + DMA_BIT_MASK(64))) {
48 + if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
49 + DMA_BIT_MASK(32))) {
50 + dev_warn(&rx->adapter->pdev->dev,
51 + "lan743x_: No suitable DMA available\n");
56 ring_allocation_size = ALIGN(rx->ring_size *
57 sizeof(struct lan743x_rx_descriptor),