aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2017-06-13 03:14:40 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:37:13 -0400
commitbd8829822204debbb2dd38a5b052ef7663e618cc (patch)
tree12f9199896a4413b366ca7082bb01deec4562a21
parent21cbd0ecad7943bbd4f7d10efaade0380637d4a0 (diff)
r8152: move calling delay_autosuspend function
Move calling delay_autosuspend() in rtl8152_runtime_suspend(). Calling delay_autosuspend() as late as possible. The original flows are 1. check if the driver/device is busy now. 2. set wake events. 3. enter runtime suspend. If the wake event occurs between (1) and (2), the device may miss it. Besides, to avoid the runtime resume occurs after runtime suspend immediately, move the checking to the end of rtl8152_runtime_suspend(). Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/r8152.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index c7663e10707c..8bc4573e0cd4 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4355,13 +4355,6 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
4355 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { 4355 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
4356 u32 rcr = 0; 4356 u32 rcr = 0;
4357 4357
4358 if (delay_autosuspend(tp)) {
4359 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
4360 smp_mb__after_atomic();
4361 ret = -EBUSY;
4362 goto out1;
4363 }
4364
4365 if (netif_carrier_ok(netdev)) { 4358 if (netif_carrier_ok(netdev)) {
4366 u32 ocp_data; 4359 u32 ocp_data;
4367 4360
@@ -4395,6 +4388,11 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
4395 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr); 4388 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
4396 napi_enable(napi); 4389 napi_enable(napi);
4397 } 4390 }
4391
4392 if (delay_autosuspend(tp)) {
4393 rtl8152_runtime_resume(tp);
4394 ret = -EBUSY;
4395 }
4398 } 4396 }
4399 4397
4400out1: 4398out1: