On 11/15/2017 10:03 AM, Jakub Kicinski wrote:
> On Tue, 14 Nov 2017 17:18:44 +0100, Jiri Pirko wrote:
>> +static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info 
>> *info)
>> +{
>> +    struct devlink *devlink = info->user_ptr[0];
>> +    int err;
>> +
>> +    if (!devlink->ops->reload)
>> +            return -EOPNOTSUPP;
>> +
>> +    err = devlink_resources_validate(devlink, NULL, info);
>> +    if (err)
>> +            return err;
>> +
>> +    mutex_unlock(&devlink->lock);
>> +    err = devlink->ops->reload(devlink);
>> +    mutex_lock(&devlink->lock);
>> +
>> +    return err;
>> +}
> 
> I'm a bit confused with the locking, why is devlink->lock not held
> around the validation?
> 

As Jiri mentioned it is held. The per devlink instance lock is taken
by default for each doit operation in the pre_doit(), because it operates
on a specific devlink instance.

The lock is released before performing the reload itself because during
the reload the driver register/unregisters devlink objects like sb/dpipe
/ports, which require the lock again, so this is done in order to avoid
recursive locking.

Reply via email to