netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Hayes Wang <hayeswang@realtek.com>
Cc: <netdev@vger.kernel.org>, <nic_swsd@realtek.com>,
	<linux-kernel@vger.kernel.org>, <linux-usb@vger.kernel.org>
Subject: Re: [PATCH net] r8152: use cancel_delayed_work for runtime suspend
Date: Fri, 17 Oct 2014 09:42:02 +0200	[thread overview]
Message-ID: <87zjcvgn1x.fsf@nemi.mork.no> (raw)
In-Reply-To: <1394712342-15778-64-Taiwan-albertk@realtek.com> (Hayes Wang's message of "Fri, 17 Oct 2014 13:55:29 +0800")

Hayes Wang <hayeswang@realtek.com> writes:

> It would cause dead lock for runtime suspend, when the workqueue
> is running and runtime suspend occurs before the workqueue wakes
> up the device. The rtl8152_suspend() waits the workqueue to finish
> because of calling cancel_delayed_work_sync(). The workqueue waits
> the suspend function to finish for waking up the device because of
> calling usb_autopm_get_interface().
>
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
>  drivers/net/usb/r8152.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 864159e..7d4e55a 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -3200,12 +3200,13 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
>  	if (netif_running(tp->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)) {
> +			cancel_delayed_work(&tp->schedule);
>  			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);

This looks strange to me. The delayed work will cause an immediate
resume due to the usb_autopm_get_interface() it starts with.  Wouldn't
it be better to just prevent runtime suspending by returning -EBUSY if
there is any delayed work scheduled?


Bjørn

  reply	other threads:[~2014-10-17  7:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17  5:55 [PATCH net] r8152: use cancel_delayed_work for runtime suspend Hayes Wang
2014-10-17  7:42 ` Bjørn Mork [this message]
2014-10-17  8:55   ` [PATCH net] r8152: return -EBUSY " Hayes Wang
2014-10-18  3:46     ` David Miller
     [not found] ` <1394712342-15778-64-Taiwan-albertk-Rasf1IRRPZFBDgjK7y7TUQ@public.gmane.org>
2014-10-18 19:48   ` [PATCH net] r8152: use cancel_delayed_work " Oliver Neukum
     [not found]     ` <1413661699.19391.2.camel-AfvqVibwNMkMNNZnWhT/Jw@public.gmane.org>
2014-10-20  2:19       ` Hayes Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjcvgn1x.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=hayeswang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).