All of lore.kernel.org
 help / color / mirror / Atom feed
* [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY
@ 2021-07-21  9:07 Hao Chen
  2021-07-21 15:10   ` [net, v6] " kernel test robot
  2021-07-21 15:25   ` [net, v6] " kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Hao Chen @ 2021-07-21  9:07 UTC (permalink / raw)
  To: peppe.cavallaro
  Cc: alexandre.torgue, joabreu, davem, kuba, mcoquelin.stm32, linux,
	netdev, linux-stm32, linux-kernel, qiangqing.zhang, Hao Chen

I want to get permanent MAC address when the card 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 detect that the network card is up in '. Begin',
which will cause that all the ethtool commands can't be used when the
network card 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.

I have checked the '. Begin' implementation of other drivers, most of which
support the submission of NIC driver for the first time.
They are too old to know why '. Begin' is implemented. I suspect that they
have not noticed the usage of '. Begin'.

Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet
		     controllers.")

Compile-tested on arm64. Tested on an arm64 system with an on-board
STMMAC chip.

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  | 21 +++++++++++++------
 1 file changed, 15 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..e969bde36507 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,18 @@ 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;
+	struct stmmac_priv *priv = netdev_priv(dev);
+
+	return pm_runtime_resume_and_get(dev);
+}
+
+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)
@@ -1073,7 +1081,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] 5+ messages in thread

* Re: [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY
  2021-07-21  9:07 [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
@ 2021-07-21 15:10   ` kernel test robot
  2021-07-21 15:25   ` [net, v6] " kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-21 15:10 UTC (permalink / raw)
  To: Hao Chen, peppe.cavallaro
  Cc: clang-built-linux, kbuild-all, alexandre.torgue, joabreu, davem,
	kuba, mcoquelin.stm32, linux, netdev, linux-stm32, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3010 bytes --]

Hi Hao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b
config: arm64-randconfig-r022-20210720 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project c781eb153bfbd1b52b03efe34f56bbeccbb8aba6)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
        git checkout c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:378:7: warning: variable 'mask' set but not used [-Wunused-but-set-variable]
                   u32 mask = ADVERTISED_Autoneg | ADVERTISED_Pause;
                       ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:418:35: error: incompatible pointer types passing 'struct net_device *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
           return pm_runtime_resume_and_get(dev);
                                            ^~~
   include/linux/pm_runtime.h:400:60: note: passing argument to parameter 'dev' here
   static inline int pm_runtime_resume_and_get(struct device *dev)
                                                              ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:416:22: warning: unused variable 'priv' [-Wunused-variable]
           struct stmmac_priv *priv = netdev_priv(dev);
                               ^
   2 warnings and 1 error generated.


vim +418 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

   413	
   414	static int stmmac_ethtool_begin(struct net_device *dev)
   415	{
   416		struct stmmac_priv *priv = netdev_priv(dev);
   417	
 > 418		return pm_runtime_resume_and_get(dev);
   419	}
   420	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 45891 bytes --]

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

* Re: [net, v6] net: stmmac: fix 'ethtool -P' return -EBUSY
@ 2021-07-21 15:10   ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-21 15:10 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3072 bytes --]

Hi Hao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b
config: arm64-randconfig-r022-20210720 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project c781eb153bfbd1b52b03efe34f56bbeccbb8aba6)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
        git checkout c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:378:7: warning: variable 'mask' set but not used [-Wunused-but-set-variable]
                   u32 mask = ADVERTISED_Autoneg | ADVERTISED_Pause;
                       ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:418:35: error: incompatible pointer types passing 'struct net_device *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
           return pm_runtime_resume_and_get(dev);
                                            ^~~
   include/linux/pm_runtime.h:400:60: note: passing argument to parameter 'dev' here
   static inline int pm_runtime_resume_and_get(struct device *dev)
                                                              ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:416:22: warning: unused variable 'priv' [-Wunused-variable]
           struct stmmac_priv *priv = netdev_priv(dev);
                               ^
   2 warnings and 1 error generated.


