linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH v1 0/2] smsc: use generic power management
@ 2020-07-02 10:53 Vaibhav Gupta
  2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 1/2] epic100: " Vaibhav Gupta
  2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: " Vaibhav Gupta
  0 siblings, 2 replies; 5+ messages in thread
From: Vaibhav Gupta @ 2020-07-02 10:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Jakub Kicinski, Steve Glendinning
  Cc: netdev, linux-kernel-mentees, linux-kernel, Vaibhav Gupta

Linux Kernel Mentee: Remove Legacy Power Management.

The purpose of this patch series is to remove legacy power management callbacks
from smsc ethernet drivers.

The callbacks performing suspend() and resume() operations are still calling
pci_save_state(), pci_set_power_state(), etc. and handling the power management
themselves, which is not recommended.

The conversion requires the removal of the those function calls and change the
callback definition accordingly and make use of dev_pm_ops structure.

All patches are compile-tested only.

Vaibhav Gupta (2):
  epic100: use generic power management
  smsc9420: use generic power management

 drivers/net/ethernet/smsc/epic100.c  | 19 +++++---------
 drivers/net/ethernet/smsc/smsc9420.c | 39 +++++++---------------------
 2 files changed, 16 insertions(+), 42 deletions(-)

-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH v1 1/2] epic100: use generic power management
  2020-07-02 10:53 [Linux-kernel-mentees] [PATCH v1 0/2] smsc: use generic power management Vaibhav Gupta
@ 2020-07-02 10:53 ` Vaibhav Gupta
  2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: " Vaibhav Gupta
  1 sibling, 0 replies; 5+ messages in thread
From: Vaibhav Gupta @ 2020-07-02 10:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Jakub Kicinski, Steve Glendinning
  Cc: netdev, linux-kernel-mentees, linux-kernel, Vaibhav Gupta

Drivers should not use legacy power management as they have to manage power
states and related operations, for the device, themselves.

With generic PM, all essentials will be handled by the PCI core. Driver
needs to do only device-specific operations.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/ethernet/smsc/epic100.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c
index 61ddee0c2a2e..d950b312c418 100644
--- a/drivers/net/ethernet/smsc/epic100.c
+++ b/drivers/net/ethernet/smsc/epic100.c
@@ -1512,12 +1512,9 @@ static void epic_remove_one(struct pci_dev *pdev)
 	/* pci_power_off(pdev, -1); */
 }
 
-
-#ifdef CONFIG_PM
-
-static int epic_suspend (struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused epic_suspend(struct device *dev_d)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = dev_get_drvdata(dev_d);
 	struct epic_private *ep = netdev_priv(dev);
 	void __iomem *ioaddr = ep->ioaddr;
 
@@ -1531,9 +1528,9 @@ static int epic_suspend (struct pci_dev *pdev, pm_message_t state)
 }
 
 
-static int epic_resume (struct pci_dev *pdev)
+static int __maybe_unused epic_resume(struct device *dev_d)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = dev_get_drvdata(dev_d);
 
 	if (!netif_running(dev))
 		return 0;
@@ -1542,18 +1539,14 @@ static int epic_resume (struct pci_dev *pdev)
 	return 0;
 }
 
-#endif /* CONFIG_PM */
-
+static SIMPLE_DEV_PM_OPS(epic_pm_ops, epic_suspend, epic_resume);
 
 static struct pci_driver epic_driver = {
 	.name		= DRV_NAME,
 	.id_table	= epic_pci_tbl,
 	.probe		= epic_init_one,
 	.remove		= epic_remove_one,
-#ifdef CONFIG_PM
-	.suspend	= epic_suspend,
-	.resume		= epic_resume,
-#endif /* CONFIG_PM */
+	.driver.pm	= &epic_pm_ops,
 };
 
 
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: use generic power management
  2020-07-02 10:53 [Linux-kernel-mentees] [PATCH v1 0/2] smsc: use generic power management Vaibhav Gupta
  2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 1/2] epic100: " Vaibhav Gupta
@ 2020-07-02 10:53 ` Vaibhav Gupta
  2020-07-02 20:08   ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Vaibhav Gupta @ 2020-07-02 10:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Jakub Kicinski, Steve Glendinning
  Cc: netdev, linux-kernel-mentees, linux-kernel, Vaibhav Gupta

