From patchwork Wed Feb 19 10:53:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esben Haabendal X-Patchwork-Id: 11391241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8553A109A for ; Wed, 19 Feb 2020 10:53:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6386724670 for ; Wed, 19 Feb 2020 10:53:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Wt8dfjso"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="QDWUVQDT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6386724670 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=geanix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qBggKz3ko5zQge2uR8ZKFWVtVewOu+MUX0DAG5oOjF0=; b=Wt8dfjsoUgQvRy 0vi9ZhKh5QqlW4MfNXMVClC/Qy5ZE2K/xb/woNTfkUz+xnqgvH+mTw/sHMbMZMXNSALgjD6KbQuNr A+gNhRSLKt2OD2hriljKMCYjmKLDJAeInDzrFgiMv8lcY7Ovrb6fCkVD7tB5p9zWaPf15JgHUJsP3 qdyuyVSSJUUdn10lrXnZe/v7FgJ0IFwcJ/YLFcxs7a7UiECjeZD9yD6mLNRp/4OtVRN6csXYSr+kl MkBtwfT5htIMKinOUOGiFI2JZa4NuDiGT1hhkDB5741cg9Po0muP7q/0xJnnPm/9lCuqhZoxDU7Ag h+hp5LTKbZrjJLUbjQrg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4MzK-0002yG-L6; Wed, 19 Feb 2020 10:53:54 +0000 Received: from first.geanix.com ([116.203.34.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4MzH-0002vE-8c for linux-arm-kernel@lists.infradead.org; Wed, 19 Feb 2020 10:53:52 +0000 Received: from localhost (_gateway [172.20.0.1]) by first.geanix.com (Postfix) with ESMTPSA id 1C78BC002E; Wed, 19 Feb 2020 10:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1582109629; bh=KvmUZ7RpfqddUx8uLthfjCMTy9g+ZYpZDHIMYzR1KoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QDWUVQDTAquUov6+PXtSzsOfsH4R3+bYJ3ZFFOC28FYbLNwgyFlsz7nSieXIiZObI 6RS5Cq28tPzIwWfbHZgOkd/XyTSlCRafR7TkPqfGeqwDLdmzmY3nyS3CqkX3Q9PJhU 41iR4DuU8ZKbDxt5N1tCKXPCncY6kOy4RZGxwdCWezT2xTMbB9JFcf58WjgZZVSiu0 PhJW2zacPec6lzoZSjXu+5GzHFR4kDgIjvxC8bUA1n3K5gZSROG0Ay/8sJ1WvKJn2u kFX78mjFRB31JsHAvVbmiSBDVwE5dJFSitJCWTyiKjyr3uggxs94cQnuO3kc8Bb+E4 oHuj6tj7RiLWw== From: Esben Haabendal To: netdev@vger.kernel.org Subject: [PATCH net 1/4] net: ll_temac: Fix race condition causing TX hang Date: Wed, 19 Feb 2020 11:53:48 +0100 Message-Id: X-Mailer: git-send-email 2.25.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=4.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=disabled version=3.4.3 X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on eb9da72b0f73 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_025351_461137_C99EAF48 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Michal Simek , linux-kernel@vger.kernel.org, =?utf-8?q?Petr_=C5=A0tetiar?= , "David S . Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;