From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jose Abreu Subject: Re: [net-next, v2, 1/2] net: stmmac: Rework coalesce timer and fix multi-queue races Date: Mon, 10 Sep 2018 17:21:19 +0100 Message-ID: <5d7c2397-8ca9-1f9c-c394-f73a12456384@synopsys.com> References: <2f7c89f1-3416-2327-8158-67c318c62214@baylibre.com> <9283e03e-5167-0d04-5ad9-59593a46fa8a@synopsys.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------059A216362CAD824D9975654" Cc: Jerome Brunet , Martin Blumenstingl , "David S. Miller" , Joao Pinto , "Giuseppe Cavallaro" , Alexandre Torgue To: Neil Armstrong , Jose Abreu , Return-path: Received: from smtprelay2.synopsys.com ([198.182.60.111]:52632 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbeIJVQR (ORCPT ); Mon, 10 Sep 2018 17:16:17 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: --------------059A216362CAD824D9975654 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 10-09-2018 16:49, Neil Armstrong wrote: > Hi Jose, > > On 10/09/2018 16:44, Jose Abreu wrote: >> On 10-09-2018 14:46, Neil Armstrong wrote: >>> hi Jose, >>> >>> On 10/09/2018 14:55, Jose Abreu wrote: >>>> On 10-09-2018 13:52, Jose Abreu wrote: >>>>> Can you please try attached follow-up patch ? >>>> Oh, please apply the whole series otherwise this will not apply >>>> cleanly. >>> Indeed, it helps! >>> >>> With the fixups, it fails later, around 15s instead of 3, in RX and TX. >> Thanks for testing Neil. What if we keep rearming the timer >> whilst there are pending packets ? Something like in the attach. >> (applies on top of previous one). > It fixes RX, but TX fails after ~13s. Ok :( Can you please try attached follow-up patch ? I'm so sorry about this back and forth and I appreciate all your help . Thanks and Best Regards, Jose Miguel Abreu > > Neil > >> Thanks and Best Regards, >> Jose Miguel Abreu >> --------------059A216362CAD824D9975654 Content-Type: text/x-patch; name="0001-fixup_coalesce_3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-fixup_coalesce_3.patch" >>From 4f2ba5fca6c8858cfe640f3d466fd01904c451e3 Mon Sep 17 00:00:00 2001 Message-Id: <4f2ba5fca6c8858cfe640f3d466fd01904c451e3.1536596296.git.joabreu@synopsys.com> From: Jose Abreu Date: Mon, 10 Sep 2018 18:18:10 +0200 Subject: [PATCH] fixup_coalesce_3 Signed-off-by: Jose Abreu --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++----------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 76a6196b3263..f6587ee372ab 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2245,11 +2245,7 @@ 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; } /** @@ -2264,10 +2260,7 @@ static void stmmac_tx_timer(struct timer_list *t) struct stmmac_priv *priv = tx_q->priv_data; bool more; - tx_q->tx_timer_active = false; stmmac_tx_clean(priv, ~0, tx_q->queue_index, &more); - if (more) - stmmac_tx_timer_arm(priv, tx_q->queue_index); } /** @@ -2866,9 +2859,6 @@ 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)))) { @@ -2975,6 +2965,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) stmmac_set_tx_ic(priv, desc); priv->xstats.tx_set_ic_bit++; tx_q->tx_count_frames = 0; + } else { + stmmac_tx_timer_arm(priv, queue); } skb_tx_timestamp(skb); @@ -3065,9 +3057,6 @@ 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, @@ -3186,6 +3175,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) stmmac_set_tx_ic(priv, desc); priv->xstats.tx_set_ic_bit++; tx_q->tx_count_frames = 0; + } else { + stmmac_tx_timer_arm(priv, queue); } skb_tx_timestamp(skb); @@ -3572,16 +3563,12 @@ static int stmmac_tx_poll(struct napi_struct *napi, int budget) struct stmmac_priv *priv = tx_q->priv_data; u32 chan = tx_q->queue_index; int work_done = 0; - bool more; priv->xstats.napi_poll++; - work_done = stmmac_tx_clean(priv, budget, chan, &more); - if (work_done < budget) { + work_done = stmmac_tx_clean(priv, budget, chan, NULL); + if (work_done < budget) napi_complete_done(napi, work_done); - if (more) - napi_reschedule(napi); - } return min(work_done, budget); } -- 2.7.4 --------------059A216362CAD824D9975654--