Drivers should not use legacy power management as they have to manage power
states and related operations, for the device, themselves. This driver was
handling them with the help of PCI helper functions.

With generic PM, all essentials will be handled by the PCI core. Driver
needs to do only device-specific operations.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/ethernet/smsc/smsc9420.c | 39 +++++++---------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index 7312e522c022..d07f509cb4c7 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -1422,11 +1422,9 @@ static int smsc9420_open(struct net_device *dev)
 	return result;
 }
 
-#ifdef CONFIG_PM
-
-static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused smsc9420_suspend(struct device *dev_d)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
+	struct net_device *dev = dev_get_drvdata(dev_d);
 	struct smsc9420_pdata *pd = netdev_priv(dev);
 	u32 int_cfg;
 	ulong flags;
@@ -1451,33 +1449,19 @@ static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
 		netif_device_detach(dev);
 	}
 
-	pci_save_state(pdev);
-	pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
+	device_wakeup_disable(dev_d);
 
 	return 0;
 }
 
-static int smsc9420_resume(struct pci_dev *pdev)
+static int __maybe_unused smsc9420_resume(struct device *dev_d)
 {
-	struct net_device *dev = pci_get_drvdata(pdev);
-	struct smsc9420_pdata *pd = netdev_priv(dev);
+	struct net_device *dev = dev_get_drvdata(dev_d);
 	int err;
 
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-
-	err = pci_enable_device(pdev);
-	if (err)
-		return err;
+	pci_set_master(to_pci_dev(dev_d));
 
-	pci_set_master(pdev);
-
-	err = pci_enable_wake(pdev, PCI_D0, 0);
-	if (err)
-		netif_warn(pd, ifup, pd->dev, "pci_enable_wake failed: %d\n",
-			   err);
+	device_wakeup_disable(dev_d);
 
 	if (netif_running(dev)) {
 		/* FIXME: gross. It looks like ancient PM relic.*/
@@ -1487,8 +1471,6 @@ static int smsc9420_resume(struct pci_dev *pdev)
 	return err;
 }
 
-#endif /* CONFIG_PM */
-
 static const struct net_device_ops smsc9420_netdev_ops = {
 	.ndo_open		= smsc9420_open,
 	.ndo_stop		= smsc9420_stop,
@@ -1658,15 +1640,14 @@ static void smsc9420_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
+static SIMPLE_DEV_PM_OPS(smsc9420_pm_ops, smsc9420_suspend, smsc9420_resume);
+
 static struct pci_driver smsc9420_driver = {
 	.name = DRV_NAME,
 	.id_table = smsc9420_id_table,
 	.probe = smsc9420_probe,
 	.remove = smsc9420_remove,
-#ifdef CONFIG_PM
-	.suspend = smsc9420_suspend,
-	.resume = smsc9420_resume,
-#endif /* CONFIG_PM */
+	.driver.pm = &smsc9420_pm_ops,
 };
 
 static int __init smsc9420_init_module(void)
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: use generic power management
  2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: " Vaibhav Gupta
@ 2020-07-02 20:08   ` kernel test robot
  2020-07-03  3:03     ` Vaibhav Gupta
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2020-07-02 20:08 UTC (permalink / raw)
  To: Vaibhav Gupta, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Jakub Kicinski, Steve Glendinning
  Cc: kbuild-all, netdev, linux-kernel, clang-built-linux,
	linux-kernel-mentees

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

Hi Vaibhav,

Thank you for the patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Vaibhav-Gupta/smsc-use-generic-power-management/20200702-185914
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd77006e01b3198c75fb7819b3d0ff89709539bb
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 003a086ffc0d1affbb8300b36225fb8150a2d40a)
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 x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/smsc/smsc9420.c:1466:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (netif_running(dev)) {
               ^~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/smsc/smsc9420.c:1471:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/net/ethernet/smsc/smsc9420.c:1466:2: note: remove the 'if' if its condition is always true
           if (netif_running(dev)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/smsc/smsc9420.c:1460:9: note: initialize the variable 'err' to silence this warning
           int err;
                  ^
                   = 0
   1 warning generated.

vim +1466 drivers/net/ethernet/smsc/smsc9420.c

2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1456  
7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1457  static int __maybe_unused smsc9420_resume(struct device *dev_d)
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1458  {
7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1459  	struct net_device *dev = dev_get_drvdata(dev_d);
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1460  	int err;
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1461  
7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1462  	pci_set_master(to_pci_dev(dev_d));
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1463  
7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1464  	device_wakeup_disable(dev_d);
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1465  
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11 @1466  	if (netif_running(dev)) {
b5a80837b7e125 drivers/net/ethernet/smsc/smsc9420.c Francois Romieu   2012-03-09  1467  		/* FIXME: gross. It looks like ancient PM relic.*/
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1468  		err = smsc9420_open(dev);
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1469  		netif_device_attach(dev);
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1470  	}
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1471  	return err;
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1472  }
2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1473  

---
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: 75347 bytes --]

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: use generic power management
  2020-07-02 20:08   ` kernel test robot
@ 2020-07-03  3:03     ` Vaibhav Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Vaibhav Gupta @ 2020-07-03  3:03 UTC (permalink / raw)
  To: kernel test robot
  Cc: Steve Glendinning, kbuild-all, Vaibhav Gupta, netdev,
	Linux Kernel Mailing List, clang-built-linux, Bjorn Helgaas,
	Jakub Kicinski, linux-kernel-mentees, David S. Miller

On Fri, 3 Jul 2020 at 01:38, kernel test robot <lkp@intel.com> wrote:
>
> Hi Vaibhav,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on linus/master]
> [also build test WARNING on v5.8-rc3 next-20200702]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use  as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:    https://github.com/0day-ci/linux/commits/Vaibhav-Gupta/smsc-use-generic-power-management/20200702-185914
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd77006e01b3198c75fb7819b3d0ff89709539bb
> config: x86_64-allyesconfig (attached as .config)
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 003a086ffc0d1affbb8300b36225fb8150a2d40a)
> 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 x86_64 cross compiling tool for clang build
>         # apt-get install binutils-x86-64-linux-gnu
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/net/ethernet/smsc/smsc9420.c:1466:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>            if (netif_running(dev)) {
>                ^~~~~~~~~~~~~~~~~~
>    drivers/net/ethernet/smsc/smsc9420.c:1471:9: note: uninitialized use occurs here
>            return err;
>                   ^~~
>    drivers/net/ethernet/smsc/smsc9420.c:1466:2: note: remove the 'if' if its condition is always true
>            if (netif_running(dev)) {
>            ^~~~~~~~~~~~~~~~~~~~~~~~
>    drivers/net/ethernet/smsc/smsc9420.c:1460:9: note: initialize the variable 'err' to silence this warning
>            int err;
>                   ^
>                    = 0
>    1 warning generated.
>
> vim +1466 drivers/net/ethernet/smsc/smsc9420.c
>
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1456
> 7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1457  static int __maybe_unused smsc9420_resume(struct device *dev_d)
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1458  {
> 7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1459          struct net_device *dev = dev_get_drvdata(dev_d);
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1460          int err;
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1461
> 7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1462          pci_set_master(to_pci_dev(dev_d));
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1463
> 7d465053ec82e2 drivers/net/ethernet/smsc/smsc9420.c Vaibhav Gupta     2020-07-02  1464          device_wakeup_disable(dev_d);
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1465
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11 @1466          if (netif_running(dev)) {
> b5a80837b7e125 drivers/net/ethernet/smsc/smsc9420.c Francois Romieu   2012-03-09  1467                  /* FIXME: gross. It looks like ancient PM relic.*/
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1468                  err = smsc9420_open(dev);
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1469                  netif_device_attach(dev);
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1470          }
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1471          return err;
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1472  }
> 2cb377283f3469 drivers/net/smsc9420.c               Steve Glendinning 2008-12-11  1473
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Fixed. Thanks!
-- Vaibhav Gupta
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2020-07-03  3:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 10:53 [Linux-kernel-mentees] [PATCH v1 0/2] smsc: use generic power management Vaibhav Gupta
2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 1/2] epic100: " Vaibhav Gupta
2020-07-02 10:53 ` [Linux-kernel-mentees] [PATCH v1 2/2] smsc9420: " Vaibhav Gupta
2020-07-02 20:08   ` kernel test robot
2020-07-03  3:03     ` Vaibhav Gupta

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