1 From f9ec5723c3dbfcede9c7b0dcdf85e401ce16316c Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sat, 23 Jul 2022 16:29:29 +0200
4 Subject: [PATCH 1/5] net: ethernet: stmicro: stmmac: move queue reset to
7 Move queue reset to dedicated functions. This aside from a simple
8 cleanup is also required to allocate a dma conf without resetting the tx
9 queue while the device is temporarily detached as now the reset is not
10 part of the dma init function and can be done later in the code flow.
12 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 59 ++++++++++---------
16 1 file changed, 31 insertions(+), 28 deletions(-)
18 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
19 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
20 @@ -130,6 +130,9 @@ static irqreturn_t stmmac_mac_interrupt(
21 static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id);
22 static irqreturn_t stmmac_msi_intr_tx(int irq, void *data);
23 static irqreturn_t stmmac_msi_intr_rx(int irq, void *data);
24 +static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue);
25 +static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue);
26 +static void stmmac_reset_queues_param(struct stmmac_priv *priv);
27 static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue);
28 static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue);
30 @@ -1712,9 +1715,6 @@ static int __init_dma_rx_desc_rings(stru
37 /* Setup the chained descriptor addresses */
38 if (priv->mode == STMMAC_CHAIN_MODE) {
39 if (priv->extend_desc)
40 @@ -1820,12 +1820,6 @@ static int __init_dma_tx_desc_rings(stru
41 tx_q->tx_skbuff[i] = NULL;
48 - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
53 @@ -2694,10 +2688,7 @@ static void stmmac_tx_err(struct stmmac_
54 stmmac_stop_tx_dma(priv, chan);
55 dma_free_tx_skbufs(priv, chan);
56 stmmac_clear_tx_descriptors(priv, chan);
60 - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, chan));
61 + stmmac_reset_tx_queue(priv, chan);
62 stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
63 tx_q->dma_tx_phy, chan);
64 stmmac_start_tx_dma(priv, chan);
65 @@ -3781,6 +3772,8 @@ static int stmmac_open(struct net_device
69 + stmmac_reset_queues_param(priv);
71 ret = stmmac_hw_setup(dev, true);
73 netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
74 @@ -6430,6 +6423,7 @@ void stmmac_enable_rx_queue(struct stmma
78 + stmmac_reset_rx_queue(priv, queue);
79 stmmac_clear_rx_descriptors(priv, queue);
81 stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
82 @@ -6491,6 +6485,7 @@ void stmmac_enable_tx_queue(struct stmma
86 + stmmac_reset_tx_queue(priv, queue);
87 stmmac_clear_tx_descriptors(priv, queue);
89 stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
90 @@ -7411,6 +7406,25 @@ int stmmac_suspend(struct device *dev)
92 EXPORT_SYMBOL_GPL(stmmac_suspend);
94 +static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue)
96 + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
102 +static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue)
104 + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];
107 + tx_q->dirty_tx = 0;
110 + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
114 * stmmac_reset_queues_param - reset queue parameters
115 * @priv: device pointer
116 @@ -7421,22 +7435,11 @@ static void stmmac_reset_queues_param(st
117 u32 tx_cnt = priv->plat->tx_queues_to_use;
120 - for (queue = 0; queue < rx_cnt; queue++) {
121 - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
122 + for (queue = 0; queue < rx_cnt; queue++)
123 + stmmac_reset_rx_queue(priv, queue);
126 - rx_q->dirty_rx = 0;
129 - for (queue = 0; queue < tx_cnt; queue++) {
130 - struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];
133 - tx_q->dirty_tx = 0;
136 - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
138 + for (queue = 0; queue < tx_cnt; queue++)
139 + stmmac_reset_tx_queue(priv, queue);