Commit 65841fd5 authored by Ming Lei's avatar Ming Lei Committed by David S. Miller

usbnet: handle remote wakeup asap

If usbnet is resumed by remote wakeup, generally there are
some packets comming to be handled, so allocate and submit
rx URBs in usbnet_resume to avoid delays introduced by tasklet.
Otherwise, usbnet may have been runtime suspended before the
usbnet_bh is executed to schedule Rx URBs.

Without the patch, usbnet can't recieve any packets from peer
in runtime suspend state if runtime PM is enabled and
autosuspend_delay is set as zero.
Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
Acked-by: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5eeb3132
...@@ -1204,6 +1204,21 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, ...@@ -1204,6 +1204,21 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
} }
EXPORT_SYMBOL_GPL(usbnet_start_xmit); EXPORT_SYMBOL_GPL(usbnet_start_xmit);
static void rx_alloc_submit(struct usbnet *dev, gfp_t flags)
{
struct urb *urb;
int i;
/* don't refill the queue all at once */
for (i = 0; i < 10 && dev->rxq.qlen < RX_QLEN(dev); i++) {
urb = usb_alloc_urb(0, flags);
if (urb != NULL) {
if (rx_submit(dev, urb, flags) == -ENOLINK)
return;
}
}
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
// tasklet (work deferred from completions, in_irq) or timer // tasklet (work deferred from completions, in_irq) or timer
...@@ -1243,26 +1258,14 @@ static void usbnet_bh (unsigned long param) ...@@ -1243,26 +1258,14 @@ static void usbnet_bh (unsigned long param)
!timer_pending (&dev->delay) && !timer_pending (&dev->delay) &&
!test_bit (EVENT_RX_HALT, &dev->flags)) { !test_bit (EVENT_RX_HALT, &dev->flags)) {
int temp = dev->rxq.qlen; int temp = dev->rxq.qlen;
int qlen = RX_QLEN (dev);
if (temp < qlen) { if (temp < RX_QLEN(dev)) {
struct urb *urb; rx_alloc_submit(dev, GFP_ATOMIC);
int i;
// don't refill the queue all at once
for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
urb = usb_alloc_urb (0, GFP_ATOMIC);
if (urb != NULL) {
if (rx_submit (dev, urb, GFP_ATOMIC) ==
-ENOLINK)
return;
}
}
if (temp != dev->rxq.qlen) if (temp != dev->rxq.qlen)
netif_dbg(dev, link, dev->net, netif_dbg(dev, link, dev->net,
"rxqlen %d --> %d\n", "rxqlen %d --> %d\n",
temp, dev->rxq.qlen); temp, dev->rxq.qlen);
if (dev->rxq.qlen < qlen) if (dev->rxq.qlen < RX_QLEN(dev))
tasklet_schedule (&dev->bh); tasklet_schedule (&dev->bh);
} }
if (dev->txq.qlen < TX_QLEN (dev)) if (dev->txq.qlen < TX_QLEN (dev))
...@@ -1572,6 +1575,13 @@ int usbnet_resume (struct usb_interface *intf) ...@@ -1572,6 +1575,13 @@ int usbnet_resume (struct usb_interface *intf)
spin_unlock_irq(&dev->txq.lock); spin_unlock_irq(&dev->txq.lock);
if (test_bit(EVENT_DEV_OPEN, &dev->flags)) { if (test_bit(EVENT_DEV_OPEN, &dev->flags)) {
/* handle remote wakeup ASAP */
if (!dev->wait &&
netif_device_present(dev->net) &&
!timer_pending(&dev->delay) &&
!test_bit(EVENT_RX_HALT, &dev->flags))
rx_alloc_submit(dev, GFP_KERNEL);
if (!(dev->txq.qlen >= TX_QLEN(dev))) if (!(dev->txq.qlen >= TX_QLEN(dev)))
netif_tx_wake_all_queues(dev->net); netif_tx_wake_all_queues(dev->net);
tasklet_schedule (&dev->bh); tasklet_schedule (&dev->bh);
......
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