netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jose Abreu <jose.abreu@synopsys.com>,
	Joao Pinto <jpinto@synopsys.com>,
	"David S . Miller" <davem@davemloft.net>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.20 057/105] net: stmmac: Prevent RX starvation in stmmac_napi_poll()
Date: Tue, 12 Feb 2019 21:32:48 -0500	[thread overview]
Message-ID: <20190213023336.19019-57-sashal@kernel.org> (raw)
In-Reply-To: <20190213023336.19019-1-sashal@kernel.org>

From: Jose Abreu <jose.abreu@synopsys.com>

[ Upstream commit fa0be0a43f101888ac677dba31b590963eafeaa1 ]

Currently, TX is given a budget which is consumed by stmmac_tx_clean()
and stmmac_rx() is given the remaining non-consumed budget.

This is wrong and in case we are sending a large number of packets this
can starve RX because remaining budget will be low.

Let's give always the same budget for RX and TX clean.

While at it, check if we missed any interrupts while we were in NAPI
callback by looking at DMA interrupt status.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 27 ++++++++++---------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fe9240e15aea..5d83d6a7694b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3525,27 +3525,28 @@ static int stmmac_napi_poll(struct napi_struct *napi, int budget)
 	struct stmmac_channel *ch =
 		container_of(napi, struct stmmac_channel, napi);
 	struct stmmac_priv *priv = ch->priv_data;
-	int work_done = 0, work_rem = budget;
+	int work_done, rx_done = 0, tx_done = 0;
 	u32 chan = ch->index;
 
 	priv->xstats.napi_poll++;
 
-	if (ch->has_tx) {
-		int done = stmmac_tx_clean(priv, work_rem, chan);
+	if (ch->has_tx)
+		tx_done = stmmac_tx_clean(priv, budget, chan);
+	if (ch->has_rx)
+		rx_done = stmmac_rx(priv, budget, chan);
 
-		work_done += done;
-		work_rem -= done;
-	}
-
-	if (ch->has_rx) {
-		int done = stmmac_rx(priv, work_rem, chan);
+	work_done = max(rx_done, tx_done);
+	work_done = min(work_done, budget);
 
-		work_done += done;
-		work_rem -= done;
-	}
+	if (work_done < budget && napi_complete_done(napi, work_done)) {
+		int stat;
 
-	if (work_done < budget && napi_complete_done(napi, work_done))
 		stmmac_enable_dma_irq(priv, priv->ioaddr, chan);
+		stat = stmmac_dma_interrupt_status(priv, priv->ioaddr,
+						   &priv->xstats, chan);
+		if (stat && napi_reschedule(napi))
+			stmmac_disable_dma_irq(priv, priv->ioaddr, chan);
+	}
 
 	return work_done;
 }
-- 
2.19.1


  parent reply	other threads:[~2019-02-13  2:35 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190213023336.19019-1-sashal@kernel.org>
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 022/105] soc/fsl/qe: fix err handling of ucc_of_parse_tdm Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 032/105] net/mlx4: Get rid of page operation after dma_alloc_coherent Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 034/105] xprtrdma: Double free in rpcrdma_sendctxs_create() Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 035/105] mlxsw: spectrum_acl: Add cleanup after C-TCAM update error condition Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 036/105] mlxsw: spectrum: Add VXLAN dependency for spectrum Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 037/105] selftests: forwarding: Add a test for VLAN deletion Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 038/105] netfilter: nf_tables: fix leaking object reference count Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 043/105] netfilter: nft_flow_offload: Fix reverse route lookup Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 044/105] bpf: correctly set initial window on active Fast Open sender Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 046/105] selftests: bpf: install files tcp_(server|client)*.py Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 047/105] bpf: fix panic in stack_map_get_build_id() on i386 and arm32 Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 049/105] netfilter: nft_flow_offload: fix interaction with vrf slave device Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 053/105] net: stmmac: Fix PCI module removal leak Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 054/105] net: stmmac: dwxgmac2: Only clear interrupts that are active Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 055/105] net: stmmac: Check if CBS is supported before configuring Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 056/105] net: stmmac: Fix the logic of checking if RX Watchdog must be enabled Sasha Levin
2019-02-13  2:32 ` Sasha Levin [this message]
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 058/105] isdn: i4l: isdn_tty: Fix some concurrency double-free bugs Sasha Levin
2019-02-13  2:32 ` [PATCH AUTOSEL 4.20 065/105] netfilter: nft_flow_offload: fix checking method of conntrack helper Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 070/105] vhost: return EINVAL if iovecs size does not match the message size Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 071/105] vhost/scsi: Use copy_to_iter() to send control queue response Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 072/105] xsk: Check if a queue exists during umem setup Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 073/105] selftests/bpf: install with_tunnels.sh for test_flow_dissector.sh Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 074/105] samples/bpf: workaround clang asm goto compilation errors Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 075/105] SUNRPC: Ensure rq_bytes_sent is reset before request transmission Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 076/105] SUNRPC: Ensure we respect the RPCSEC_GSS sequence number limit Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 080/105] net: phy: micrel: set soft_reset callback to genphy_soft_reset for KSZ9031 Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 089/105] bpf: don't assume build-id length is always 20 bytes Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 090/105] bpf: zero out build_id for BPF_STACK_BUILD_ID_IP Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 091/105] selftests/bpf: retry tests that expect build-id Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 092/105] atm: he: fix sign-extension overflow on large shift Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 095/105] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 096/105] bpf: fix SO_MAX_PACING_RATE to support TCP internal pacing Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 097/105] dpaa_eth: NETIF_F_LLTX requires to do our own update of trans_start Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 098/105] mlxsw: pci: Return error on PCI reset timeout Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 099/105] net: bridge: Mark FDB entries that were added by user as such Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 100/105] mlxsw: spectrum_switchdev: Do not treat static FDB entries as sticky Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 101/105] selftests: forwarding: Add a test case for externally learned FDB entries Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 103/105] net/mlx5e: Force CHECKSUM_UNNECESSARY for short ethernet frames Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 104/105] net/mlx5e: Fix wrong (zero) TX drop counter indication for representor Sasha Levin
2019-02-13  2:33 ` [PATCH AUTOSEL 4.20 105/105] isdn: avm: Fix string plus integer warning from Clang Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213023336.19019-57-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=joabreu@synopsys.com \
    --cc=jose.abreu@synopsys.com \
    --cc=jpinto@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).