netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Hao Chen <chenhaoa@uniontech.com>,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: [net-next,v8] net: stmmac: optimize check in ops '.begin'
Date: Tue, 3 Aug 2021 08:04:40 +0200	[thread overview]
Message-ID: <b21d425e-d2ec-aa39-16ea-838b638e250e@gmail.com> (raw)
In-Reply-To: <20210803023836.6244-1-chenhaoa@uniontech.com>

On 03.08.2021 04:38, Hao Chen wrote:
> I want to get permanent MAC address when the interface is down. And I think
> it is more convenient to get statistics in the down state by 'ethtool -S'.
> But current all of the ethool command return -EBUSY.
> 
> I don't think we should check that the network interface is up in '.begin',
> which will cause that all the ethtool commands can't be used when the
> network interface is down. If some ethtool commands can only be used in the
> up state, check it in the corresponding ethool OPS function is better.
> This is too rude and unreasonable.
> 
> Compile-tested on arm64. Tested on an arm64 system with an on-board
> STMMAC chip.
> 

I doubt it's compile-tested, at least not with rpm enabled.
See comment below.

> Changes v7 ... v8:
> - Optimize commit description information, optimization parameters of
>   pm_runtime function.
> 
> Changes v6 ... v7:
> - fix arg type error of 'dev' to 'priv->device'.
> 
> Changes v5 ... v6:
> - The 4.19.90 kernel not support pm_runtime, so implemente '.begin' and
>   '.complete' again. Add return value check of pm_runtime function.
> 
> Changes v4 ... v5:
> - test the '.begin' will return -13 error on my machine based on 4.19.90
>   kernel. The platform driver does not supported pm_runtime. So remove the
>   implementation of '.begin' and '.complete'.
> 
> Changes v3 ... v4:
> - implement '.complete' ethtool OPS.
> 
> Changes v2 ... v3:
> - add linux/pm_runtime.h head file.
> 
> Changes v1 ... v2:
> - fix spell error of dev.
> 
> Signed-off-by: Hao Chen <chenhaoa@uniontech.com>
> ---
>  .../ethernet/stmicro/stmmac/stmmac_ethtool.c    | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> index d0ce608b81c3..8e2ae0ff7f8f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
> @@ -12,8 +12,9 @@
>  #include <linux/ethtool.h>
>  #include <linux/interrupt.h>
>  #include <linux/mii.h>
> -#include <linux/phylink.h>
>  #include <linux/net_tstamp.h>
> +#include <linux/phylink.h>
> +#include <linux/pm_runtime.h>
>  #include <asm/io.h>
>  
>  #include "stmmac.h"
> @@ -410,11 +411,14 @@ 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;
> -	return 0;
> +	return pm_runtime_resume_and_get(dev->dev);

This is wrong in two ways:
- There is a type mismatch and the code won't compile.
- I talked about the netdev parent.

> +}
> +
> +static void stmmac_ethtool_complete(struct net_device *dev)
> +{
> +	pm_runtime_put(dev->dev);
>  }
>  
>  static int stmmac_ethtool_get_regs_len(struct net_device *dev)
> @@ -1073,7 +1077,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,
> 

Again you missed to send the patch to the maintainers.
Read the basics about how to submit a patch.

Last but not least please wait for feedback on
https://lore.kernel.org/netdev/106547ef-7a61-2064-33f5-3cc8d12adb34@gmail.com/

  reply	other threads:[~2021-08-03  6:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  2:38 [net-next,v8] net: stmmac: optimize check in ops '.begin' Hao Chen
2021-08-03  6:04 ` Heiner Kallweit [this message]
2021-08-03  9:01 ` kernel test robot
2021-08-03 10:33 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-08-03  2:37 Hao Chen

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=b21d425e-d2ec-aa39-16ea-838b638e250e@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=chenhaoa@uniontech.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.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).