ath79: add support for Huawei AP5030DN
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 729-17-v6.3-net-ethernet-mtk_wed-get-rid-of-queue-lock-for-tx-qu.patch
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Thu, 12 Jan 2023 10:21:29 +0100
3 Subject: [PATCH] net: ethernet: mtk_wed: get rid of queue lock for tx queue
4
5 Similar to MTK Wireless Ethernet Dispatcher (WED) MCU rx queue,
6 we do not need to protect WED MCU tx queue with a spin lock since
7 the tx queue is accessed in the two following routines:
8 - mtk_wed_wo_queue_tx_skb():
9 it is run at initialization and during mt7915 normal operation.
10 Moreover MCU messages are serialized through MCU mutex.
11 - mtk_wed_wo_queue_tx_clean():
12 it runs just at mt7915 driver module unload when no more messages
13 are sent to the MCU.
14
15 Remove tx queue spinlock.
16
17 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
18 Link: https://lore.kernel.org/r/7bd0337b2a13ab1a63673b7c03fd35206b3b284e.1673515140.git.lorenzo@kernel.org
19 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
20 ---
21
22 --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c
23 +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
24 @@ -258,7 +258,6 @@ mtk_wed_wo_queue_alloc(struct mtk_wed_wo
25 int n_desc, int buf_size, int index,
26 struct mtk_wed_wo_queue_regs *regs)
27 {
28 - spin_lock_init(&q->lock);
29 q->regs = *regs;
30 q->n_desc = n_desc;
31 q->buf_size = buf_size;
32 @@ -290,7 +289,6 @@ mtk_wed_wo_queue_tx_clean(struct mtk_wed
33 struct page *page;
34 int i;
35
36 - spin_lock_bh(&q->lock);
37 for (i = 0; i < q->n_desc; i++) {
38 struct mtk_wed_wo_queue_entry *entry = &q->entry[i];
39
40 @@ -299,7 +297,6 @@ mtk_wed_wo_queue_tx_clean(struct mtk_wed
41 skb_free_frag(entry->buf);
42 entry->buf = NULL;
43 }
44 - spin_unlock_bh(&q->lock);
45
46 if (!q->cache.va)
47 return;
48 @@ -347,8 +344,6 @@ int mtk_wed_wo_queue_tx_skb(struct mtk_w
49 int ret = 0, index;
50 u32 ctrl;
51
52 - spin_lock_bh(&q->lock);
53 -
54 q->tail = mtk_wed_mmio_r32(wo, q->regs.dma_idx);
55 index = (q->head + 1) % q->n_desc;
56 if (q->tail == index) {
57 @@ -379,8 +374,6 @@ int mtk_wed_wo_queue_tx_skb(struct mtk_w
58 mtk_wed_wo_queue_kick(wo, q, q->head);
59 mtk_wed_wo_kickout(wo);
60 out:
61 - spin_unlock_bh(&q->lock);
62 -
63 dev_kfree_skb(skb);
64
65 return ret;
66 --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.h
67 +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.h
68 @@ -211,7 +211,6 @@ struct mtk_wed_wo_queue {
69 struct mtk_wed_wo_queue_regs regs;
70
71 struct page_frag_cache cache;
72 - spinlock_t lock;
73
74 struct mtk_wed_wo_queue_desc *desc;
75 dma_addr_t desc_dma;