Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1664531

[PATCH net-next v2 2/2] r8152: move calling delay_autosuspend function

From Hayes Wang <hayeswang@realtek.com>
Newsgroups linux.kernel
Subject [PATCH net-next v2 2/2] r8152: move calling delay_autosuspend function
Date 2017-06-13 09:20 +0200
Message-ID <tROhj-4Yo-9@gated-at.bofh.it> (permalink)
References <tRsTw-8al-9@gated-at.bofh.it> <tROhj-4Yo-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/net/usb/r8152.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2d238b5..b916418 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3752,13 +3752,6 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
 	if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
 		u32 rcr = 0;
 
-		if (delay_autosuspend(tp)) {
-			clear_bit(SELECTIVE_SUSPEND, &tp->flags);
-			smp_mb__after_atomic();
-			ret = -EBUSY;
-			goto out1;
-		}
-
 		if (netif_carrier_ok(netdev)) {
 			u32 ocp_data;
 
@@ -3792,6 +3785,11 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
 			ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, rcr);
 			napi_enable(napi);
 		}
+
+		if (delay_autosuspend(tp)) {
+			rtl8152_runtime_resume(tp);
+			ret = -EBUSY;
+		}
 	}
 
 out1:
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next 0/2] r8152: adjust runtime suspend/resume Hayes Wang <hayeswang@realtek.com> - 2017-06-12 10:30 +0200
  [PATCH net-next v2 2/2] r8152: move calling delay_autosuspend function Hayes Wang <hayeswang@realtek.com> - 2017-06-13 09:20 +0200
  [PATCH net-next v2 1/2] r8152: split rtl8152_resume function Hayes Wang <hayeswang@realtek.com> - 2017-06-13 09:20 +0200
  [PATCH net-next v2 0/2] r8152: adjust runtime suspend/resume Hayes Wang <hayeswang@realtek.com> - 2017-06-13 09:20 +0200
    Re: [PATCH net-next v2 0/2] r8152: adjust runtime suspend/resume David Miller <davem@davemloft.net> - 2017-06-13 19:10 +0200
      RE: [PATCH net-next v2 0/2] r8152: adjust runtime suspend/resume Hayes Wang <hayeswang@realtek.com> - 2017-06-16 05:30 +0200
        Re: [PATCH net-next v2 0/2] r8152: adjust runtime suspend/resume David Miller <davem@davemloft.net> - 2017-06-16 17:40 +0200

csiph-web