]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_a...
authorYuiko Oshino <yuiko.oshino@microchip.com>
Fri, 22 Oct 2021 15:53:43 +0000 (11:53 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Oct 2021 12:38:56 +0000 (13:38 +0100)
The dma failure was reported in the raspberry pi github (issue #4117).
https://github.com/raspberrypi/linux/issues/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: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/lan743x_main.c

index 3ac968b1c6ce9e6e5dde2751055f2a6a4aeaeeaa..c4f32c7e0db1f7a4e1791c313d5bc4f33efa9ec5 100644 (file)
@@ -1743,6 +1743,16 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
                ret = -EINVAL;
                goto cleanup;
        }
+       if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
+                                     DMA_BIT_MASK(64))) {
+               if (dma_set_mask_and_coherent(&tx->adapter->pdev->dev,
+                                             DMA_BIT_MASK(32))) {
+                       dev_warn(&tx->adapter->pdev->dev,
+                                "lan743x_: No suitable DMA available\n");
+                       ret = -ENOMEM;
+                       goto cleanup;
+               }
+       }
        ring_allocation_size = ALIGN(tx->ring_size *
                                     sizeof(struct lan743x_tx_descriptor),
                                     PAGE_SIZE);
@@ -2276,6 +2286,16 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
                ret = -EINVAL;
                goto cleanup;
        }
+       if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
+                                     DMA_BIT_MASK(64))) {
+               if (dma_set_mask_and_coherent(&rx->adapter->pdev->dev,
+                                             DMA_BIT_MASK(32))) {
+                       dev_warn(&rx->adapter->pdev->dev,
+                                "lan743x_: No suitable DMA available\n");
+                       ret = -ENOMEM;
+                       goto cleanup;
+               }
+       }
        ring_allocation_size = ALIGN(rx->ring_size *
                                     sizeof(struct lan743x_rx_descriptor),
                                     PAGE_SIZE);