lantiq: Backport upstream network driver locking fix
[openwrt/staging/hauke.git] / target / linux / lantiq / patches-5.4 / 0010-net-lantiq-Add-locking-for-TX-DMA-channel.patch
1 From e0c0ad805905d7dc3d6cd36da86119535f0cf374 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Tue, 22 Sep 2020 23:14:03 +0200
4 Subject: net: lantiq: Add locking for TX DMA channel
5
6 The TX DMA channel data is accessed by the xrx200_start_xmit() and the
7 xrx200_tx_housekeeping() function from different threads. Make sure the
8 accesses are synchronized by acquiring the netif_tx_lock() in the
9 xrx200_tx_housekeeping() function too. This lock is acquired by the
10 kernel before calling xrx200_start_xmit().
11
12 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
13 ---
14 drivers/net/ethernet/lantiq_xrx200.c | 2 ++
15 1 file changed, 2 insertions(+)
16
17 --- a/drivers/net/ethernet/lantiq_xrx200.c
18 +++ b/drivers/net/ethernet/lantiq_xrx200.c
19 @@ -245,6 +245,7 @@ static int xrx200_tx_housekeeping(struct
20 int pkts = 0;
21 int bytes = 0;
22
23 + netif_tx_lock(net_dev);
24 while (pkts < budget) {
25 struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->tx_free];
26
27 @@ -268,6 +269,7 @@ static int xrx200_tx_housekeeping(struct
28 net_dev->stats.tx_bytes += bytes;
29 netdev_completed_queue(ch->priv->net_dev, pkts, bytes);
30
31 + netif_tx_unlock(net_dev);
32 if (netif_queue_stopped(net_dev))
33 netif_wake_queue(net_dev);
34