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=-7.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS 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 401FAC43381 for ; Fri, 22 Feb 2019 21:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1EB92077B for ; Fri, 22 Feb 2019 21:20:30 +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="EOkJB3G2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725929AbfBVVU3 (ORCPT ); Fri, 22 Feb 2019 16:20:29 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:40686 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfBVVU3 (ORCPT ); Fri, 22 Feb 2019 16:20:29 -0500 Received: by mail-qk1-f193.google.com with SMTP id h28so2007030qkk.7 for ; Fri, 22 Feb 2019 13:20:28 -0800 (PST) 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=0XTsbbl6BWV2ZCs8Rd1mBA8tH/zyvVvo01tSd4Sn5Fo=; b=EOkJB3G2UbmL0yejwd4RYzg2iu7jWI2b0fP2VzPbsH46qKu9kwGJrPdAVM2fdzi6Pz lSvKyaUBs77f8HU9tlNbOnTJ7cuBZF7yrUwHkb9JLkXIE+dT+yYLDY1zsEKJSdblXNmg QVlVoRCAkqVQ3Nd/THrmmaGvES7y6enTH83Av2Voh2gvrrLzp9g0g5i9AcVocaU3rusV HzfmVDIHfaW8IAzUOZCKJXGvylWQScr6WkD5SYS8fNVZFz1nW06/6+TcHvK98Y8auEb3 hRD9pH2mb/NnLlSewplQb3hfh5HoN0ywfdZO2KZrjgv5sT2jdJPKXfmVT/oTXKoExpGf QsZg== 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=0XTsbbl6BWV2ZCs8Rd1mBA8tH/zyvVvo01tSd4Sn5Fo=; b=no/iQqlZNM2rhSFakjuSNRxZvFDKLc0p56LEarkU9XKbV7aEEMVNMCei8U50nO0L2O Edb3F85t/hUUgygDmSYl79LAYT+Mb1ruk8TDIPJkiIipBfOFlJ/M/T+1/g/jv9y++8+v GFGH3IRwvS03S1FhR8w2+GdM2KuBeVVupnyY60MN6eqVhf+kfQrf1ANo2HvXSGlTo8qr GVPkOStX3W3Pj8Yx84TAaM6gU24lAXUx+HOszqDe/H2Q8pkDNsDd2zflUo19yCjUUDvt 5dH4tgL7+5RUcIFaOmNZ9Ru94llktn4AhqdQXi1H1Hf0+uwVyVhQzwOuMFhLpWoVEG88 aDkw== X-Gm-Message-State: AHQUAuZhKIGkVA1xdyeg7xXykBWiNKUkN5FRTAfZ1snIBtV13t9h7hip g6on5Sdjx27HnPkIh1gfmXEUItv0dSM= X-Google-Smtp-Source: AHgI3IbLdzHgQ1AWLcXHImywogelsExfW7JJb0geAsv/61SbJrZ+tCG5eqJgeGaH10UtHPSl9Sdb1g== X-Received: by 2002:ae9:e890:: with SMTP id a138mr4467797qkg.339.1550870428273; Fri, 22 Feb 2019 13:20:28 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id i65sm2458234qki.32.2019.02.22.13.20.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 13:20:28 -0800 (PST) Date: Fri, 22 Feb 2019 13:20:23 -0800 From: Jakub Kicinski To: Florian Fainelli Cc: davem@davemloft.net, jiri@resnulli.us, mkubecek@suse.cz, andrew@lunn.ch, netdev@vger.kernel.org, oss-drivers@netronome.com Subject: Re: [PATCH net-next v2 2/5] ethtool: hold a reference to the netdevice around devlink compat Message-ID: <20190222132023.77d213ef@cakuba.netronome.com> In-Reply-To: <97be3163-b167-edf4-fd16-be35dc68fa25@gmail.com> References: <20190222195410.9494-1-jakub.kicinski@netronome.com> <20190222195410.9494-3-jakub.kicinski@netronome.com> <97be3163-b167-edf4-fd16-be35dc68fa25@gmail.com> 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 Fri, 22 Feb 2019 12:09:32 -0800, Florian Fainelli wrote: > On 2/22/19 11:54 AM, Jakub Kicinski wrote: > > When calling into devlink compat code make sure we have a reference > > on the netdevice on which the operation was invoked. > > > > Signed-off-by: Jakub Kicinski > > --- > > net/core/ethtool.c | 11 ++++++++--- > > 1 file changed, 8 insertions(+), 3 deletions(-) > > > > diff --git a/net/core/ethtool.c b/net/core/ethtool.c > > index 1320e8dce559..6832476dfcaf 100644 > > --- a/net/core/ethtool.c > > +++ b/net/core/ethtool.c > > @@ -805,11 +805,14 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, > > if (ops->get_eeprom_len) > > info.eedump_len = ops->get_eeprom_len(dev); > > > > - rtnl_unlock(); > > - if (!info.fw_version[0]) > > + if (!info.fw_version[0]) { > > + dev_hold(dev); > > + rtnl_unlock(); > > devlink_compat_running_version(dev, info.fw_version, > > sizeof(info.fw_version)); > > - rtnl_lock(); > > + rtnl_lock(); > > + dev_put(dev); > > + } > > Would it make sense to make the locking and reference holding implicit > within the compat versions of devlink_* because they use a net_device -> > devlink object manipulation as opposed to doing in the caller. We are > more or less guaranteed that the compatibility layer is used from within > ethtool. I guess we can, in general it feels wrong to call some devlink_ function with rtnl_lock held, but I guess devlink_compat_ can be special in this regard. v3 coming up.