From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: davem@davemloft.ne, jeffrey.t.kirsher@intel.com
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
"David S. Miller" <davem@davemloft.net>,
Michal Kubecek <mkubecek@suse.cz>,
Florian Fainelli <f.fainelli@gmail.com>,
Jiri Pirko <jiri@mellanox.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Li RongQing <lirongqing@baidu.com>,
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 [thread overview]
Message-ID: <20200110074159.18473-2-kai.heng.feng@canonical.com> (raw)
In-Reply-To: <20200110074159.18473-1-kai.heng.feng@canonical.com>
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 <kai.heng.feng@canonical.com>
---
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
next prev parent reply other threads:[~2020-01-10 7:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 7:41 [PATCH 1/2] igb: Use device_lock() insead of rtnl_lock() Kai-Heng Feng
2020-01-10 7:41 ` Kai-Heng Feng [this message]
2020-01-13 12:51 ` [PATCH 2/2] ethtool: Call begin() and complete() in __ethtool_get_link_ksettings() Michal Kubecek
2020-01-14 10:06 ` Kai-Heng Feng
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=20200110074159.18473-2-kai.heng.feng@canonical.com \
--to=kai.heng.feng@canonical.com \
--cc=davem@davemloft.ne \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jiri@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).