bmips: fix Tx cleanup when NAPI poll budget is zero
authorSieng-Piaw Liew <liew.s.piaw@gmail.com>
Fri, 8 Jul 2022 08:16:08 +0000 (16:16 +0800)
committerÁlvaro Fernández Rojas <noltari@gmail.com>
Sat, 4 Mar 2023 18:28:16 +0000 (19:28 +0100)
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@gmail.com>
[improve code format]
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c

index b3dc53c20f839d3fb2e5caf6059f9abc41d6879f..c655ae8d27753106298d0bae151c98444bbab337 100644 (file)
@@ -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++) {