4404971cc74ddee4246dcf9aa379081d1f4d2d2e
[openwrt/staging/neocturne.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Thu, 24 Nov 2022 16:22:55 +0100
3 Subject: [PATCH] net: ethernet: mtk_wed: add reset to tx_ring_setup callback
4
5 Introduce reset parameter to mtk_wed_tx_ring_setup signature.
6 This is a preliminary patch to add Wireless Ethernet Dispatcher reset
7 support.
8
9 Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
10 Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
11 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
12 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
13 ---
14
15 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
17 @@ -1181,7 +1181,8 @@ mtk_wed_ring_alloc(struct mtk_wed_device
18 }
19
20 static int
21 -mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size)
22 +mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size,
23 + bool reset)
24 {
25 u32 desc_size = sizeof(struct mtk_wdma_desc) * dev->hw->version;
26 struct mtk_wed_ring *wdma;
27 @@ -1190,8 +1191,8 @@ mtk_wed_wdma_rx_ring_setup(struct mtk_we
28 return -EINVAL;
29
30 wdma = &dev->rx_wdma[idx];
31 - if (mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE, desc_size,
32 - true))
33 + if (!reset && mtk_wed_ring_alloc(dev, wdma, MTK_WED_WDMA_RING_SIZE,
34 + desc_size, true))
35 return -ENOMEM;
36
37 wdma_w32(dev, MTK_WDMA_RING_RX(idx) + MTK_WED_RING_OFS_BASE,
38 @@ -1389,7 +1390,7 @@ mtk_wed_start(struct mtk_wed_device *dev
39
40 for (i = 0; i < ARRAY_SIZE(dev->rx_wdma); i++)
41 if (!dev->rx_wdma[i].desc)
42 - mtk_wed_wdma_rx_ring_setup(dev, i, 16);
43 + mtk_wed_wdma_rx_ring_setup(dev, i, 16, false);
44
45 mtk_wed_hw_init(dev);
46 mtk_wed_configure_irq(dev, irq_mask);
47 @@ -1498,7 +1499,8 @@ unlock:
48 }
49
50 static int
51 -mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
52 +mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs,
53 + bool reset)
54 {
55 struct mtk_wed_ring *ring = &dev->tx_ring[idx];
56
57 @@ -1517,11 +1519,12 @@ mtk_wed_tx_ring_setup(struct mtk_wed_dev
58 if (WARN_ON(idx >= ARRAY_SIZE(dev->tx_ring)))
59 return -EINVAL;
60
61 - if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE,
62 - sizeof(*ring->desc), true))
63 + if (!reset && mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE,
64 + sizeof(*ring->desc), true))
65 return -ENOMEM;
66
67 - if (mtk_wed_wdma_rx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE))
68 + if (mtk_wed_wdma_rx_ring_setup(dev, idx, MTK_WED_WDMA_RING_SIZE,
69 + reset))
70 return -ENOMEM;
71
72 ring->reg_base = MTK_WED_RING_TX(idx);
73 --- a/include/linux/soc/mediatek/mtk_wed.h
74 +++ b/include/linux/soc/mediatek/mtk_wed.h
75 @@ -158,7 +158,7 @@ struct mtk_wed_device {
76 struct mtk_wed_ops {
77 int (*attach)(struct mtk_wed_device *dev);
78 int (*tx_ring_setup)(struct mtk_wed_device *dev, int ring,
79 - void __iomem *regs);
80 + void __iomem *regs, bool reset);
81 int (*rx_ring_setup)(struct mtk_wed_device *dev, int ring,
82 void __iomem *regs);
83 int (*txfree_ring_setup)(struct mtk_wed_device *dev,
84 @@ -216,8 +216,8 @@ mtk_wed_get_rx_capa(struct mtk_wed_devic
85 #define mtk_wed_device_active(_dev) !!(_dev)->ops
86 #define mtk_wed_device_detach(_dev) (_dev)->ops->detach(_dev)
87 #define mtk_wed_device_start(_dev, _mask) (_dev)->ops->start(_dev, _mask)
88 -#define mtk_wed_device_tx_ring_setup(_dev, _ring, _regs) \
89 - (_dev)->ops->tx_ring_setup(_dev, _ring, _regs)
90 +#define mtk_wed_device_tx_ring_setup(_dev, _ring, _regs, _reset) \
91 + (_dev)->ops->tx_ring_setup(_dev, _ring, _regs, _reset)
92 #define mtk_wed_device_txfree_ring_setup(_dev, _regs) \
93 (_dev)->ops->txfree_ring_setup(_dev, _regs)
94 #define mtk_wed_device_reg_read(_dev, _reg) \
95 @@ -243,7 +243,7 @@ static inline bool mtk_wed_device_active
96 }
97 #define mtk_wed_device_detach(_dev) do {} while (0)
98 #define mtk_wed_device_start(_dev, _mask) do {} while (0)
99 -#define mtk_wed_device_tx_ring_setup(_dev, _ring, _regs) -ENODEV
100 +#define mtk_wed_device_tx_ring_setup(_dev, _ring, _regs, _reset) -ENODEV
101 #define mtk_wed_device_txfree_ring_setup(_dev, _ring, _regs) -ENODEV
102 #define mtk_wed_device_reg_read(_dev, _reg) 0
103 #define mtk_wed_device_reg_write(_dev, _reg, _val) do {} while (0)