Skip to content

Commit

Permalink
net: ethernet: microchip: lan743x: Fix dma allocation failure by usin…
Browse files Browse the repository at this point in the history
…g dma_set_mask_and_coherent

BugLink: https://bugs.launchpad.net/bugs/1952785

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]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>
  • Loading branch information
microchip1 authored and ksacilotto committed Jan 13, 2022
1 parent 699d80b commit eac6779
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions drivers/net/ethernet/microchip/lan743x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -2291,6 +2301,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);
Expand Down

0 comments on commit eac6779

Please sign in to comment.