Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp201965pxk; Thu, 17 Sep 2020 00:08:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMhJ7BaGL0kP7He8n6qRIpO9XTsL/DfRIkrsMmwSXpvHOuXJGzoRoEM8HFCVMwnwpNV36S X-Received: by 2002:aa7:d8d8:: with SMTP id k24mr30847192eds.97.1600326530418; Thu, 17 Sep 2020 00:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600326530; cv=none; d=google.com; s=arc-20160816; b=wNx7nPrjdN0wOyH2hYPN7JbXDejHurX4y9l6P57kS5LYyuWwPTSdLv9saFvyViHjZo yOP0d8AJlgR5RF+mMVQx/9tI/cPMoTLdAhOvnKBYZsbrNW5cZGAbAJwhUKcE1LjPnvJB 2QphUASB/6FFypd2zg4sGuADeSc1aY7G8G9OpK0rBpDHi75jMDjfOl4Ud5XSPQjurRkg KQ+sjizXF+jTqzVz6uNujBAEoSkJ6prRCWG+0T/AGhDzeCwRwZlyR9b4InWQiaZnRnJj 28vKpC6YaGXRS5j/iPRVgW25sa+CkOZld2DvFsoHxhp5ehSPX3n7TKZlDFzRTSU2XaTs o66A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Lp++q3SzG2O7dmFll/nIUa4mhqh+SWA5jhIi0Jr7h10=; b=VjYJV+sk4lSm4ktAxVfuYokHOlWBRAZVj891EpV2EKa7H7ZCazOmmzxU2/YhqSxh4e ebJrs+JCxFEKADTAuR3ADD3nS1KW/bet1uoSFCvWq7CsUow2/LAWpuAhh4GDaVegtQ3M xHgjk+BzZ1ilGGC7puM/PmQbMBsOpy8TpxMcPq0ShMdbp9CLpyTKtD/L5YyftvUK0/Mg ZCc0WaAIoZ9Zz7JNzJsXfx8rd4A6AaWHLdZYm2EKx1wN/K+NzLKnq/8ubMNf38CmFLfE M11B4npW/ZQUSa9Y2a78+UfKGp6gUCr9MjuogfRAFazACGt0akRCmsYDd3IttJz6nsWQ pskg== ARC-Authentication-Results: i=1; mx.google.com; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si12776256ejm.695.2020.09.17.00.08.26; Thu, 17 Sep 2020 00:08:50 -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; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726205AbgIQHHN (ORCPT + 99 others); Thu, 17 Sep 2020 03:07:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbgIQHGY (ORCPT ); Thu, 17 Sep 2020 03:06:24 -0400 Received: from localhost (unknown [193.47.165.251]) (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 B6941206E6; Thu, 17 Sep 2020 07:06:17 +0000 (UTC) Date: Thu, 17 Sep 2020 10:06:14 +0300 From: Leon Romanovsky To: Wong Vee Khee Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , 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 , Tan Tee Min , Vijaya Balan Sadhishkhanna , Seow Chen Yong Subject: Re: [PATCH net-next] net: stmmac: introduce rtnl_lock|unlock() on configuring real_num_rx|tx_queues Message-ID: <20200917070614.GP486552@unreal> References: <20200917050215.8725-1-vee.khee.wong@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917050215.8725-1-vee.khee.wong@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 01:02:15PM +0800, Wong Vee Khee wrote: > From: "Tan, Tee Min" > > For driver open(), rtnl_lock is acquired by network stack but not in the > resume(). Therefore, we introduce lock_acquired boolean to control when > to use rtnl_lock|unlock() within stmmac_hw_setup(). Doesn't really make sense, if function needs to have lock acquired, the caller is supposed to take it and function should have proper lockdep annotation inside and not this conditional lock/unlock. Thanks > > Fixes: 686cff3d7022 ("net: stmmac: Fix incorrect location to set real_num_rx|tx_queues") > Extra line. > Signed-off-by: Tan, Tee Min > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index df2c74bbfcff..22e6a3defa78 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -2607,7 +2607,8 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv) > * 0 on success and an appropriate (-)ve integer as defined in errno.h > * file on failure. > */ > -static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) > +static int stmmac_hw_setup(struct net_device *dev, bool init_ptp, > + bool lock_acquired) > { > struct stmmac_priv *priv = netdev_priv(dev); > u32 rx_cnt = priv->plat->rx_queues_to_use; > @@ -2715,9 +2716,15 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) > } > > /* Configure real RX and TX queues */ > + if (!lock_acquired) > + rtnl_lock(); > + > netif_set_real_num_rx_queues(dev, priv->plat->rx_queues_to_use); > netif_set_real_num_tx_queues(dev, priv->plat->tx_queues_to_use); > > + if (!lock_acquired) > + rtnl_unlock(); > + > /* Start the ball rolling... */ > stmmac_start_all_dma(priv); > > @@ -2804,7 +2811,7 @@ static int stmmac_open(struct net_device *dev) > goto init_error; > } > > - ret = stmmac_hw_setup(dev, true); > + ret = stmmac_hw_setup(dev, true, true); > if (ret < 0) { > netdev_err(priv->dev, "%s: Hw setup failed\n", __func__); > goto init_error; > @@ -5238,7 +5245,7 @@ int stmmac_resume(struct device *dev) > > stmmac_clear_descriptors(priv); > > - stmmac_hw_setup(ndev, false); > + stmmac_hw_setup(ndev, false, false); > stmmac_init_coalesce(priv); > stmmac_set_rx_mode(ndev); > > -- > 2.17.0 >