Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1271475 > unrolled thread
| Started by | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| First post | 2015-11-17 18:30 +0100 |
| Last post | 2015-11-18 10:20 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] dl2k: Implement suspend Ondrej Zary <linux@rainbow-software.org> - 2015-11-17 18:30 +0100
Re: [PATCH 3/3] dl2k: Implement suspend Francois Romieu <romieu@fr.zoreil.com> - 2015-11-18 00:00 +0100
Re: [PATCH 3/3] dl2k: Implement suspend Ondrej Zary <linux@rainbow-software.org> - 2015-11-18 10:20 +0100
| From | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| Date | 2015-11-17 18:30 +0100 |
| Subject | [PATCH 3/3] dl2k: Implement suspend |
| Message-ID | <qvSeT-81H-21@gated-at.bofh.it> |
Add suspend/resume support to dl2k driver.
Tested on Asus NX1101 (IP1000A) and D-Link DGE-550T (DL-2000).
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
drivers/net/ethernet/dlink/dl2k.c | 46 +++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index 9e9baa0..b53dfa7 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -1824,11 +1824,57 @@ rio_remove1 (struct pci_dev *pdev)
}
}
+#ifdef CONFIG_PM
+static int rio_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct netdev_private *np = netdev_priv(dev);
+
+ pci_save_state(pdev);
+
+ if (netif_running(dev)) {
+ netif_device_detach(dev);
+ del_timer_sync(&np->timer);
+ rio_hw_stop(dev);
+ free_list(dev);
+ }
+
+ pci_set_power_state(pdev, PCI_D3hot);
+
+ return 0;
+}
+
+static int rio_resume(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct netdev_private *np = netdev_priv(dev);
+
+ pci_set_power_state(pdev, PCI_D0);
+ pci_restore_state(pdev);
+
+ if (netif_running(dev)) {
+ alloc_list(dev);
+ rio_hw_init(dev);
+ np->timer.expires = jiffies + 1 * HZ;
+ add_timer(&np->timer);
+ netif_device_attach(dev);
+ dl2k_enable_int(np);
+ }
+
+ return 0;
+}
+
+#endif /* CONFIG_PM */
+
static struct pci_driver rio_driver = {
.name = "dl2k",
.id_table = rio_pci_tbl,
.probe = rio_probe1,
.remove = rio_remove1,
+#ifdef CONFIG_PM
+ .suspend = rio_suspend,
+ .resume = rio_resume,
+#endif /* CONFIG_PM */
};
module_pci_driver(rio_driver);
--
Ondrej Zary
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Francois Romieu <romieu@fr.zoreil.com> |
|---|---|
| Date | 2015-11-18 00:00 +0100 |
| Message-ID | <qvXoe-2MS-15@gated-at.bofh.it> |
| In reply to | #1271475 |
Ondrej Zary <linux@rainbow-software.org> :
[...]
> diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
> index 9e9baa0..b53dfa7 100644
> --- a/drivers/net/ethernet/dlink/dl2k.c
> +++ b/drivers/net/ethernet/dlink/dl2k.c
> @@ -1824,11 +1824,57 @@ rio_remove1 (struct pci_dev *pdev)
> }
> }
>
> +#ifdef CONFIG_PM
> +static int rio_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct netdev_private *np = netdev_priv(dev);
> +
> + pci_save_state(pdev);
Cargo-cultism ?
> +
> + if (netif_running(dev)) {
> + netif_device_detach(dev);
> + del_timer_sync(&np->timer);
> + rio_hw_stop(dev);
> + free_list(dev);
If free_list is used here, so must alloc_list be in resume, whence
an extra failure opportunity.
You may not need to free both Tx and Rx here.
[...]
> static struct pci_driver rio_driver = {
> .name = "dl2k",
> .id_table = rio_pci_tbl,
> .probe = rio_probe1,
> .remove = rio_remove1,
> +#ifdef CONFIG_PM
> + .suspend = rio_suspend,
> + .resume = rio_resume,
> +#endif /* CONFIG_PM */
It looks a bit old school.
See Documentation/power/pci.txt and drivers/net/ethernet/via/via-rhine.c
for an instance of SIMPLE_DEV_PM_OPS.
At some point you'll probably support runtime power management though.
--
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ondrej Zary <linux@rainbow-software.org> |
|---|---|
| Date | 2015-11-18 10:20 +0100 |
| Message-ID | <qw74e-WO-37@gated-at.bofh.it> |
| In reply to | #1271719 |
On Tuesday 17 November 2015, Francois Romieu wrote:
> Ondrej Zary <linux@rainbow-software.org> :
> [...]
>
> > diff --git a/drivers/net/ethernet/dlink/dl2k.c
> > b/drivers/net/ethernet/dlink/dl2k.c index 9e9baa0..b53dfa7 100644
> > --- a/drivers/net/ethernet/dlink/dl2k.c
> > +++ b/drivers/net/ethernet/dlink/dl2k.c
> > @@ -1824,11 +1824,57 @@ rio_remove1 (struct pci_dev *pdev)
> > }
> > }
> >
> > +#ifdef CONFIG_PM
> > +static int rio_suspend(struct pci_dev *pdev, pm_message_t state)
> > +{
> > + struct net_device *dev = pci_get_drvdata(pdev);
> > + struct netdev_private *np = netdev_priv(dev);
> > +
> > + pci_save_state(pdev);
>
> Cargo-cultism ?
>
> > +
> > + if (netif_running(dev)) {
> > + netif_device_detach(dev);
> > + del_timer_sync(&np->timer);
> > + rio_hw_stop(dev);
> > + free_list(dev);
>
> If free_list is used here, so must alloc_list be in resume, whence
> an extra failure opportunity.
>
> You may not need to free both Tx and Rx here.
I'll better drop the free_list/alloc_list from suspend/resume (as you
suggested before).
> [...]
>
> > static struct pci_driver rio_driver = {
> > .name = "dl2k",
> > .id_table = rio_pci_tbl,
> > .probe = rio_probe1,
> > .remove = rio_remove1,
> > +#ifdef CONFIG_PM
> > + .suspend = rio_suspend,
> > + .resume = rio_resume,
> > +#endif /* CONFIG_PM */
>
> It looks a bit old school.
>
> See Documentation/power/pci.txt and drivers/net/ethernet/via/via-rhine.c
> for an instance of SIMPLE_DEV_PM_OPS.
>
> At some point you'll probably support runtime power management though.
Thanks for suggestion, I've been looking at the wrong drivers as none of them
used dev_pm_ops.
--
Ondrej Zary
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web