From: Sieng-Piaw Liew Date: Fri, 8 Jul 2022 08:16:08 +0000 (+0800) Subject: bmips: fix Tx cleanup when NAPI poll budget is zero X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a6a54135ef7dca13a3f042afe83a99ce0218622c;p=openwrt%2Fstaging%2F981213.git 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 [improve code format] Signed-off-by: Álvaro Fernández Rojas --- 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++) {