[openwrt/openwrt] bmips: fix Tx cleanup when NAPI poll budget is zero

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 4 10:30:01 PST 2023


noltari pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/a6a54135ef7dca13a3f042afe83a99ce0218622c

commit a6a54135ef7dca13a3f042afe83a99ce0218622c
Author: Sieng-Piaw Liew <liew.s.piaw at gmail.com>
AuthorDate: Fri Jul 8 16:16:08 2022 +0800

    bmips: fix Tx cleanup when NAPI poll budget is zero
    
    NAPI poll() function may be passed a budget value of zero, i.e. during
    netpoll, which isn't NAPI context.
    Therefore, napi_consume_skb() must be given budget value instead of
    !force to truly discern netpoll-like scenarios.
    
    https://lore.kernel.org/netdev/20220707141056.2644-1-liew.s.piaw@gmail.com/t/#m470f5c20225e76fb08c44d6cfa2f1b739ffaaea4
    Signed-off-by: Sieng-Piaw Liew <liew.s.piaw at gmail.com>
    [improve code format]
    Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 .../bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
index b3dc53c20f..c655ae8d27 100644
--- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
+++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
@@ -442,7 +442,8 @@ static int bcm6368_enetsw_receive_queue(struct net_device *dev, int budget)
 /*
  * try to or force reclaim of transmitted buffers
  */
-static int bcm6368_enetsw_tx_reclaim(struct net_device *dev, int force)
+static int bcm6368_enetsw_tx_reclaim(struct net_device *dev, int force,
+				     int budget)
 {
 	struct bcm6368_enetsw *priv = netdev_priv(dev);
 	unsigned int bytes = 0;
@@ -483,7 +484,7 @@ static int bcm6368_enetsw_tx_reclaim(struct net_device *dev, int force)
 			dev->stats.tx_errors++;
 
 		bytes += skb->len;
-		napi_consume_skb(skb, !force);
+		napi_consume_skb(skb, budget);
 		released++;
 	}
 
@@ -511,7 +512,7 @@ static int bcm6368_enetsw_poll(struct napi_struct *napi, int budget)
 			 DMAC_IR_REG, priv->tx_chan);
 
 	/* reclaim sent skb */
-	bcm6368_enetsw_tx_reclaim(dev, 0);
+	bcm6368_enetsw_tx_reclaim(dev, 0, budget);
 
 	spin_lock(&priv->rx_lock);
 	rx_work_done = bcm6368_enetsw_receive_queue(dev, budget);
@@ -855,7 +856,7 @@ static int bcm6368_enetsw_stop(struct net_device *dev)
 	bcm6368_enetsw_disable_dma(priv, priv->rx_chan);
 
 	/* force reclaim of all tx buffers */
-	bcm6368_enetsw_tx_reclaim(dev, 1);
+	bcm6368_enetsw_tx_reclaim(dev, 1, 0);
 
 	/* free the rx buffer ring */
 	for (i = 0; i < priv->rx_ring_size; i++) {




More information about the lede-commits mailing list