Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp875051pxk; Thu, 17 Sep 2020 20:00:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIWx6AEf1HExU1oV+TRjmKn/0aRo7QuB6QSm9s+gYmRdtL+W2ZxpjqI5TUvyuts2lx4NhH X-Received: by 2002:a17:906:5452:: with SMTP id d18mr34969024ejp.163.1600398030388; Thu, 17 Sep 2020 20:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398030; cv=none; d=google.com; s=arc-20160816; b=YbRw5ukAYXu2bLborqNEl0mk339fb9jV87n7LWr7HPIYZsjE/EkJbv16IJVaZqp/zU Rkd2qamziMQVvu4fJsj/r9HFPN3IHBOl5GdjnWasboSbphqU5clkaSY4/wzFNYjijxHB mQjJKRwHBKeIL47OFkJebBsxsNhkDO9e6ObOeK2gSNEYw0GyQuTNVjWjQXHwfkKRQvHF vAOnUyN63WZDHstfMRon0Hv8pg7msuiHgVScs0kTnVYyAKHgYzz6Yc7itmsOcF2iCtib 28BY9d3uec46o2F6taJf+oBQBE5Owe6me4GmaOzXWH4PLphVHIWBTL39JYg0rKm4mswm bCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7+uTkc2STA9poWOqFyTfx/3rBie6LetxAZEjnA9n0wc=; b=D2LAM3OJji7+yblYb/xpmh1+/zvNfz6lM8bCu1x9nB3JXMa+oEJWPOJkWjcTKkEqWW IQgW/KvONi2EHnSe1tg4h/FNnDkOPDZlycU5YrOQsiqU/a+E/0FdhoC1gABALMqz4azo zAaVsPZ6JliIms1KdgYN1uNFOjLgI40EHZHdWLIxeW4Alp19bHbBvhtzAAryPfLGH+oE Pmcfx6r+e/TEmrRMaipK76m7zUPhb0OVM5Gilrj0lSbD5N4D4zlX5KvYlLa9IwY4YQ2K aLRqVkKTQiKn+6Kb1NmNJAQMgIVtYTy7I0DiE+d9jkXZ+1IaBS15g0neRhtYuAdzMC3H u6HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HkT2FPL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si1165288edy.292.2020.09.17.20.00.07; Thu, 17 Sep 2020 20:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HkT2FPL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730080AbgIRC4Q (ORCPT + 99 others); Thu, 17 Sep 2020 22:56:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:57182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727841AbgIRCHH (ORCPT ); Thu, 17 Sep 2020 22:07:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABE1D23770; Fri, 18 Sep 2020 02:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394813; bh=4RHDLPx1B2EiQrAj9Ccw67ednESdgfjPvKhBLY38m80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HkT2FPL/nK3v8sE/GuiV/dg+cbKwzLS2iVm+5bYQ1oM3MsgwTmc0s47oZ0COJdXz0 Rpj4YFClU7YlqE7+mRwDudUVHWJkcGtnv3oRFFf9EHPgSSkS4fZBDbxoihmEx0BiJw T/2sIG0XO+eUBqE+y8SJTJYIaVH5qcGeoVJUeYo4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Duyck , Maxim Zhukov , Jeff Kirsher , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 280/330] e1000: Do not perform reset in reset_task if we are already down Date: Thu, 17 Sep 2020 22:00:20 -0400 Message-Id: <20200918020110.2063155-280-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck [ Upstream commit 49ee3c2ab5234757bfb56a0b3a3cb422f427e3a3 ] We are seeing a deadlock in e1000 down when NAPI is being disabled. Looking over the kernel function trace of the system it appears that the interface is being closed and then a reset is hitting which deadlocks the interface as the NAPI interface is already disabled. To prevent this from happening I am disabling the reset task when __E1000_DOWN is already set. In addition code has been added so that we set the __E1000_DOWN while holding the __E1000_RESET flag in e1000_close in order to guarantee that the reset task will not run after we have started the close call. Signed-off-by: Alexander Duyck Tested-by: Maxim Zhukov Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/e1000/e1000_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index f93ed70709c65..a2ee28e487a6f 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -542,8 +542,13 @@ void e1000_reinit_locked(struct e1000_adapter *adapter) WARN_ON(in_interrupt()); while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) msleep(1); - e1000_down(adapter); - e1000_up(adapter); + + /* only run the task if not already down */ + if (!test_bit(__E1000_DOWN, &adapter->flags)) { + e1000_down(adapter); + e1000_up(adapter); + } + clear_bit(__E1000_RESETTING, &adapter->flags); } @@ -1433,10 +1438,15 @@ int e1000_close(struct net_device *netdev) struct e1000_hw *hw = &adapter->hw; int count = E1000_CHECK_RESET_COUNT; - while (test_bit(__E1000_RESETTING, &adapter->flags) && count--) + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags) && count--) usleep_range(10000, 20000); - WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); + WARN_ON(count < 0); + + /* signal that we're down so that the reset task will no longer run */ + set_bit(__E1000_DOWN, &adapter->flags); + clear_bit(__E1000_RESETTING, &adapter->flags); + e1000_down(adapter); e1000_power_down_phy(adapter); e1000_free_irq(adapter); -- 2.25.1