Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp370106ybl; Thu, 9 Jan 2020 23:43:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxxNiPdIbsS45tF66mY9iHc2CRtGWRBg6uZVkjHSAZ2RHg4Lj7wmHOdbWQDR92sHtmdnDa/ X-Received: by 2002:a9d:478:: with SMTP id 111mr1433255otc.359.1578642222718; Thu, 09 Jan 2020 23:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578642222; cv=none; d=google.com; s=arc-20160816; b=XsUb7E9v5lNmdzfR/MbnUEZ4cncDBFkUpkje8DX/2/uQfSWQdixBE+om7Rn3sxZ7wm ZBaYah3aaOqbnKYnFmUfuo/wS+IXj3HusgC70IdSZo6et9zLwGWAwhQ1s8mABrNx170N VCcf6bqTkbFAfPMrAAdFFqvMNRdypDpGairbLOAen+teE8njGwrKgN35xXKc+GYwsNGD zSChCsB2NXgwIkSC9P9c3+c4dvFGQ1WblvVFY3Uef0KwpL1ufMMbf0GaGqT78rk0paRB oO0R/sCxlsLGSrWX8gLXf9V6KKFizRB6tip7UPX9u3zov5WVDHL/OOWWBnZKpK7400aj GJ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=chXaHS7MyMrXpmSfwltB1iiW6Dvzm9IZBUPGz/8IiMs=; b=S819c9DPcmGVxyPIb7q6OkrDNTh+ZuNVXR1iKT+fvDjV6sYb8klvdoQjZ1makE4Fh8 3AddUtiXUbenRZWFG7qDRnJ1yQQzHAkh3pDjTgbFfbdJSWvnSfEEh42GZSaZya5kFcQG LyEQv2W1F4i7FdD3aaavLdRreRvQspksy/jA/sf2rI2OQKuA1t5fpcMeS7GXj4KEMt92 Czb4kud4r45mozlK0swE3aJ7oEj8J3uF70+g0k3VSwWgFCrjdDZmoIWuCmQs4Nn0+sOu 7dH5LLUpX2/RGFEX3HcTxkbtsYnZmeS8K6UXu36MFW0F4U/Kl8cy/m+wmCVg6CtQ3yGn Z4ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i17si692119ota.82.2020.01.09.23.43.31; Thu, 09 Jan 2020 23:43:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbgAJHmg (ORCPT + 99 others); Fri, 10 Jan 2020 02:42:36 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41985 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbgAJHmf (ORCPT ); Fri, 10 Jan 2020 02:42:35 -0500 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ipow3-0001rj-Lx; Fri, 10 Jan 2020 07:42:24 +0000 From: Kai-Heng Feng To: davem@davemloft.ne, jeffrey.t.kirsher@intel.com Cc: Kai-Heng Feng , "David S. Miller" , Michal Kubecek , Florian Fainelli , Jiri Pirko , Pablo Neira Ayuso , Maxime Chevallier , Jakub Kicinski , Li RongQing , netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] ethtool: Call begin() and complete() in __ethtool_get_link_ksettings() Date: Fri, 10 Jan 2020 15:41:59 +0800 Message-Id: <20200110074159.18473-2-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200110074159.18473-1-kai.heng.feng@canonical.com> References: <20200110074159.18473-1-kai.heng.feng@canonical.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device like igb gets runtime suspended when there's no link partner. We can't get correct speed under that state: $ cat /sys/class/net/enp3s0/speed 1000 In addition to that, an error can also be spotted in dmesg: [ 385.991957] igb 0000:03:00.0 enp3s0: PCIe link lost It's because the igb device doesn't get runtime resumed before calling get_link_ksettings(). So let's call begin() and complete() like what dev_ethtool() does, to runtime resume/suspend or power up/down the device properly. Once this fix is in place, igb can show the speed correctly without link partner: $ cat /sys/class/net/enp3s0/speed -1 Signed-off-by: Kai-Heng Feng --- net/ethtool/ioctl.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 182bffbffa78..c768dbf45fc4 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -423,13 +423,26 @@ struct ethtool_link_usettings { int __ethtool_get_link_ksettings(struct net_device *dev, struct ethtool_link_ksettings *link_ksettings) { + int rc; + ASSERT_RTNL(); if (!dev->ethtool_ops->get_link_ksettings) return -EOPNOTSUPP; + if (dev->ethtool_ops->begin) { + rc = dev->ethtool_ops->begin(dev); + if (rc < 0) + return rc; + } + memset(link_ksettings, 0, sizeof(*link_ksettings)); - return dev->ethtool_ops->get_link_ksettings(dev, link_ksettings); + rc = dev->ethtool_ops->get_link_ksettings(dev, link_ksettings); + + if (dev->ethtool_ops->complete) + dev->ethtool_ops->complete(dev); + + return rc; } EXPORT_SYMBOL(__ethtool_get_link_ksettings); -- 2.17.1