Message ID | CAPopfEXz+HPdwWh_GQ2WzMnHh5DuXTse78NAU=-iN15wv-0C5g@mail.gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
Oliver, I have a couple of questions about this: - Does the macro as implemented properly communicate the intent as you requested? - You made a comment about this being useful outside of usbnet. The only appropriate place that I could identify for this would be all the way up in usb.h. Do you think something at that level is more appropriate? Jim -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Am Montag, 5. September 2011, 18:36:54 schrieb Jim Wylder: > Oliver, > > I have a couple of questions about this: > > - Does the macro as implemented properly communicate the intent as you > requested? Yes. > - You made a comment about this being useful outside of usbnet. The > only appropriate place that I could identify for this would be all the > way up in usb.h. Do you think something at that level is more > appropriate? It is specific to usb. It belongs in the core device code. Regards Oliver
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index ce395fe..7dcef05 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -81,6 +81,19 @@ /*-------------------------------------------------------------------------*/ +/* When power management is configured, usb_autopm_get_interface_async() + * will return -EINPROGRESS to signify that the interface was already + * resuming at the time that the function was called. In our case + * (all cases?) this not an error condition. + * */ +#ifdef CONFIG_PM +#define USBNET_PM_INTF_ALREADY_RESUMING(x) (x == -EINPROGRESS) +#else +#define USBNET_PM_INTF_ALREADY_RESUMING(x) 0 +#endif + +/*-------------------------------------------------------------------------*/ + // randomly generated ethernet address static u8 node_id [ETH_ALEN]; @@ -1042,6 +1055,7 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout); /*-------------------------------------------------------------------------*/ + netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, struct net_device *net) { @@ -1105,7 +1119,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, spin_lock_irqsave(&dev->txq.lock, flags); retval = usb_autopm_get_interface_async(dev->intf); - if (retval < 0) { + if (retval < 0 && !USBNET_PM_INTF_ALREADY_RESUMING(retval)) { spin_unlock_irqrestore(&dev->txq.lock, flags); goto drop; }
When calling pm_runtime_get, usb_autopm_get_interface_async treats a return value of -EINPROGRESS as a success and increments the usage count. Since the interface is resuming, it is safe for usbnet_start_xmit to submit the urb. If instead, usbnet_start_xmit treats this as an error the packet will be dropped. Additionally, a corresponding tx_complete will not run to offset the earlier increment of the usage count from the call to usb_autopm_get_interface_async. Signed-off-by: James Wylder <james.wylder@motorola.com> --- drivers/net/usb/usbnet.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)