netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY
@ 2021-07-19  9:32 Hao Chen
  2021-07-19  9:52 ` Joakim Zhang
  2021-07-19 19:48 ` Andrew Lunn
  0 siblings, 2 replies; 3+ messages in thread
From: Hao Chen @ 2021-07-19  9:32 UTC (permalink / raw)
  To: peppe.cavallaro
  Cc: alexandre.torgue, joabreu, davem, kuba, mcoquelin.stm32, linux,
	netdev, linux-stm32, linux-kernel, Hao Chen

The permanent mac address should be available for query when the device
is not up.
NetworkManager, the system network daemon, uses 'ethtool -P' to obtain
the permanent address after the kernel start. When the network device
is not up, it will return the device busy error with 'ethtool -P'. At
that time, it is unable to access the Internet through the permanent
address by NetworkManager.
I think that the '.begin' is not used to check if the device is up.

Signed-off-by: Hao Chen <chenhaoa@uniontech.com>
---
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index d0ce608b81c3..25c44c1ecbd6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -15,6 +15,7 @@
 #include <linux/phylink.h>
 #include <linux/net_tstamp.h>
 #include <asm/io.h>
+#include <linux/pm_runtime.h>
 
 #include "stmmac.h"
 #include "dwmac_dma.h"
@@ -410,13 +411,22 @@ 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)
 {
-	if (!netif_running(dev))
-		return -EBUSY;
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	pm_runtime_get_sync(priv->device);
+
 	return 0;
 }
 
+static void stmmac_ethtool_complete(struct net_device *dev)
+{
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	pm_runtime_put(priv->device);
+}
+
 static int stmmac_ethtool_get_regs_len(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
@@ -1073,7 +1083,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.20.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY
  2021-07-19  9:32 [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
@ 2021-07-19  9:52 ` Joakim Zhang
  2021-07-19 19:48 ` Andrew Lunn
  1 sibling, 0 replies; 3+ messages in thread
From: Joakim Zhang @ 2021-07-19  9:52 UTC (permalink / raw)
  To: Hao Chen, peppe.cavallaro
  Cc: alexandre.torgue, joabreu, davem, kuba, mcoquelin.stm32, linux,
	netdev, linux-stm32, linux-kernel


> -----Original Message-----
> From: Hao Chen <chenhaoa@uniontech.com>
> Sent: 2021年7月19日 17:32
> To: peppe.cavallaro@st.com
> Cc: alexandre.torgue@foss.st.com; joabreu@synopsys.com;
> davem@davemloft.net; kuba@kernel.org; mcoquelin.stm32@gmail.com;
> linux@armlinux.org.uk; netdev@vger.kernel.org;
> linux-stm32@st-md-mailman.stormreply.com; linux-kernel@vger.kernel.org;
> Hao Chen <chenhaoa@uniontech.com>
> Subject: [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY
> 
> The permanent mac address should be available for query when the device is
> not up.
> NetworkManager, the system network daemon, uses 'ethtool -P' to obtain the
> permanent address after the kernel start. When the network device is not up,
> it will return the device busy error with 'ethtool -P'. At that time, it is unable to
> access the Internet through the permanent address by NetworkManager.
> I think that the '.begin' is not used to check if the device is up.
> 
> Signed-off-by: Hao Chen <chenhaoa@uniontech.com>
> ---
>  .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> index d0ce608b81c3..25c44c1ecbd6 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> @@ -15,6 +15,7 @@
>  #include <linux/phylink.h>
>  #include <linux/net_tstamp.h>
>  #include <asm/io.h>
> +#include <linux/pm_runtime.h>
Please in alphabetical order.


>  #include "stmmac.h"
>  #include "dwmac_dma.h"
> @@ -410,13 +411,22 @@ 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)
>  {
> -	if (!netif_running(dev))
> -		return -EBUSY;
> +	struct stmmac_priv *priv = netdev_priv(dev);
> +
> +	pm_runtime_get_sync(priv->device);
> +
>  	return 0;
>  }

Add error check, like:
ret = pm_runtime_get_sync(priv->device);
if (ret < 0) {
	pm_runtime_put_noidle(priv->device);
	return ret;
}

Best Regards,
Joakim Zhang
> +static void stmmac_ethtool_complete(struct net_device *dev) {
> +	struct stmmac_priv *priv = netdev_priv(dev);
> +
> +	pm_runtime_put(priv->device);
> +}
> +
>  static int stmmac_ethtool_get_regs_len(struct net_device *dev)  {
>  	struct stmmac_priv *priv = netdev_priv(dev); @@ -1073,7 +1083,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.20.1
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY
  2021-07-19  9:32 [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
  2021-07-19  9:52 ` Joakim Zhang
@ 2021-07-19 19:48 ` Andrew Lunn
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2021-07-19 19:48 UTC (permalink / raw)
  To: Hao Chen
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, linux, netdev, linux-stm32, linux-kernel

On Mon, Jul 19, 2021 at 05:32:07PM +0800, Hao Chen wrote:
> The permanent mac address should be available for query when the device
> is not up.
> NetworkManager, the system network daemon, uses 'ethtool -P' to obtain
> the permanent address after the kernel start. When the network device
> is not up, it will return the device busy error with 'ethtool -P'. At
> that time, it is unable to access the Internet through the permanent
> address by NetworkManager.
> I think that the '.begin' is not used to check if the device is up.

You forgot to update the commit message.

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-19 20:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  9:32 [PATCH v4] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
2021-07-19  9:52 ` Joakim Zhang
2021-07-19 19:48 ` Andrew Lunn

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).