]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
bc9b7a933679045cb73770ff0442a0116744bcdd
[thirdparty/kernel/stable-queue.git] /
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
5
6 From: Yuiko Oshino <yuiko.oshino@microchip.com>
7
8 commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.
9
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.
14
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>
19 ---
20 drivers/net/ethernet/microchip/lan743x_main.c | 20 ++++++++++++++++++++
21 1 file changed, 20 insertions(+)
22
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
26 ret = -EINVAL;
27 goto cleanup;
28 }
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");
35 + ret = -ENOMEM;
36 + goto cleanup;
37 + }
38 + }
39 ring_allocation_size = ALIGN(tx->ring_size *
40 sizeof(struct lan743x_tx_descriptor),
41 PAGE_SIZE);
42 @@ -2258,6 +2268,16 @@ static int lan743x_rx_ring_init(struct l
43 ret = -EINVAL;
44 goto cleanup;
45 }
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");
52 + ret = -ENOMEM;
53 + goto cleanup;
54 + }
55 + }
56 ring_allocation_size = ALIGN(rx->ring_size *
57 sizeof(struct lan743x_rx_descriptor),
58 PAGE_SIZE);