All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancock@sedsystems.ca>
To: netdev@vger.kernel.org
Cc: anirudh@xilinx.com, John.Linn@xilinx.com,
	Robert Hancock <hancock@sedsystems.ca>
Subject: [PATCH net-next 13/18] net: axienet: Fix race condition causing TX hang
Date: Mon,  3 Jun 2019 15:57:12 -0600	[thread overview]
Message-ID: <1559599037-8514-14-git-send-email-hancock@sedsystems.ca> (raw)
In-Reply-To: <1559599037-8514-1-git-send-email-hancock@sedsystems.ca>

It is possible that the interrupt handler fires and frees up space in
the TX ring in between checking for sufficient TX ring space and
stopping the TX queue in axienet_start_xmit. If this happens, the
queue wake from the interrupt handler will occur before the queue is
stopped, causing a lost wakeup and the adapter's transmit hanging.

To avoid this, after stopping the queue, check again whether there is
sufficient space in the TX ring. If so, wake up the queue again.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index e26b339..398e7e6 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -621,6 +621,10 @@ static void axienet_start_xmit_done(struct net_device *ndev)
 
 	ndev->stats.tx_packets += packets;
 	ndev->stats.tx_bytes += size;
+
+	/* Matches barrier in axienet_start_xmit */
+	smp_mb();
+
 	netif_wake_queue(ndev);
 }
 
@@ -676,9 +680,19 @@ static inline int axienet_check_tx_bd_space(struct axienet_local *lp,
 	cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
 
 	if (axienet_check_tx_bd_space(lp, num_frag)) {
-		if (!netif_queue_stopped(ndev))
-			netif_stop_queue(ndev);
-		return NETDEV_TX_BUSY;
+		if (netif_queue_stopped(ndev))
+			return NETDEV_TX_BUSY;
+
+		netif_stop_queue(ndev);
+
+		/* Matches barrier in axienet_start_xmit_done */
+		smp_mb();
+
+		/* Space might have just been freed - check again */
+		if (axienet_check_tx_bd_space(lp, num_frag))
+			return NETDEV_TX_BUSY;
+
+		netif_wake_queue(ndev);
 	}
 
 	if (skb->ip_summed == CHECKSUM_PARTIAL) {
-- 
1.8.3.1


  parent reply	other threads:[~2019-06-03 21:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 21:56 [PATCH net-next 00/18] Xilinx axienet driver updates (v2) Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 01/18] net: axienet: Fix casting of pointers to u32 Robert Hancock
2019-06-04  2:05   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 02/18] net: axienet: Use standard IO accessors Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 03/18] net: axienet: fix MDIO bus naming Robert Hancock
2019-06-04  2:25   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 04/18] net: axienet: add X86 and ARM as supported platforms Robert Hancock
2019-06-04  2:26   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 05/18] net: axienet: Allow explicitly setting MDIO clock divisor Robert Hancock
2019-06-04  2:33   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 06/18] net: axienet: fix teardown order of MDIO bus Robert Hancock
2019-06-04  2:34   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 07/18] net: axienet: Re-initialize MDIO registers properly after reset Robert Hancock
2019-06-04  2:43   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 08/18] net: axienet: Cleanup DMA device reset and halt process Robert Hancock
2019-06-04  2:45   ` Andrew Lunn
2019-06-03 21:57 ` [PATCH net-next 09/18] net: axienet: Make RX/TX ring sizes configurable Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 10/18] net: axienet: Add DMA registers to ethtool register dump Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 11/18] net: axienet: Support shared interrupts Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 12/18] net: axienet: Add optional support for Ethernet core interrupt Robert Hancock
2019-06-03 21:57 ` Robert Hancock [this message]
2019-06-03 21:57 ` [PATCH net-next 14/18] net: axienet: Make missing MAC address non-fatal Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 15/18] net: axienet: stop interface during shutdown Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 16/18] net: axienet: document axistream-connected attribute Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 17/18] net: axienet: make use of axistream-connected attribute optional Robert Hancock
2019-06-03 21:57 ` [PATCH net-next 18/18] net: axienet: convert to phylink API Robert Hancock

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=1559599037-8514-14-git-send-email-hancock@sedsystems.ca \
    --to=hancock@sedsystems.ca \
    --cc=John.Linn@xilinx.com \
    --cc=anirudh@xilinx.com \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.