From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0494BC43381 for ; Thu, 21 Mar 2019 19:08:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEA9A218D3 for ; Thu, 21 Mar 2019 19:08:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="VAJ8bUj3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728779AbfCUTIb (ORCPT ); Thu, 21 Mar 2019 15:08:31 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:33701 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbfCUTIb (ORCPT ); Thu, 21 Mar 2019 15:08:31 -0400 Received: by mail-qt1-f194.google.com with SMTP id k14so7940549qtb.0 for ; Thu, 21 Mar 2019 12:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=dXmQHaBHulcBBn46pvpGR62ZagBm2KBDia1UyH//+ZI=; b=VAJ8bUj3b49fl7G4C6v+CKkuIB17/+CSBpkBODPj47h2k+jSU9Bjo/b3Sug8HGq+Zs lCPAMTcKdmrU1IVQWJXaM2T4RUUD4rjhC5Ogo62sPmb+yAnVJ1Fj4oQRivO9qLJDbjYb oOmj79vB+KGZZi6K1z+2SQXun2z+fMkhoxgd3ZyV1bU1FSgcmAvcB88BlwtD8zdbE+J8 BWkzh/mMP/tliVF03f8NaoCEFVojAU9t5YrX7EZnu62/Ckvpy+FbpDOHB2I9dA8SinID 0l0EtotDiPXBgCaNaGAJK4KfLLAzTBB1ydanpnwrMRPKIj4ge6oCPT+PZ7ztxglhCyiM 7scA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=dXmQHaBHulcBBn46pvpGR62ZagBm2KBDia1UyH//+ZI=; b=qldhJoXA82jr/zvAVDgfQa27LRYbdwtaO4tdoyplfnKxvc4Mjah936EdBHRwTnHEgZ 40iqamgEf9ukAsYouCR46RGeG1mIm5GD+KxFZLgdaXag0daGKpB/wbmi188YKvtENUDa Brr7C3eN5xolafsuPNIdp/zXB4LonUS/M+u3scZ7E+x7/sdhK3LrsDxT+YYa30J4p9Ld 9320pKQo+n4XrGVlz7cXsnJWDZcgunDOoqw9/JYQbO+MKKX4Egcb/ehm7DX2u+yGROE1 xB35tfC9XjpXIkPd/V7T68lHvURiqJkch+Oo6X02zQJDuyzaeKPX2RqucbElXVSUHOx6 Rb+Q== X-Gm-Message-State: APjAAAWgKtWjUcxudG6Wz8GK40bO30pxMeP3tCxyd6u1AR/LpZxk1wvU DXKIYGewMR71Wtz7rq2kQS0/Gw== X-Google-Smtp-Source: APXvYqwiWIwo8RYnzYsh9uRGp8Xhz3ZvqEyyx+5R+8nCWvHY8xj5XJmZdjIMycODsJs/WkuXMzrqEg== X-Received: by 2002:a0c:d498:: with SMTP id u24mr4603971qvh.117.1553195309166; Thu, 21 Mar 2019 12:08:29 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id y5sm3460590qkl.73.2019.03.21.12.08.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 12:08:29 -0700 (PDT) Date: Thu, 21 Mar 2019 12:08:24 -0700 From: Jakub Kicinski To: Jiri Pirko 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_* Message-ID: <20190321120824.5fcbbbb4@cakuba.netronome.com> In-Reply-To: <20190321132019.1426-7-jiri@resnulli.us> References: <20190321132019.1426-1-jiri@resnulli.us> <20190321132019.1426-7-jiri@resnulli.us> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 21 Mar 2019 14:20:14 +0100, Jiri Pirko wrote: > From: Jiri Pirko > > 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. 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). > Signed-off-by: Jiri Pirko > 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); >