[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 05 Apr 2011 00:26:31 +0100
From: Ben Hutchings <bhutchings@...arflare.com>
To: David Miller <davem@...emloft.net>
Cc: netdev <netdev@...r.kernel.org>, linux-net-drivers@...arflare.com,
Stephen Hemminger <shemminger@...tta.com>,
Michał Mirosław <mirqus@...il.com>
Subject: Re: [PATCH net-next-2.6 5/6] ethtool: Change ETHTOOL_PHYS_ID
implementation to allow dropping RTNL
This reimplementation lets us blink LEDs on multiple device at the same
time, but that's pretty pointless. The nasty thing is we could try to
blink LEDs twice over on the same device, violating the rules that the
drivers depend on. So I think I need to add:
On Sun, 2011-04-03 at 20:53 +0100, Ben Hutchings wrote:
[...]
> @@ -1618,14 +1620,54 @@ out:
> static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
> {
static struct net_device *active_dev;
> struct ethtool_value id;
> + int rc;
>
> - if (!dev->ethtool_ops->phys_id)
> + if (!dev->ethtool_ops->set_phys_id && !dev->ethtool_ops->phys_id)
> return -EOPNOTSUPP;
if (active_dev)
return -EBUSY;
> if (copy_from_user(&id, useraddr, sizeof(id)))
> return -EFAULT;
>
> - return dev->ethtool_ops->phys_id(dev, id.data);
> + if (!dev->ethtool_ops->set_phys_id)
> + /* Do it the old way */
> + return dev->ethtool_ops->phys_id(dev, id.data);
> +
> + rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE);
> + if (rc && rc != -EINVAL)
> + return rc;
> +
active_dev = dev;
> + dev_hold(dev);
> + rtnl_unlock();
> +
> + if (rc == 0) {
> + /* Driver will handle this itself */
> + schedule_timeout_interruptible(
> + id.data ? id.data : MAX_SCHEDULE_TIMEOUT);
> + } else {
> + /* Driver expects to be called periodically */
> + do {
> + rtnl_lock();
> + rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ON);
> + rtnl_unlock();
> + if (rc)
> + break;
> + schedule_timeout_interruptible(HZ / 2);
> +
> + rtnl_lock();
> + rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_OFF);
> + rtnl_unlock();
> + if (rc)
> + break;
> + schedule_timeout_interruptible(HZ / 2);
> + } while (!signal_pending(current) &&
> + (id.data == 0 || --id.data != 0));
> + }
> +
> + rtnl_lock();
> + dev_put(dev);
active_dev = NULL;
> + (void)dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_INACTIVE);
> + return rc;
> }
>
> static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists