netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	netdev@vger.kernel.org
Subject: [PATCH net-next] net: stmmac: allow ethtool action on PCI devices if device is down
Date: Fri, 31 Mar 2023 11:23:41 +0200	[thread overview]
Message-ID: <20230331092341.268964-1-vinschen@redhat.com> (raw)

So far stmmac is only able to handle ethtool commands if the device
is UP.  However, PCI devices usually just have to be in the active
state for ethtool commands.

Rename stmmac_check_if_running to stmmac_ethtool_begin and add a
stmmac_ethtool_complete action.  Check if the device is connected
to PCI and if so, just make sure the device is active.  Reset it
to idle state as complete action.

Tested on Intel Elkhart Lake system.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
---
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 20 +++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 35c8dd92d369..5a57970dc06a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -14,6 +14,7 @@
 #include <linux/mii.h>
 #include <linux/phylink.h>
 #include <linux/net_tstamp.h>
+#include <linux/pm_runtime.h>
 #include <asm/io.h>
 
 #include "stmmac.h"
@@ -429,13 +430,27 @@ static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level)
 
 }
 
-static int stmmac_check_if_running(struct net_device *dev)
+static int stmmac_ethtool_begin(struct net_device *dev)
 {
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	if (priv->plat->pdev) {
+		pm_runtime_get_sync(&priv->plat->pdev->dev);
+		return 0;
+	}
 	if (!netif_running(dev))
 		return -EBUSY;
 	return 0;
 }
 
+static void stmmac_ethtool_complete(struct net_device *dev)
+{
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	if (priv->plat->pdev)
+		pm_runtime_put(&priv->plat->pdev->dev);
+}
+
 static int stmmac_ethtool_get_regs_len(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
@@ -1152,7 +1167,8 @@ static int stmmac_set_tunable(struct net_device *dev,
 static const struct ethtool_ops stmmac_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
 				     ETHTOOL_COALESCE_MAX_FRAMES,
-	.begin = stmmac_check_if_running,
+	.begin = stmmac_ethtool_begin,
+	.complete = stmmac_ethtool_complete,
 	.get_drvinfo = stmmac_ethtool_getdrvinfo,
 	.get_msglevel = stmmac_ethtool_getmsglevel,
 	.set_msglevel = stmmac_ethtool_setmsglevel,
-- 
2.39.2


             reply	other threads:[~2023-03-31  9:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  9:23 Corinna Vinschen [this message]
2023-03-31 10:48 ` [PATCH net-next] net: stmmac: allow ethtool action on PCI devices if device is down Heiner Kallweit
2023-04-03  9:43   ` Corinna Vinschen
2023-04-03 13:13     ` Heiner Kallweit
2023-04-25  8:14     ` Corinna Vinschen
2023-04-25 13:54       ` Jakub Kicinski
2023-04-26 10:24         ` Corinna Vinschen

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=20230331092341.268964-1-vinschen@redhat.com \
    --to=vinschen@redhat.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=joabreu@synopsys.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /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).