Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp429461pxk; Fri, 11 Sep 2020 10:37:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHbWYDF7BjtE9SPQ0IXOyb8iG5NukUW75n6ig5Upox5XOjsAXL474o9P4G5Uk2EvFlbhwI X-Received: by 2002:a17:906:5452:: with SMTP id d18mr3175017ejp.163.1599845865064; Fri, 11 Sep 2020 10:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845865; cv=none; d=google.com; s=arc-20160816; b=OLeUOXhoTwyBcw/bz3DPwmNr7D2a9RT1/XupIxZRiTysEkAAxQz9l+jmFgIy0UDZnE XMr1PWIddvy8HmOZJtYdJZQKs9pRA+SFAQiPVVB8z8a0Nf+6okUh4yPOMuQro3s5vJrH 755V+nZrYWItY1IDdeKsqrz2mzLsFCk2WPYFMqup3bodwd4W3gQM+BCNi9rQ+3dLo36E LErfVqlDHYLBnYgdF5dBbZZnEtPLBdMXP9iRrAz2jAA7au0DJ8+A15QWpzJ5qnmNt0Op /KUW8QBIT5yTW9WlN0rdIrk1CAeTv3xXkmLXSWCVeNfkehVIE6ebOi5T+83oi5vQAaIi VAtg== 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=ul4YtK+1OB030petOJyR/RCFBjEt9lTi98GygFuHE1I=; b=URzgX39CRD33Ql5/KSmm6xITe8SHh54lG5f/RgvLCTL4y9Dl7Aa8eL35fsFk0j8moV YILefbXDdBNQelHfaz6/Hxi8G2R4CDlgVJoAnTgURriZrSqKJrGtIi9LbXd/8wduE1uy MtkIbnAatioitovkwBENWqBad7KDJiEa3Sj/lEbPckmPjBJ4UQTYuNGUdUGKUodPMbEY 192sFdaZoisWiXYF2tSmyEyzQ9R8pyZ/ahr4emWX3wWPo79iUEm5FRRUEh1pXj9TdLfI 5TRPb07ivkj/skgO0bt5qJ7eSFPvfI05CuqCC83LaT4RWNWuQuV4MVJ2BC7XSmysVmUb 24xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RoTRw7rv; 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 h11si1787685edt.462.2020.09.11.10.37.22; Fri, 11 Sep 2020 10:37:45 -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=RoTRw7rv; 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 S1726531AbgIKReg (ORCPT + 99 others); Fri, 11 Sep 2020 13:34:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54:34 -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 9F9522220E; Fri, 11 Sep 2020 12:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828816; bh=Idp+qWzw4A7rf3pUCN+jGJqQy3TiLBI4wkg+aNJ5o6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RoTRw7rvxuI2sHOsk9mUUJr3VnI+/45h7WV4s6UjPbUp9rIXRp1iXF8NrnrbU5IYm hlSmPkIZ8tC5E9MkxCgrW+5F2bmC7jfvvmL5cZwGlm3Q3ba/ILJ5QvbkEbYJLBOBlg EhJnHW5Wf+0/I/fSYU6U4yiAII8HtoeCzUxPuZ0I= 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.4 18/62] tg3: Fix soft lockup when tg3_reset_task() fails. Date: Fri, 11 Sep 2020 14:46:01 +0200 Message-Id: <20200911122503.306946260@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@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 e198427d0f292..2ee2b6e858283 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7203,8 +7203,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); } @@ -11176,18 +11176,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