public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli•us>
To: Jakub Kicinski <jakub.kicinski@netronome•com>
Cc: netdev@vger•kernel.org, davem@davemloft•net, mlxsw@mellanox•com,
	idosch@mellanox•com, f.fainelli@gmail•com, andrew@lunn•ch,
	vivien.didelot@gmail•com
Subject: Re: [patch net-next 06/11] net: devlink: don't take devlink_mutex for devlink_compat_*
Date: Fri, 22 Mar 2019 14:44:52 +0100	[thread overview]
Message-ID: <20190322134452.GD2211@nanopsycho> (raw)
In-Reply-To: <20190321120824.5fcbbbb4@cakuba.netronome.com>

Thu, Mar 21, 2019 at 08:08:24PM CET, jakub.kicinski@netronome•com wrote:
>On Thu, 21 Mar 2019 14:20:14 +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox•com>
>> 
>> The netdevice is guaranteed to not disappear so we can rely that
>> devlink_port and devlink won't disappear as well. No need to take
>> devlink_mutex so don't take it here.
>
>I'm not sure the port can't disappear, just looking at this series it
>seems bnxt registers the port after netdev (maybe it unregisters in 
>the other order).  Not that it matters here, we use the main devlink
>instance for the compat helpers, and devlink instance should
>definitely exist.

You are right. Btw, the devlink_port-netdev registration order should be
fixed as well. Niting it down to my todo.


>
>So FWIW the entire series looks good to me.
>
>I've also pushed my port patches out:
>
>https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git/log/?h=devlink-pci-ports
>
>if that's of any use to you (e.g. the patch which changes the order of
>port vs netdev registration).

Thanks.


>
>> Signed-off-by: Jiri Pirko <jiri@mellanox•com>
>
>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index 3dc51ddf7451..1e125c3b890c 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -6444,17 +6444,15 @@ void devlink_compat_running_version(struct net_device *dev,
>>  	dev_hold(dev);
>>  	rtnl_unlock();
>>  
>> -	mutex_lock(&devlink_mutex);
>>  	devlink = netdev_to_devlink(dev);
>>  	if (!devlink || !devlink->ops->info_get)
>> -		goto unlock_list;
>> +		goto out;
>>  
>>  	mutex_lock(&devlink->lock);
>>  	__devlink_compat_running_version(devlink, buf, len);
>>  	mutex_unlock(&devlink->lock);
>> -unlock_list:
>> -	mutex_unlock(&devlink_mutex);
>>  
>> +out:
>>  	rtnl_lock();
>>  	dev_put(dev);
>>  }
>> @@ -6462,22 +6460,22 @@ void devlink_compat_running_version(struct net_device *dev,
>>  int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
>>  {
>>  	struct devlink *devlink;
>> -	int ret = -EOPNOTSUPP;
>> +	int ret;
>>  
>>  	dev_hold(dev);
>>  	rtnl_unlock();
>>  
>> -	mutex_lock(&devlink_mutex);
>>  	devlink = netdev_to_devlink(dev);
>> -	if (!devlink || !devlink->ops->flash_update)
>> -		goto unlock_list;
>> +	if (!devlink || !devlink->ops->flash_update) {
>> +		ret = -EOPNOTSUPP;
>> +		goto out;
>> +	}
>>  
>>  	mutex_lock(&devlink->lock);
>>  	ret = devlink->ops->flash_update(devlink, file_name, NULL, NULL);
>>  	mutex_unlock(&devlink->lock);
>> -unlock_list:
>> -	mutex_unlock(&devlink_mutex);
>>  
>> +out:
>>  	rtnl_lock();
>>  	dev_put(dev);
>>  
>

  reply	other threads:[~2019-03-22 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 13:20 [patch net-next 00/11] devlink: small spring cleanup Jiri Pirko
2019-03-21 13:20 ` [patch net-next 01/11] net: devlink: add couple of missing mutex_destroy() calls Jiri Pirko
2019-03-21 13:20 ` [patch net-next 02/11] bnxt: add missing net/devlink.h include Jiri Pirko
2019-03-22  9:16   ` Vasundhara Volam
2019-03-22 13:38     ` Jiri Pirko
2019-03-21 13:20 ` [patch net-next 03/11] dsa: " Jiri Pirko
2019-03-21 14:12   ` Andrew Lunn
2019-03-21 13:20 ` [patch net-next 04/11] bnxt: set devlink port attrs properly Jiri Pirko
2019-03-21 13:20 ` [patch net-next 05/11] bnxt: call devlink_port_type_eth_set() before port register Jiri Pirko
2019-03-21 13:20 ` [patch net-next 06/11] net: devlink: don't take devlink_mutex for devlink_compat_* Jiri Pirko
2019-03-21 19:08   ` Jakub Kicinski
2019-03-22 13:44     ` Jiri Pirko [this message]
2019-03-21 13:20 ` [patch net-next 07/11] net: devlink: don't pass return value of __devlink_port_type_set() Jiri Pirko
2019-03-21 13:20 ` [patch net-next 08/11] mlxsw: Move devlink_port_attrs_set() call before register Jiri Pirko
2019-03-21 13:20 ` [patch net-next 09/11] dsa: move " Jiri Pirko
2019-03-21 13:41   ` Andrew Lunn
2019-03-21 13:44     ` Jiri Pirko
2019-03-21 13:20 ` [patch net-next 10/11] net: devlink: disallow port_attrs_set() to be called " Jiri Pirko
2019-03-21 13:20 ` [patch net-next 11/11] net: devlink: add port type spinlock Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190322134452.GD2211@nanopsycho \
    --to=jiri@resnulli$(echo .)us \
    --cc=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=idosch@mellanox$(echo .)com \
    --cc=jakub.kicinski@netronome$(echo .)com \
    --cc=mlxsw@mellanox$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=vivien.didelot@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox