c63628da99da816fe6df9cd0e948bd8a0242ba5d
[openwrt/staging/ldir.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Mon, 5 Dec 2022 12:34:42 +0100
3 Subject: [PATCH] net: ethernet: mtk_wed: add reset to rx_ring_setup callback
4
5 This patch adds reset parameter to mtk_wed_rx_ring_setup signature
6 in order to align rx_ring_setup callback to tx_ring_setup one introduced
7 in 'commit 23dca7a90017 ("net: ethernet: mtk_wed: add reset to
8 tx_ring_setup callback")'
9
10 Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
11 Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
12 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
13 Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
14 Link: https://lore.kernel.org/r/29c6e7a5469e784406cf3e2920351d1207713d05.1670239984.git.lorenzo@kernel.org
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 ---
17
18 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
20 @@ -1252,7 +1252,8 @@ mtk_wed_wdma_rx_ring_setup(struct mtk_we
21 }
22
23 static int
24 -mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
25 +mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev, int idx, int size,
26 + bool reset)
27 {
28 u32 desc_size = sizeof(struct mtk_wdma_desc) * dev->hw->version;
29 struct mtk_wed_ring *wdma;
30 @@ -1261,8 +1262,8 @@ mtk_wed_wdma_tx_ring_setup(struct mtk_we
31 return -EINVAL;
32
33 wdma = &dev->tx_wdma[idx];
34 - if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE, desc_size,
35 - true))
36 + if (!reset && mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
37 + desc_size, true))
38 return -ENOMEM;
39
40 wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_BASE,
41 @@ -1272,6 +1273,9 @@ mtk_wed_wdma_tx_ring_setup(struct mtk_we
42 wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_CPU_IDX, 0);
43 wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_DMA_IDX, 0);
44
45 + if (reset)
46 + mtk_wed_ring_reset(wdma, MTK_WED_WDMA_RING_SIZE, true);
47 +
48 if (!idx) {
49 wed_w32(dev, MTK_WED_WDMA_RING_TX + MTK_WED_RING_OFS_BASE,
50 wdma->desc_phys);
51 @@ -1611,18 +1615,20 @@ mtk_wed_txfree_ring_setup(struct mtk_wed
52 }
53
54 static int
55 -mtk_wed_rx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
56 +mtk_wed_rx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs,
57 + bool reset)
58 {
59 struct mtk_wed_ring *ring = &dev->rx_ring[idx];
60
61 if (WARN_ON(idx >= ARRAY_SIZE(dev->rx_ring)))
62 return -EINVAL;
63
64 - if (mtk_wed_ring_alloc(dev, ring, MTK_WED_RX_RING_SIZE,
65 - sizeof(*ring->desc), false))
66 + if (!reset && mtk_wed_ring_alloc(dev, ring, MTK_WED_RX_RING_SIZE,
67 + sizeof(*ring->desc), false))
68 return -ENOMEM;
69
70 - if (mtk_wed_wdma_tx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE))
71 + if (mtk_wed_wdma_tx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE,
72 + reset))
73 return -ENOMEM;
74
75 ring->reg_base = MTK_WED_RING_RX_DATA(idx);
76 --- a/include/linux/soc/mediatek/mtk_wed.h
77 +++ b/include/linux/soc/mediatek/mtk_wed.h
78 @@ -162,7 +162,7 @@ struct mtk_wed_ops {
79 int (*tx_ring_setup)(struct mtk_wed_device *dev, int ring,
80 void __iomem *regs, bool reset);
81 int (*rx_ring_setup)(struct mtk_wed_device *dev, int ring,
82 - void __iomem *regs);
83 + void __iomem *regs, bool reset);
84 int (*txfree_ring_setup)(struct mtk_wed_device *dev,
85 void __iomem *regs);
86 int (*msg_update)(struct mtk_wed_device *dev, int cmd_id,
87 @@ -230,8 +230,8 @@ mtk_wed_get_rx_capa(struct mtk_wed_devic
88 (_dev)->ops->irq_get(_dev, _mask)
89 #define mtk_wed_device_irq_set_mask(_dev, _mask) \
90 (_dev)->ops->irq_set_mask(_dev, _mask)
91 -#define mtk_wed_device_rx_ring_setup(_dev, _ring, _regs) \
92 - (_dev)->ops->rx_ring_setup(_dev, _ring, _regs)
93 +#define mtk_wed_device_rx_ring_setup(_dev, _ring, _regs, _reset) \
94 + (_dev)->ops->rx_ring_setup(_dev, _ring, _regs, _reset)
95 #define mtk_wed_device_ppe_check(_dev, _skb, _reason, _hash) \
96 (_dev)->ops->ppe_check(_dev, _skb, _reason, _hash)
97 #define mtk_wed_device_update_msg(_dev, _id, _msg, _len) \
98 @@ -251,7 +251,7 @@ static inline bool mtk_wed_device_active
99 #define mtk_wed_device_reg_write(_dev, _reg, _val) do {} while (0)
100 #define mtk_wed_device_irq_get(_dev, _mask) 0
101 #define mtk_wed_device_irq_set_mask(_dev, _mask) do {} while (0)
102 -#define mtk_wed_device_rx_ring_setup(_dev, _ring, _regs) -ENODEV
103 +#define mtk_wed_device_rx_ring_setup(_dev, _ring, _regs, _reset) -ENODEV
104 #define mtk_wed_device_ppe_check(_dev, _skb, _reason, _hash) do {} while (0)
105 #define mtk_wed_device_update_msg(_dev, _id, _msg, _len) -ENODEV
106 #define mtk_wed_device_stop(_dev) do {} while (0)