mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net 0/3] r8152: patches for autosuspend
@ 2014-10-29  3:12 Hayes Wang
  2014-10-29  3:12 ` [PATCH net 1/3] r8152: clear SELECTIVE_SUSPEND when autoresuming Hayes Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hayes Wang @ 2014-10-29  3:12 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

There are unexpected processes when enabling autosuspend.
These patches are used to fix them.

Hayes Wang (3):
  r8152: clear SELECTIVE_SUSPEND when autoresuming
  r8152: reset tp->speed before autoresuming in open function
  r8152: check WORK_ENABLE in suspend function

 drivers/net/usb/r8152.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/3] r8152: clear SELECTIVE_SUSPEND when autoresuming
  2014-10-29  3:12 [PATCH net 0/3] r8152: patches for autosuspend Hayes Wang
@ 2014-10-29  3:12 ` Hayes Wang
  2014-10-29  3:12 ` [PATCH net 2/3] r8152: reset tp->speed before autoresuming in open function Hayes Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hayes Wang @ 2014-10-29  3:12 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

The flag of SELECTIVE_SUSPEND should be cleared when autoresuming.
Otherwise, when the system suspend and resume occur, it may have
the wrong flow.

Besides, because the flag of SELECTIVE_SUSPEND couldn't be used
to check if the hw enables the relative feature, it should alwayes
be disabled in close().

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e3d84c3..a17ca58 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2955,10 +2955,7 @@ static int rtl8152_close(struct net_device *netdev)
 		 * be disable when autoresume occurs, because the
 		 * netif_running() would be false.
 		 */
-		if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
-			rtl_runtime_suspend_enable(tp, false);
-			clear_bit(SELECTIVE_SUSPEND, &tp->flags);
-		}
+		rtl_runtime_suspend_enable(tp, false);
 
 		tasklet_disable(&tp->tl);
 		tp->rtl_ops.down(tp);
@@ -3253,6 +3250,8 @@ static int rtl8152_resume(struct usb_interface *intf)
 			set_bit(WORK_ENABLE, &tp->flags);
 		}
 		usb_submit_urb(tp->intr_urb, GFP_KERNEL);
+	} else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
+		clear_bit(SELECTIVE_SUSPEND, &tp->flags);
 	}
 
 	mutex_unlock(&tp->control);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 2/3] r8152: reset tp->speed before autoresuming in open function
  2014-10-29  3:12 [PATCH net 0/3] r8152: patches for autosuspend Hayes Wang
  2014-10-29  3:12 ` [PATCH net 1/3] r8152: clear SELECTIVE_SUSPEND when autoresuming Hayes Wang
@ 2014-10-29  3:12 ` Hayes Wang
  2014-10-29  3:12 ` [PATCH net 3/3] r8152: check WORK_ENABLE in suspend function Hayes Wang
  2014-10-30 19:49 ` [PATCH net 0/3] r8152: patches for autosuspend David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Hayes Wang @ 2014-10-29  3:12 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

If (tp->speed & LINK_STATUS) is not zero, the rtl8152_resume()
would call rtl_start_rx() before enabling the tx/rx. Avoid this
by resetting it to zero.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a17ca58..f224231 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2891,6 +2891,9 @@ static int rtl8152_open(struct net_device *netdev)
 	if (res)
 		goto out;
 
+	/* set speed to 0 to avoid autoresume try to submit rx */
+	tp->speed = 0;
+
 	res = usb_autopm_get_interface(tp->intf);
 	if (res < 0) {
 		free_all_mem(tp);
@@ -2904,6 +2907,8 @@ static int rtl8152_open(struct net_device *netdev)
 		clear_bit(WORK_ENABLE, &tp->flags);
 		usb_kill_urb(tp->intr_urb);
 		cancel_delayed_work_sync(&tp->schedule);
+
+		/* disable the tx/rx, if the workqueue has enabled them. */
 		if (tp->speed & LINK_STATUS)
 			tp->rtl_ops.disable(tp);
 	}
-- 
1.9.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 3/3] r8152: check WORK_ENABLE in suspend function
  2014-10-29  3:12 [PATCH net 0/3] r8152: patches for autosuspend Hayes Wang
  2014-10-29  3:12 ` [PATCH net 1/3] r8152: clear SELECTIVE_SUSPEND when autoresuming Hayes Wang
  2014-10-29  3:12 ` [PATCH net 2/3] r8152: reset tp->speed before autoresuming in open function Hayes Wang
@ 2014-10-29  3:12 ` Hayes Wang
  2014-10-30 19:49 ` [PATCH net 0/3] r8152: patches for autosuspend David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Hayes Wang @ 2014-10-29  3:12 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Avoid unnecessary behavior when autosuspend occurs during open().
The relative processes should only be run after finishing open().

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f224231..ca3c5d5 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3207,7 +3207,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
 		netif_device_detach(netdev);
 	}
 
-	if (netif_running(netdev)) {
+	if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
 		clear_bit(WORK_ENABLE, &tp->flags);
 		usb_kill_urb(tp->intr_urb);
 		tasklet_disable(&tp->tl);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/3] r8152: patches for autosuspend
  2014-10-29  3:12 [PATCH net 0/3] r8152: patches for autosuspend Hayes Wang
                   ` (2 preceding siblings ...)
  2014-10-29  3:12 ` [PATCH net 3/3] r8152: check WORK_ENABLE in suspend function Hayes Wang
@ 2014-10-30 19:49 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-10-30 19:49 UTC (permalink / raw)
  To: hayeswang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb

From: Hayes Wang <hayeswang@realtek.com>
Date: Wed, 29 Oct 2014 11:12:14 +0800

> There are unexpected processes when enabling autosuspend.
> These patches are used to fix them.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-30 19:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29  3:12 [PATCH net 0/3] r8152: patches for autosuspend Hayes Wang
2014-10-29  3:12 ` [PATCH net 1/3] r8152: clear SELECTIVE_SUSPEND when autoresuming Hayes Wang
2014-10-29  3:12 ` [PATCH net 2/3] r8152: reset tp->speed before autoresuming in open function Hayes Wang
2014-10-29  3:12 ` [PATCH net 3/3] r8152: check WORK_ENABLE in suspend function Hayes Wang
2014-10-30 19:49 ` [PATCH net 0/3] r8152: patches for autosuspend David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®