Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1663314 > unrolled thread
| Started by | Hayes Wang <hayeswang@realtek.com> |
|---|---|
| First post | 2017-06-12 10:30 +0200 |
| Last post | 2017-06-13 04:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH net-next 1/2] r8152: split rtl8152_resume function Hayes Wang <hayeswang@realtek.com> - 2017-06-12 10:30 +0200
Re: [PATCH net-next 1/2] r8152: split rtl8152_resume function Oliver Neukum <oneukum@suse.com> - 2017-06-12 14:40 +0200
RE: [PATCH net-next 1/2] r8152: split rtl8152_resume function Hayes Wang <hayeswang@realtek.com> - 2017-06-13 04:30 +0200
| From | Hayes Wang <hayeswang@realtek.com> |
|---|---|
| Date | 2017-06-12 10:30 +0200 |
| Subject | [PATCH net-next 1/2] r8152: split rtl8152_resume function |
| Message-ID | <tRsTw-8al-7@gated-at.bofh.it> |
Split rtl8152_resume() into rtl8152_runtime_resume() and
rtl8152_system_resume().
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
drivers/net/usb/r8152.c | 99 ++++++++++++++++++++++++++++++-------------------
1 file changed, 61 insertions(+), 38 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 5a02053..3257955 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3686,6 +3686,61 @@ static bool delay_autosuspend(struct r8152 *tp)
return false;
}
+static int rtl8152_runtime_resume(struct r8152 *tp)
+{
+ struct net_device *netdev = tp->netdev;
+
+ if (netif_running(netdev) && netdev->flags & IFF_UP) {
+ struct napi_struct *napi = &tp->napi;
+
+ tp->rtl_ops.autosuspend_en(tp, false);
+ napi_disable(napi);
+ set_bit(WORK_ENABLE, &tp->flags);
+
+ if (netif_carrier_ok(netdev)) {
+ if (rtl8152_get_speed(tp) & LINK_STATUS) {
+ rtl_start_rx(tp);
+ } else {
+ netif_carrier_off(netdev);
+ tp->rtl_ops.disable(tp);
+ netif_info(tp, link, netdev, "linking down\n");
+ }
+ }
+
+ napi_enable(napi);
+ clear_bit(SELECTIVE_SUSPEND, &tp->flags);
+ smp_mb__after_atomic();
+
+ if (!list_empty(&tp->rx_done))
+ napi_schedule(&tp->napi);
+
+ usb_submit_urb(tp->intr_urb, GFP_KERNEL);
+ } else {
+ if (netdev->flags & IFF_UP)
+ tp->rtl_ops.autosuspend_en(tp, false);
+
+ clear_bit(SELECTIVE_SUSPEND, &tp->flags);
+ }
+
+ return 0;
+}
+
+static int rtl8152_system_resume(struct r8152 *tp)
+{
+ struct net_device *netdev = tp->netdev;
+
+ netif_device_attach(netdev);
+
+ if (netif_running(netdev) && netdev->flags & IFF_UP) {
+ tp->rtl_ops.up(tp);
+ netif_carrier_off(netdev);
+ set_bit(WORK_ENABLE, &tp->flags);
+ usb_submit_urb(tp->intr_urb, GFP_KERNEL);
+ }
+
+ return 0;
+}
+
static int rtl8152_runtime_suspend(struct r8152 *tp)
{
struct net_device *netdev = tp->netdev;
@@ -3784,50 +3839,18 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
static int rtl8152_resume(struct usb_interface *intf)
{
struct r8152 *tp = usb_get_intfdata(intf);
- struct net_device *netdev = tp->netdev;
+ int ret;
mutex_lock(&tp->control);
- if (!test_bit(SELECTIVE_SUSPEND, &tp->flags))
- netif_device_attach(netdev);
-
- if (netif_running(netdev) && netdev->flags & IFF_UP) {
- if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
- struct napi_struct *napi = &tp->napi;
-
- tp->rtl_ops.autosuspend_en(tp, false);
- napi_disable(napi);
- set_bit(WORK_ENABLE, &tp->flags);
- if (netif_carrier_ok(netdev)) {
- if (rtl8152_get_speed(tp) & LINK_STATUS) {
- rtl_start_rx(tp);
- } else {
- netif_carrier_off(netdev);
- tp->rtl_ops.disable(tp);
- netif_info(tp, link, netdev,
- "linking down\n");
- }
- }
- napi_enable(napi);
- clear_bit(SELECTIVE_SUSPEND, &tp->flags);
- smp_mb__after_atomic();
- if (!list_empty(&tp->rx_done))
- napi_schedule(&tp->napi);
- } else {
- tp->rtl_ops.up(tp);
- netif_carrier_off(netdev);
- set_bit(WORK_ENABLE, &tp->flags);
- }
- usb_submit_urb(tp->intr_urb, GFP_KERNEL);
- } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
- if (netdev->flags & IFF_UP)
- tp->rtl_ops.autosuspend_en(tp, false);
- clear_bit(SELECTIVE_SUSPEND, &tp->flags);
- }
+ if (test_bit(SELECTIVE_SUSPEND, &tp->flags))
+ ret = rtl8152_runtime_resume(tp);
+ else
+ ret = rtl8152_system_resume(tp);
mutex_unlock(&tp->control);
- return 0;
+ return ret;
}
static int rtl8152_reset_resume(struct usb_interface *intf)
--
2.7.4
[toc] | [next] | [standalone]
| From | Oliver Neukum <oneukum@suse.com> |
|---|---|
| Date | 2017-06-12 14:40 +0200 |
| Message-ID | <tRwNr-26c-11@gated-at.bofh.it> |
| In reply to | #1663314 |
Am Montag, den 12.06.2017, 16:21 +0800 schrieb Hayes Wang:
> Split rtl8152_resume() into rtl8152_runtime_resume() and
> rtl8152_system_resume().
>
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
> drivers/net/usb/r8152.c | 99 ++++++++++++++++++++++++++++++-------------------
> 1 file changed, 61 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 5a02053..3257955 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -3686,6 +3686,61 @@ static bool delay_autosuspend(struct r8152 *tp)
> return false;
> }
>
> +static int rtl8152_runtime_resume(struct r8152 *tp)
> +{
> + struct net_device *netdev = tp->netdev;
> +
> + if (netif_running(netdev) && netdev->flags & IFF_UP) {
> + struct napi_struct *napi = &tp->napi;
> +
> + tp->rtl_ops.autosuspend_en(tp, false);
> + napi_disable(napi);
> + set_bit(WORK_ENABLE, &tp->flags);
> +
> + if (netif_carrier_ok(netdev)) {
> + if (rtl8152_get_speed(tp) & LINK_STATUS) {
> + rtl_start_rx(tp);
> + } else {
> + netif_carrier_off(netdev);
> + tp->rtl_ops.disable(tp);
> + netif_info(tp, link, netdev, "linking down\n");
> + }
> + }
> +
> + napi_enable(napi);
> + clear_bit(SELECTIVE_SUSPEND, &tp->flags);
> + smp_mb__after_atomic();
> +
> + if (!list_empty(&tp->rx_done))
> + napi_schedule(&tp->napi);
> +
> + usb_submit_urb(tp->intr_urb, GFP_KERNEL);
If you ever built a device with included storage, this can deadlock,
as you may want to wake up a device for memory that is needed to wake
up a device. Use GFP_NOIO in resume() and reset_resume(), always.
Regards
Oliver
[toc] | [prev] | [next] | [standalone]
| From | Hayes Wang <hayeswang@realtek.com> |
|---|---|
| Date | 2017-06-13 04:30 +0200 |
| Message-ID | <tRJKG-26m-3@gated-at.bofh.it> |
| In reply to | #1663467 |
Oliver Neukum [mailto:oneukum@suse.com] > Sent: Monday, June 12, 2017 8:33 PM [...] > > + usb_submit_urb(tp->intr_urb, GFP_KERNEL); > > If you ever built a device with included storage, this can deadlock, > as you may want to wake up a device for memory that is needed to wake > up a device. Use GFP_NOIO in resume() and reset_resume(), always. I would change it. Thanks. Best Regards, Hayes
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web