Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1540557ybv; Thu, 20 Feb 2020 22:48:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwS5q2NZbXkSMWoNQl80f4ZHxy9VkVKbMNC8u0HACmkKF8PiM+2Js7/QFBI5nmCknp9nff6 X-Received: by 2002:aca:b808:: with SMTP id i8mr795380oif.66.1582267734167; Thu, 20 Feb 2020 22:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582267734; cv=none; d=google.com; s=arc-20160816; b=jFyKbw0CRDaO4U/9zWT3SFKtt/h3GJdmUeGKtNQfKwWlvwMy+39Z9aZq300+ii1doq 9zQRfmwn9CqJc7GjsJOfet9RdTB/HDrSp9RzMp1fRwNFNFnkCGZKFgSvnAnTRBjHUor9 BmVs8iplqSC6O8qHeXq+gOQbwAWGCJukbaCy8No8fN2uWIiU+7946L2MFxoXqzIKbFec tB8J1MMkD2tl19V7mV2I+leFykyUvT9967VQ3c+awQ8qPx2kcN+zezcetYFmC1j3wUST r7AujCt/GDz7OXbfRAXAUyqy93QYGLrSbMiv3/mPe5VGn+rVXvjnSvuWtJwzRSbsTGYW OjOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0dCeiDZ7O6qB0P2nBQLbFvFMpJEYBnAIAcU1wWnAEos=; b=tV7hX6FM0vLurKxyG/hSbvPjpXavMzG1L5GZ4P2zsgIhKWlaL6nZ/gHUC84Y3XNEGu s5qcFtMeccCRVtXkfy3DIImpOexzgzArdoQ9em/ybOBZa8pwdYTXbuL3SfBXnCtz1Ykh +sHoXP0DU02hhLNfEFqsRQduV3MckdHCO39oxfZz8f9+HGXNLwmfOGacMlVws6o6rzxy AyLRFeHYP4rsVA3/v3+NfCFHWzbrGb1tEgBw+eqVc9HfrSAfhndioRT6r7pC9azZiFfY vj5mJkILFwO2tlp4Gjp/1OhKR6CHZNEaXx8QcUTwx1ZO7lck9BY1qauVk4kv2wDR9DxF FA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b=Acn0rHEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si1012041otk.193.2020.02.20.22.48.41; Thu, 20 Feb 2020 22:48:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b=Acn0rHEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727495AbgBUGrZ (ORCPT + 99 others); Fri, 21 Feb 2020 01:47:25 -0500 Received: from first.geanix.com ([116.203.34.67]:55378 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbgBUGrZ (ORCPT ); Fri, 21 Feb 2020 01:47:25 -0500 Received: from localhost (87-49-45-242-mobile.dk.customer.tdc.net [87.49.45.242]) by first.geanix.com (Postfix) with ESMTPSA id 785C3AEB4D; Fri, 21 Feb 2020 06:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1582267642; bh=KvmUZ7RpfqddUx8uLthfjCMTy9g+ZYpZDHIMYzR1KoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Acn0rHEsAci/DYy2yplp8EcwQxmU0WxRKZiq5d4xvpYk9+E+Jk3Y667o2USRuVqJb Ksy6yHHV+Jy4J1BangMSPHMYI5BZcD2t3vMNFc/VDFuj09+xuuctbPbYpejEsLt8WC xgrGC+/4lq4Q93JSsNy5ztBfytW0CnjDsI8B6Eekt60Ikpv7hYEz73IoSPM2Cjt6gM pId7SarJoZiWdRjd5V7cL4gGq1aRMXK+yj8GWXIqpn0Rymc67CUSbyyw2JAXCnCjQc VCDEw8z6Q12Of+nCkYOJxEOv3z8EOWG73SsL0PVoK6aKPJM8NiE0dBSf0+2xq3vm4L uVQs2O0npbKow== From: Esben Haabendal To: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , "David S . Miller" , Michal Simek , =?UTF-8?q?Petr=20=C5=A0tetiar?= Subject: [PATCH net v2 1/4] net: ll_temac: Fix race condition causing TX hang Date: Fri, 21 Feb 2020 07:47:21 +0100 Message-Id: X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=4.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on 05ff821c8cf1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 temac_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. This is a port of the similar fix in axienet driver, commit 7de44285c1f6 ("net: axienet: Fix race condition causing TX hang"). Fixes: 23ecc4bde21f ("net: ll_temac: fix checksum offload logic") Signed-off-by: Esben Haabendal --- drivers/net/ethernet/xilinx/ll_temac_main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index 6f11f52c9a9e..996004ef8bd4 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -788,6 +788,9 @@ static void temac_start_xmit_done(struct net_device *ndev) stat = be32_to_cpu(cur_p->app0); } + /* Matches barrier in temac_start_xmit */ + smp_mb(); + netif_wake_queue(ndev); } @@ -830,9 +833,19 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; if (temac_check_tx_bd_space(lp, num_frag + 1)) { - 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 temac_start_xmit_done */ + smp_mb(); + + /* Space might have just been freed - check again */ + if (temac_check_tx_bd_space(lp, num_frag)) + return NETDEV_TX_BUSY; + + netif_wake_queue(ndev); } cur_p->app0 = 0; -- 2.25.0