Commit 71f711a4 authored by Michal Kubecek's avatar Michal Kubecek Committed by David S. Miller

via-velocity: allow nesting of ethtool_ops begin() and complete()

Unlike most networking drivers using begin() and complete() ethtool_ops
callbacks to resume a device which is down and suspend it again when done,
via-velocity does not use standard refcounted infrastructure but sets
device sleep state directly.

With the introduction of netlink ethtool interface, we may have nested
begin-complete blocks so that inner complete() would put the device back to
sleep for the rest of the outer block.

To avoid rewriting an old and not very actively developed driver, just add
a nesting counter and only perform resume and suspend on the outermost
level.
Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a69faa09
...@@ -3257,12 +3257,16 @@ static struct platform_driver velocity_platform_driver = { ...@@ -3257,12 +3257,16 @@ static struct platform_driver velocity_platform_driver = {
* @dev: network device * @dev: network device
* *
* Called before an ethtool operation. We need to make sure the * Called before an ethtool operation. We need to make sure the
* chip is out of D3 state before we poke at it. * chip is out of D3 state before we poke at it. In case of ethtool
* ops nesting, only wake the device up in the outermost block.
*/ */
static int velocity_ethtool_up(struct net_device *dev) static int velocity_ethtool_up(struct net_device *dev)
{ {
struct velocity_info *vptr = netdev_priv(dev); struct velocity_info *vptr = netdev_priv(dev);
if (!netif_running(dev))
if (vptr->ethtool_ops_nesting == U32_MAX)
return -EBUSY;
if (!vptr->ethtool_ops_nesting++ && !netif_running(dev))
velocity_set_power_state(vptr, PCI_D0); velocity_set_power_state(vptr, PCI_D0);
return 0; return 0;
} }
...@@ -3272,12 +3276,14 @@ static int velocity_ethtool_up(struct net_device *dev) ...@@ -3272,12 +3276,14 @@ static int velocity_ethtool_up(struct net_device *dev)
* @dev: network device * @dev: network device
* *
* Called after an ethtool operation. Restore the chip back to D3 * Called after an ethtool operation. Restore the chip back to D3
* state if it isn't running. * state if it isn't running. In case of ethtool ops nesting, only
* put the device to sleep in the outermost block.
*/ */
static void velocity_ethtool_down(struct net_device *dev) static void velocity_ethtool_down(struct net_device *dev)
{ {
struct velocity_info *vptr = netdev_priv(dev); struct velocity_info *vptr = netdev_priv(dev);
if (!netif_running(dev))
if (!--vptr->ethtool_ops_nesting && !netif_running(dev))
velocity_set_power_state(vptr, PCI_D3hot); velocity_set_power_state(vptr, PCI_D3hot);
} }
......
...@@ -1483,6 +1483,7 @@ struct velocity_info { ...@@ -1483,6 +1483,7 @@ struct velocity_info {
struct velocity_context context; struct velocity_context context;
u32 ticks; u32 ticks;
u32 ethtool_ops_nesting;
u8 rev_id; u8 rev_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment