Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10408242ybi; Wed, 24 Jul 2019 22:40:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDdosIE1JYHpXNz9kzyilpbYew8ES0PMX10+bgoOBRLl3rYjui1aCMoWd0TVEkIHVH3bDw X-Received: by 2002:a63:d34c:: with SMTP id u12mr69952592pgi.114.1564033253248; Wed, 24 Jul 2019 22:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033253; cv=none; d=google.com; s=arc-20160816; b=zcMcLXbwU2aru3aJDgxEuJbCMcdzFDm1TQigVNmpSSA5Q0NWWzOJk7yUR9nodAzPkc uQH15DzOqNn17f1M2HoibUUcY2Voc9bRQNu5isRdGE5ubwZOY57KTGRZXJP7wV0O+1Xz zeTwDG0fadVXwJMWu1TsoJeeKVdsXewHWh12MOWumkDK0S4K+UcB9KCgBjwfe6no+oJx WuA9q32SllGb9Tx8Fhj1ZF8gQZ80koU+ptBvIvA9VB2+oCFO4tiZ4MIxbYZBsT4TWgXq 6JfOZ6L+gJfv2hBIhQfWvD1QeyAT1O74qKmUFbGiT0gFwPlMwPfJcnyNmgp5LwbuwBFP x42w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8afgQ3D6vQUkxLwyj0AdAob5SvSdrFjTLqVs/ou0Gvk=; b=oZV/LiPz7Jy4kbGXwl9cQme1EFAOJGuMeM/qy+dPgRAngfQ6e6+/H0cktEszbqtYB/ bjFpauXzWyUiUKefClYTHZ8lmSHHWusgSRxNG/vLoiSRo/pw4HP4sX+cTiJ7vPXL/oJh wJXUe2Y5nWC3n8LzgPVv4TgLusmi4uRE3l7silYK8nHdJpTerWMzTVENJoN6k+qC0/Ks DkzF3ph0xJ39RO59XnSDsWZo1QFoQ1URxJ63hgv60LwyAnvoc3DGQ7Sx2pvpfgtccNm0 5yHhtxrSWjlcccklsFIIHDzmnJRzFwTjx4X5JCzQh1ZFN+m5rApOruPariXwJ6R8F6YI AY5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c4uTQzVe; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si18789692pjp.61.2019.07.24.22.40.39; Wed, 24 Jul 2019 22:40:53 -0700 (PDT) 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=@kernel.org header.s=default header.b=c4uTQzVe; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405695AbfGXUDS (ORCPT + 99 others); Wed, 24 Jul 2019 16:03:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:53600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405671AbfGXUDR (ORCPT ); Wed, 24 Jul 2019 16:03:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FB1E214AF; Wed, 24 Jul 2019 20:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998597; bh=RE4zTPUW2ZaNgOYRYaTLMudAji+H2gZtX2uIvn6tZ7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4uTQzVezFYCRg86q0b99G9oHZZn6B+YmYyRUVOqjNMb3ixoFXEIA6GSUJIOEYZBC YDlXYA3FBnFZ6PRTt/lYCwH0hUJLUmUdDvtXZGrRHfzxCmRXpzIboJZImOInEghhNk W6E8hXMpfQ8QVtiFiRPCXWzupuVJ5IjpTyuYeW7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 049/271] net: axienet: Fix race condition causing TX hang Date: Wed, 24 Jul 2019 21:18:38 +0200 Message-Id: <20190724191659.357714775@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 7de44285c1f69ccfbe8be1d6a16fcd956681fee6 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../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 7cfd7ff38e86..66b30ebd45ee 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -614,6 +614,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); } @@ -668,9 +672,19 @@ static int axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) 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) { -- 2.20.1