Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2418845imu; Wed, 21 Nov 2018 11:18:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/UFf9abZfkHvbdRhlkEPOLpKVgpdVdgJFXWJ0DdfCq+XxewRfQP+7niKDXSBwVYvvA5ho9+ X-Received: by 2002:a63:2ac9:: with SMTP id q192mr7136637pgq.58.1542827920485; Wed, 21 Nov 2018 11:18:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542827920; cv=none; d=google.com; s=arc-20160816; b=r0fyybJwRsSSp/T2J+SUt9raGzC+uF5aHVy1uhb1jYTWcl4hEU8zNCrYnHq9YIrH82 iCTJxbspk64dNLtuAvDEa7L/iPE63PZCtakwBSINK9ZcTS/gi6YBKhPY6I7FZPa28qbB U/9wzBntSTcPJvLpfOi4Srjf6Ix9eUsRHZ8Eaifgbv3+cX+2g2YuGbonXhYyClOdNPPm UjVuLio/W3esc/i39vC1KbcncWZeE2Tlo7KkdtzjeEg2+HLeBCJVk5VJR+WG+a5eln0Z HJiY8qpaqQ8NQBAYwh6fz6JB7pAxrQPAiLxtiAYutnrllZbFsw8jM0cV3/DWLu45qTJZ tSRg== 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=k/dQh9hV6bpnOCGWNzb6y2rBfgHkknR/hgOvdy0TLMo=; b=boAiGJq0XPck7nbE10qM3Ly4ge5Sz/tsBm6dxCz8KIkdQaC2cu0fMC8exreubUfTRU v/xQM9fcCiYR/tnbKOZhxshJ4Zqo8dL8BTYGyDFIe8RbuxHPeJGUhLNj2yZcsxnB6qVa NEMWf7/MIo4+WOJgJMSTHGeYHIjLwVbEq1YS6ZUx4lxqcSr0tmadEr72z1Cx9Sud9w1r ud9IIWW/jYZtDeZPW2s/H6exoCr3zpzJLeqpqXOQGd1w55oPNv2DRjYMTwlvq85ZzPNJ WRKtNXP/HRT5zqjXUJ3nnRZNYJvVD35RiDsrD15ava5QrCvy7ZWef90rUqNhu2KQNQJe wpVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zm7sJQ7L; 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 d23si31551135pll.161.2018.11.21.11.18.24; Wed, 21 Nov 2018 11:18:40 -0800 (PST) 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=Zm7sJQ7L; 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 S2388496AbeKVFpN (ORCPT + 99 others); Thu, 22 Nov 2018 00:45:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:39936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730870AbeKVFpM (ORCPT ); Thu, 22 Nov 2018 00:45:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 9C5B8206BB; Wed, 21 Nov 2018 19:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542827379; bh=JXykUnlM5vnLoc9wwEQR2R/imevof9sixaw0diVjwaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zm7sJQ7L9KL1xTVq5qqFRzsOa4gw8EEUVppbLW76DjeW4g572CKUX6lAAuLGffSNr f664BzKcQpwsU3G5y/zj/VZqXEpwQFrc02Vrp14MwxaYiAnPS1Sz6jn4OyYHbiLkfw nv8XKku95SQPZLN6643AGodhlwokv3LOksqBmNMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , "David S. Miller" Subject: [PATCH 4.14 09/21] net: systemport: Protect stop from timeout Date: Wed, 21 Nov 2018 20:06:53 +0100 Message-Id: <20181121183422.467454278@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121183422.103826775@linuxfoundation.org> References: <20181121183422.103826775@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Fainelli [ Upstream commit 7cb6a2a2c72c1ed8f42fb01f1a661281b568dead ] A timing hazard exists when the network interface is stopped that allows a watchdog timeout to be processed by a separate core in parallel. This creates the potential for the timeout handler to wake the queues while the driver is shutting down, or access registers after their clocks have been removed. The more common case is that the watchdog timeout will produce a warning message which doesn't lead to a crash. The chances of this are greatly increased by the fact that bcm_sysport_netif_stop stops the transmit queues which can easily precipitate a watchdog time- out because of stale trans_start data in the queues. This commit corrects the behavior by ensuring that the watchdog timeout is disabled before enterring bcm_sysport_netif_stop. There are currently only two users of the bcm_sysport_netif_stop function: close and suspend. The close case already handles the issue by exiting the RUNNING state before invoking the driver close service. The suspend case now performs the netif_device_detach to exit the PRESENT state before the call to bcm_sysport_netif_stop rather than after it. These behaviors prevent any future scheduling of the driver timeout service during the window. The netif_tx_stop_all_queues function in bcm_sysport_netif_stop is replaced with netif_tx_disable to ensure synchronization with any transmit or timeout threads that may already be executing on other cores. For symmetry, the netif_device_attach call upon resume is moved to after the call to bcm_sysport_netif_start. Since it wakes the transmit queues it is not necessary to invoke netif_tx_start_all_queues from bcm_sysport_netif_start so it is moved into the driver open service. Fixes: 40755a0fce17 ("net: systemport: add suspend and resume support") Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bcmsysport.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -1774,9 +1774,6 @@ static void bcm_sysport_netif_start(stru intrl2_1_mask_clear(priv, 0xffffffff); else intrl2_0_mask_clear(priv, INTRL2_0_TDMA_MBDONE_MASK); - - /* Last call before we start the real business */ - netif_tx_start_all_queues(dev); } static void rbuf_init(struct bcm_sysport_priv *priv) @@ -1922,6 +1919,8 @@ static int bcm_sysport_open(struct net_d bcm_sysport_netif_start(dev); + netif_tx_start_all_queues(dev); + return 0; out_clear_rx_int: @@ -1945,7 +1944,7 @@ static void bcm_sysport_netif_stop(struc struct bcm_sysport_priv *priv = netdev_priv(dev); /* stop all software from updating hardware */ - netif_tx_stop_all_queues(dev); + netif_tx_disable(dev); napi_disable(&priv->napi); phy_stop(dev->phydev); @@ -2267,12 +2266,12 @@ static int bcm_sysport_suspend(struct de if (!netif_running(dev)) return 0; + netif_device_detach(dev); + bcm_sysport_netif_stop(dev); phy_suspend(dev->phydev); - netif_device_detach(dev); - /* Disable UniMAC RX */ umac_enable_set(priv, CMD_RX_EN, 0); @@ -2356,8 +2355,6 @@ static int bcm_sysport_resume(struct dev goto out_free_rx_ring; } - netif_device_attach(dev); - /* RX pipe enable */ topctrl_writel(priv, 0, RX_FLUSH_CNTL); @@ -2402,6 +2399,8 @@ static int bcm_sysport_resume(struct dev bcm_sysport_netif_start(dev); + netif_device_attach(dev); + return 0; out_free_rx_ring: