aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/forcedeth.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-01-07 06:12:05 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-09 19:20:29 -0500
commitdba5a68ae147d0672d4b9259f3ece37777f8b2fa (patch)
tree4126af0f0cbc00dcac3f1f7156a975916f124147 /drivers/net/forcedeth.c
parent14934efab62201c176c620bd598b34b59acb6796 (diff)
forcedeth: Do not use legacy PCI power management
The forcedeth driver uses the legacy PCI power management, so it has to do PCI-specific things in its ->suspend() and ->resume() callbacks and some of them are not done correctly. Convert forcedeth to the new PCI power management framework and make it let the PCI subsystem take care of all the PCI-specific aspects of device handling during system power transitions. Tested with nVidia Corporation MCP55 Ethernet (rev a2). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/forcedeth.c')
-rw-r--r--drivers/net/forcedeth.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index cd2d72d825d..af09296ef0d 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3949,6 +3949,7 @@ static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
3949 writel(flags, base + NvRegWakeUpFlags); 3949 writel(flags, base + NvRegWakeUpFlags);
3950 spin_unlock_irq(&np->lock); 3950 spin_unlock_irq(&np->lock);
3951 } 3951 }
3952 device_set_wakeup_enable(&np->pci_dev->dev, np->wolenabled);
3952 return 0; 3953 return 0;
3953} 3954}
3954 3955
@@ -5488,14 +5489,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5488 /* set mac address */ 5489 /* set mac address */
5489 nv_copy_mac_to_hw(dev); 5490 nv_copy_mac_to_hw(dev);
5490 5491
5491 /* Workaround current PCI init glitch: wakeup bits aren't
5492 * being set from PCI PM capability.
5493 */
5494 device_init_wakeup(&pci_dev->dev, 1);
5495
5496 /* disable WOL */ 5492 /* disable WOL */
5497 writel(0, base + NvRegWakeUpFlags); 5493 writel(0, base + NvRegWakeUpFlags);
5498 np->wolenabled = 0; 5494 np->wolenabled = 0;
5495 device_set_wakeup_enable(&pci_dev->dev, false);
5499 5496
5500 if (id->driver_data & DEV_HAS_POWER_CNTRL) { 5497 if (id->driver_data & DEV_HAS_POWER_CNTRL) {
5501 5498
@@ -5746,8 +5743,9 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
5746} 5743}
5747 5744
5748#ifdef CONFIG_PM 5745#ifdef CONFIG_PM
5749static int nv_suspend(struct pci_dev *pdev, pm_message_t state) 5746static int nv_suspend(struct device *device)
5750{ 5747{
5748 struct pci_dev *pdev = to_pci_dev(device);
5751 struct net_device *dev = pci_get_drvdata(pdev); 5749 struct net_device *dev = pci_get_drvdata(pdev);
5752 struct fe_priv *np = netdev_priv(dev); 5750 struct fe_priv *np = netdev_priv(dev);
5753 u8 __iomem *base = get_hwbase(dev); 5751 u8 __iomem *base = get_hwbase(dev);
@@ -5763,25 +5761,17 @@ static int nv_suspend(struct pci_dev *pdev, pm_message_t state)
5763 for (i = 0; i <= np->register_size/sizeof(u32); i++) 5761 for (i = 0; i <= np->register_size/sizeof(u32); i++)
5764 np->saved_config_space[i] = readl(base + i*sizeof(u32)); 5762 np->saved_config_space[i] = readl(base + i*sizeof(u32));
5765 5763
5766 pci_save_state(pdev);
5767 pci_enable_wake(pdev, pci_choose_state(pdev, state), np->wolenabled);
5768 pci_disable_device(pdev);
5769 pci_set_power_state(pdev, pci_choose_state(pdev, state));
5770 return 0; 5764 return 0;
5771} 5765}
5772 5766
5773static int nv_resume(struct pci_dev *pdev) 5767static int nv_resume(struct device *device)
5774{ 5768{
5769 struct pci_dev *pdev = to_pci_dev(device);
5775 struct net_device *dev = pci_get_drvdata(pdev); 5770 struct net_device *dev = pci_get_drvdata(pdev);
5776 struct fe_priv *np = netdev_priv(dev); 5771 struct fe_priv *np = netdev_priv(dev);
5777 u8 __iomem *base = get_hwbase(dev); 5772 u8 __iomem *base = get_hwbase(dev);
5778 int i, rc = 0; 5773 int i, rc = 0;
5779 5774
5780 pci_set_power_state(pdev, PCI_D0);
5781 pci_restore_state(pdev);
5782 /* ack any pending wake events, disable PME */
5783 pci_enable_wake(pdev, PCI_D0, 0);
5784
5785 /* restore non-pci configuration space */ 5775 /* restore non-pci configuration space */
5786 for (i = 0; i <= np->register_size/sizeof(u32); i++) 5776 for (i = 0; i <= np->register_size/sizeof(u32); i++)
5787 writel(np->saved_config_space[i], base+i*sizeof(u32)); 5777 writel(np->saved_config_space[i], base+i*sizeof(u32));
@@ -5800,6 +5790,9 @@ static int nv_resume(struct pci_dev *pdev)
5800 return rc; 5790 return rc;
5801} 5791}
5802 5792
5793static SIMPLE_DEV_PM_OPS(nv_pm_ops, nv_suspend, nv_resume);
5794#define NV_PM_OPS (&nv_pm_ops)
5795
5803static void nv_shutdown(struct pci_dev *pdev) 5796static void nv_shutdown(struct pci_dev *pdev)
5804{ 5797{
5805 struct net_device *dev = pci_get_drvdata(pdev); 5798 struct net_device *dev = pci_get_drvdata(pdev);
@@ -5822,15 +5815,13 @@ static void nv_shutdown(struct pci_dev *pdev)
5822 * only put the device into D3 if we really go for poweroff. 5815 * only put the device into D3 if we really go for poweroff.
5823 */ 5816 */
5824 if (system_state == SYSTEM_POWER_OFF) { 5817 if (system_state == SYSTEM_POWER_OFF) {
5825 if (pci_enable_wake(pdev, PCI_D3cold, np->wolenabled)) 5818 pci_wake_from_d3(pdev, np->wolenabled);
5826 pci_enable_wake(pdev, PCI_D3hot, np->wolenabled);
5827 pci_set_power_state(pdev, PCI_D3hot); 5819 pci_set_power_state(pdev, PCI_D3hot);
5828 } 5820 }
5829} 5821}
5830#else 5822#else
5831#define nv_suspend NULL 5823#define NV_PM_OPS NULL
5832#define nv_shutdown NULL 5824#define nv_shutdown NULL
5833#define nv_resume NULL
5834#endif /* CONFIG_PM */ 5825#endif /* CONFIG_PM */
5835 5826
5836static DEFINE_PCI_DEVICE_TABLE(pci_tbl) = { 5827static DEFINE_PCI_DEVICE_TABLE(pci_tbl) = {
@@ -6002,9 +5993,8 @@ static struct pci_driver driver = {
6002 .id_table = pci_tbl, 5993 .id_table = pci_tbl,
6003 .probe = nv_probe, 5994 .probe = nv_probe,
6004 .remove = __devexit_p(nv_remove), 5995 .remove = __devexit_p(nv_remove),
6005 .suspend = nv_suspend,
6006 .resume = nv_resume,
6007 .shutdown = nv_shutdown, 5996 .shutdown = nv_shutdown,
5997 .driver.pm = NV_PM_OPS,
6008}; 5998};
6009 5999
6010static int __init init_nic(void) 6000static int __init init_nic(void)