Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp420970pxk; Fri, 11 Sep 2020 10:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9hGHG9admSVMl8Wbs9uV0O4kg/bbb/ptEflPmEtFvCboX9wZVDstQiGN7knAHc64/BD9i X-Received: by 2002:a50:8306:: with SMTP id 6mr3162090edh.340.1599845028515; Fri, 11 Sep 2020 10:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845028; cv=none; d=google.com; s=arc-20160816; b=m3xmgn3oF4y2Uiw+gvZDLN0Fd2lEzyVp+pyUuEEEm1PnCFCJV2ju1kXbN1PCmuf9Kl ofgYNKYCptkZi+L3l0csZlI/xwXubgKWdVXyRlxXOdy7cTo9KU97Yse5pCEx+GW1g2YZ yygl1Wn9SQaMcGcd60UB5ViHajsGcSVE0xp+OnhxXKJAsbj2iSzw0QlwzlwnYFKVv/jQ ukSYE+doDjPv5LGTtyrYPcAYJ8LphhA6aZ6jdwqj56d8JlfD6g1o7IZI5ejGWNTueIHK KiRkRFk54iTMSwWsQUPpUz3lfKQALcyqIXHZvBu/T4FMUv5MOZmsHIen18N2ElTScEn7 vI7A== 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=G/ccx6j0GEcGD/zW6GfsZw1+2cNTIDZpkmwjkS05o3Y=; b=z0fnOECPE9p4ILEeMiRyYnrVCLWxB3pR3Ni8i3UXJiqKKwzMh+l7UUnItY9rZPGic6 ryhOTyRZxi4fcvQUJ1eeDm9k+2rnDgajmorqPV+zPf62kciGF7lagCGgN3D3pCDk/web mJtWpx+7lCf633BdpAFDEkYY5GkzBpNUOc8sZlYNNwD7xWgDPPpHKHAIlIl95P9YK6r2 2KIsozLE5tnf0qLGSVFkMKcWEKQbFAgDlN6b6Zb4j3kedPIxrMeqCgiMmliO7IxpQsG0 YgUyga6E45008lzqDMWHw2qfJrQgvriF2OdYEoKyShxMUhpapxyMIsiCMHQa9uOwII5u meOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H9QrJ80L; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv15si1880871ejb.364.2020.09.11.10.23.25; Fri, 11 Sep 2020 10:23:48 -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=H9QrJ80L; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726287AbgIKRWI (ORCPT + 99 others); Fri, 11 Sep 2020 13:22:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbgIKNAL (ORCPT ); Fri, 11 Sep 2020 09:00:11 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CB8F12222C; Fri, 11 Sep 2020 12:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828997; bh=NAev7a/D8le1whi8aOSyiSWgBBR73NF3D/Nanw3oZ0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H9QrJ80LJe/v8A/kIv5oLfrrjc8wc+Sg7W8OzI4u1kAV8Gm+vpSY4PL3fxFcGZkoM hLyj3h3weXjpL/eSvKkR3DcDPgTNWtt4rdY924GEZwDewlKwsy/62oPxHFb+moGmrd rlwfgq5m5vwlpc+APlYQGzBrYuHSEb7Z31ptcFaI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Christensen , Baptiste Covolato , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 25/71] tg3: Fix soft lockup when tg3_reset_task() fails. Date: Fri, 11 Sep 2020 14:46:09 +0200 Message-Id: <20200911122506.193965152@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@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 From: Michael Chan [ Upstream commit 556699341efa98243e08e34401b3f601da91f5a3 ] If tg3_reset_task() fails, the device state is left in an inconsistent state with IFF_RUNNING still set but NAPI state not enabled. A subsequent operation, such as ifdown or AER error can cause it to soft lock up when it tries to disable NAPI state. Fix it by bringing down the device to !IFF_RUNNING state when tg3_reset_task() fails. tg3_reset_task() running from workqueue will now call tg3_close() when the reset fails. We need to modify tg3_reset_task_cancel() slightly to avoid tg3_close() calling cancel_work_sync() to cancel tg3_reset_task(). Otherwise cancel_work_sync() will wait forever for tg3_reset_task() to finish. Reported-by: David Christensen Reported-by: Baptiste Covolato Fixes: db2199737990 ("tg3: Schedule at most one tg3_reset_task run") Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/tg3.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 5790b35064a8d..2db6102ed5848 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7201,8 +7201,8 @@ static inline void tg3_reset_task_schedule(struct tg3 *tp) static inline void tg3_reset_task_cancel(struct tg3 *tp) { - cancel_work_sync(&tp->reset_task); - tg3_flag_clear(tp, RESET_TASK_PENDING); + if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags)) + cancel_work_sync(&tp->reset_task); tg3_flag_clear(tp, TX_RECOVERY_PENDING); } @@ -11174,18 +11174,27 @@ static void tg3_reset_task(struct work_struct *work) tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); err = tg3_init_hw(tp, true); - if (err) + if (err) { + tg3_full_unlock(tp); + tp->irq_sync = 0; + tg3_napi_enable(tp); + /* Clear this flag so that tg3_reset_task_cancel() will not + * call cancel_work_sync() and wait forever. + */ + tg3_flag_clear(tp, RESET_TASK_PENDING); + dev_close(tp->dev); goto out; + } tg3_netif_start(tp); -out: tg3_full_unlock(tp); if (!err) tg3_phy_start(tp); tg3_flag_clear(tp, RESET_TASK_PENDING); +out: rtnl_unlock(); } -- 2.25.1