Skip to content

Commit

Permalink
r8152: return -EBUSY for runtime suspend
Browse files Browse the repository at this point in the history
Remove calling cancel_delayed_work_sync() for runtime suspend,
because it would cause dead lock. Instead, return -EBUSY to
avoid the device enters suspending if the net is running and
the delayed work is pending or running. The delayed work would
try to wake up the device later, so the suspending is not
necessary.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
hayeswang authored and David S. Miller committed Oct 18, 2014
1 parent d8f00d2 commit 6cc69f2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions drivers/net/usb/r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -3189,31 +3189,39 @@ static void r8153_init(struct r8152 *tp)
static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
{
struct r8152 *tp = usb_get_intfdata(intf);
struct net_device *netdev = tp->netdev;
int ret = 0;

mutex_lock(&tp->control);

if (PMSG_IS_AUTO(message))
if (PMSG_IS_AUTO(message)) {
if (netif_running(netdev) && work_busy(&tp->schedule.work)) {
ret = -EBUSY;
goto out1;
}

set_bit(SELECTIVE_SUSPEND, &tp->flags);
else
netif_device_detach(tp->netdev);
} else {
netif_device_detach(netdev);
}

if (netif_running(tp->netdev)) {
if (netif_running(netdev)) {
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
cancel_delayed_work_sync(&tp->schedule);
tasklet_disable(&tp->tl);
if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
rtl_stop_rx(tp);
rtl_runtime_suspend_enable(tp, true);
} else {
cancel_delayed_work_sync(&tp->schedule);
tp->rtl_ops.down(tp);
}
tasklet_enable(&tp->tl);
}

out1:
mutex_unlock(&tp->control);

return 0;
return ret;
}

static int rtl8152_resume(struct usb_interface *intf)
Expand Down

0 comments on commit 6cc69f2

Please sign in to comment.