Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2086418pxb; Sat, 14 Nov 2020 12:48:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkS6dpEKqRqJa4h6MXGeo7cZ9BXUcJAiAGTz6A/2OCzGCUNVaWTLSWa3IGQiGTqd2hezYR X-Received: by 2002:a17:906:e2c3:: with SMTP id gr3mr7773667ejb.471.1605386884603; Sat, 14 Nov 2020 12:48:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605386884; cv=none; d=google.com; s=arc-20160816; b=CWerlaZZDQWyHi0WSOjG42v+Yw0kfRaDEH/v+UIvH9+zPfr/FxyXVfxcEldV7zGrX9 G2MV2Inghkpzd418tfXmgAVxqImZ6Pf8Zrxywel26sY2fSvBEL2i1hGJsBj40DkXK2t6 0yB41kGHvcyIQYnak4Btf8zsXdY1TFnDc8HU5cdBcc4YeOJQ6PN0cII+rIh1IhFFRWMY l1gYSx9eoQMlJnY8EupP3JiOgOCwvjZGCti1SW8RoUESS+NwgehqwpV+ikypLan8Sl/o FBk9wdJar3ONJvoibK5ZmolS2EGGar7WAIJWhHG+b+2EkcMflAS2aIdkwc7hQ4A5A6aI XLMQ== 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:subject:cc:to:from:date :dkim-signature; bh=Owt2ssJorE8Gj0z5tRzFpu4HmiQDjWSteACy2MDGBzw=; b=Zp4Jv2Ebqrcjt6kHqgCvpCXG4UZkyaudy1DcGCozV+57lIEz9sVzRbX+yWDpHBzw4J PXc3A4XUqhpw/I6zPav/9qw9JhL+JSJtfcabewh5iqbrKrcExyGtmyCXSj6JfX6HYHKt ovZDgP7oEq9AeOcu7ySj8i/Hvj+5WLCB7Z33R+QwX9dQN2LQM36zxvN0HLmexnRqwPaR 9e7M2T8RthkTYe9ShV58UxghLnyV9g4pfYNnA1+vJqZej6iuuExFDShTz7NsuaFMSyVM E3TwJyzOwuMvt6EvR5UzQvgFqnfVN8GjX7NdmxK7qIK62+z5Tw3HG6t9KSAFCeDfC86Y Kl5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ckAxn0Pt; 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 m20si8415315eje.363.2020.11.14.12.47.42; Sat, 14 Nov 2020 12:48:04 -0800 (PST) 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=ckAxn0Pt; 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 S1726278AbgKNUpJ (ORCPT + 99 others); Sat, 14 Nov 2020 15:45:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:34478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbgKNUpI (ORCPT ); Sat, 14 Nov 2020 15:45:08 -0500 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (c-67-180-217-166.hsd1.ca.comcast.net [67.180.217.166]) (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 8E31922245; Sat, 14 Nov 2020 20:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605386708; bh=55zxoyo1mw5dFVi7p+0C1p3Xc0RC5j9O+Cjwpd28/ws=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ckAxn0Pt2y0h2Lt0+FbrNqdH6Du3v4N1NoglM7MmQ3sJfy5ol4xd2jl2BHcP8sA4w xYvXpui1Y4e6m6f5ofe+Dqwv9Kgy1Tb0f4wmI1lnsfE4lt8DfSAGR8lMRK8FR0h7Ul fLU/rFawQBFiJRPnQ7K/QDpubI/U2bqdjnqt8ot8= Date: Sat, 14 Nov 2020 12:45:06 -0800 From: Jakub Kicinski To: Wong Vee Khee Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ong Boon Leong , Voon Wei Feng , Christophe ROULLIER Subject: Re: [PATCH net 1/1] net: stmmac: Use rtnl_lock/unlock on netif_set_real_num_rx_queues() call Message-ID: <20201114124506.13847db4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20201112144948.3042-1-vee.khee.wong@intel.com> References: <20201112144948.3042-1-vee.khee.wong@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Nov 2020 22:49:48 +0800 Wong Vee Khee wrote: > Fix an issue where dump stack is printed on suspend resume flow due to > netif_set_real_num_rx_queues() is not called with rtnl_lock held(). > > Fixes: 686cff3d7022 ("net: stmmac: Fix incorrect location to set real_num_rx|tx_queues") > Reported-by: Christophe ROULLIER > Tested-by: Christophe ROULLIER > Cc: Alexandre TORGUE > Reviewed-by: Ong Boon Leong > Signed-off-by: Wong Vee Khee > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index ba855465a2db..33e280040000 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -5278,7 +5278,10 @@ int stmmac_resume(struct device *dev) > > stmmac_clear_descriptors(priv); > > + rtnl_lock(); > stmmac_hw_setup(ndev, false); > + rtnl_unlock(); > + > stmmac_init_coalesce(priv); > stmmac_set_rx_mode(ndev); > Doesn't look quite right. This is under the priv->lock which is sometimes taken under rtnl_lock. So theoretically there could be a deadlock. You should probably take rtnl_lock() before priv->lock and release it after. It's pretty common for drivers to hold rtnl_lock around most of the resume method. With larger context: mutex_lock(&priv->lock); stmmac_reset_queues_param(priv); stmmac_clear_descriptors(priv); + rtnl_lock(); stmmac_hw_setup(ndev, false); + rtnl_unlock(); + stmmac_init_coalesce(priv); stmmac_set_rx_mode(ndev); stmmac_restore_hw_vlan_rx_fltr(priv, ndev, priv->hw); stmmac_enable_all_queues(priv); mutex_unlock(&priv->lock);