vim +418 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

   413	
   414	static int stmmac_ethtool_begin(struct net_device *dev)
   415	{
   416		struct stmmac_priv *priv = netdev_priv(dev);
   417	
 > 418		return pm_runtime_resume_and_get(dev);
   419	}
   420	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 45891 bytes --]

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

* Re: [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY
  2021-07-21  9:07 [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
@ 2021-07-21 15:25   ` kernel test robot
  2021-07-21 15:25   ` [net, v6] " kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-21 15:25 UTC (permalink / raw)
  To: Hao Chen, peppe.cavallaro
  Cc: kbuild-all, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, linux, netdev, linux-stm32, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2954 bytes --]

Hi Hao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b
config: nios2-allyesconfig (attached as .config)
compiler: nios2-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
        git checkout c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=nios2 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c: In function 'stmmac_ethtool_begin':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:418:35: error: passing argument 1 of 'pm_runtime_resume_and_get' from incompatible pointer type [-Werror=incompatible-pointer-types]
     418 |  return pm_runtime_resume_and_get(dev);
         |                                   ^~~
         |                                   |
         |                                   struct net_device *
   In file included from drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:17:
   include/linux/pm_runtime.h:400:60: note: expected 'struct device *' but argument is of type 'struct net_device *'
     400 | static inline int pm_runtime_resume_and_get(struct device *dev)
         |                                             ~~~~~~~~~~~~~~~^~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:416:22: warning: unused variable 'priv' [-Wunused-variable]
     416 |  struct stmmac_priv *priv = netdev_priv(dev);
         |                      ^~~~
   cc1: some warnings being treated as errors


vim +/pm_runtime_resume_and_get +418 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

   413	
   414	static int stmmac_ethtool_begin(struct net_device *dev)
   415	{
   416		struct stmmac_priv *priv = netdev_priv(dev);
   417	
 > 418		return pm_runtime_resume_and_get(dev);
   419	}
   420	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 60074 bytes --]

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

* Re: [net, v6] net: stmmac: fix 'ethtool -P' return -EBUSY
@ 2021-07-21 15:25   ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-21 15:25 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3015 bytes --]

Hi Hao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210721]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b
config: nios2-allyesconfig (attached as .config)
compiler: nios2-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hao-Chen/net-stmmac-fix-ethtool-P-return-EBUSY/20210721-172413
        git checkout c55b4adeb427ae7db9fb2942a7bc7958a8d667bd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=nios2 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c: In function 'stmmac_ethtool_begin':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:418:35: error: passing argument 1 of 'pm_runtime_resume_and_get' from incompatible pointer type [-Werror=incompatible-pointer-types]
     418 |  return pm_runtime_resume_and_get(dev);
         |                                   ^~~
         |                                   |
         |                                   struct net_device *
   In file included from drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:17:
   include/linux/pm_runtime.h:400:60: note: expected 'struct device *' but argument is of type 'struct net_device *'
     400 | static inline int pm_runtime_resume_and_get(struct device *dev)
         |                                             ~~~~~~~~~~~~~~~^~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:416:22: warning: unused variable 'priv' [-Wunused-variable]
     416 |  struct stmmac_priv *priv = netdev_priv(dev);
         |                      ^~~~
   cc1: some warnings being treated as errors


vim +/pm_runtime_resume_and_get +418 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

   413	
   414	static int stmmac_ethtool_begin(struct net_device *dev)
   415	{
   416		struct stmmac_priv *priv = netdev_priv(dev);
   417	
 > 418		return pm_runtime_resume_and_get(dev);
   419	}
   420	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 60074 bytes --]

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

end of thread, other threads:[~2021-07-21 15:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21  9:07 [net,v6] net: stmmac: fix 'ethtool -P' return -EBUSY Hao Chen
2021-07-21 15:10 ` kernel test robot
2021-07-21 15:10   ` [net, v6] " kernel test robot
2021-07-21 15:25 ` [net,v6] " kernel test robot
2021-07-21 15:25   ` [net, v6] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.