>From 35a5e33f4edcc663511d615e61a1ea119dfc77ee Mon Sep 17 00:00:00 2001 Message-Id: <35a5e33f4edcc663511d615e61a1ea119dfc77ee.1536583587.git.joabreu@synopsys.com> From: Jose Abreu Date: Mon, 10 Sep 2018 14:46:09 +0200 Subject: [PATCH] fixup_coalesce Signed-off-by: Jose Abreu --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 39 +++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 97268769186e..7875e81966fb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1872,7 +1872,7 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int limit, u32 queue, priv->xstats.tx_clean++; entry = tx_q->dirty_tx; - while ((entry != tx_q->cur_tx) && (pkts_compl < limit)) { + while (entry != tx_q->cur_tx) { struct sk_buff *skb = tx_q->tx_skbuff[entry]; struct dma_desc *p; int status; @@ -2241,6 +2241,17 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) return ret; } +static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + + if (tx_q->tx_timer_active) + return; + + mod_timer(&tx_q->txtimer, STMMAC_COAL_TIMER(priv->tx_coal_timer)); + tx_q->tx_timer_active = true; +} + /** * stmmac_tx_timer - mitigation sw timer for tx. * @data: data pointer @@ -2250,10 +2261,10 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) static void stmmac_tx_timer(struct timer_list *t) { struct stmmac_tx_queue *tx_q = from_timer(tx_q, t, txtimer); + struct stmmac_priv *priv = tx_q->priv_data; - if (likely(napi_schedule_prep(&tx_q->napi))) - __napi_schedule(&tx_q->napi); - tx_q->tx_timer_active = 0; + stmmac_tx_clean(priv, ~0, tx_q->queue_index, NULL); + tx_q->tx_timer_active = false; } /** @@ -2852,6 +2863,9 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) /* Compute header lengths */ proto_hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); + /* Start coalesce timer earlier in case TX Queue is stopped */ + stmmac_tx_timer_arm(priv, queue); + /* Desc availability based on threshold should be enough safe */ if (unlikely(stmmac_tx_avail(priv, queue) < (((skb->len - proto_hdr_len) / TSO_MAX_BUFF_SIZE + 1)))) { @@ -3009,12 +3023,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); - if (priv->tx_coal_timer && !tx_q->tx_timer_active) { - tx_q->tx_timer_active = 1; - mod_timer(&tx_q->txtimer, - STMMAC_COAL_TIMER(priv->tx_coal_timer)); - } - return NETDEV_TX_OK; dma_map_err: @@ -3054,6 +3062,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) return stmmac_tso_xmit(skb, dev); } + /* Start coalesce timer earlier in case TX Queue is stopped */ + stmmac_tx_timer_arm(priv, queue); + if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) { if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) { netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, @@ -3221,12 +3232,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); - if (priv->tx_coal_timer && !tx_q->tx_timer_active) { - tx_q->tx_timer_active = 1; - mod_timer(&tx_q->txtimer, - STMMAC_COAL_TIMER(priv->tx_coal_timer)); - } - return NETDEV_TX_OK; dma_map_err: @@ -3575,7 +3580,7 @@ static int stmmac_tx_poll(struct napi_struct *napi, int budget) napi_reschedule(napi); } - return work_done; + return min(work_done, budget); } /** -- 2.7.4