stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: Jonghwan Choi <jhbird.choi@samsung.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	"'Gustavo Padovan'" <gustavo.padovan@collabora.co.uk>,
	"'Daniel Drake'" <dsd@laptop.org>,
	"'Marcel Holtmann'" <marcel@holtmann.org>
Subject: Re: [PATCH 3.9-stable]  Bluetooth: btmrvl: fix thread stopping race
Date: Fri, 28 Jun 2013 12:26:51 +0100	[thread overview]
Message-ID: <8761wy8ohw.fsf@canonical.com> (raw)
In-Reply-To: <002501ce7390$9f7c4750$de74d5f0$%choi@samsung.com> (Jonghwan Choi's message of "Fri, 28 Jun 2013 08:47:02 +0900")

Jonghwan Choi <jhbird.choi@samsung.com> writes:

> This patch looks like it should be in the 3.9-stable tree, should we apply
> it?

This seems to be applicable to all the other stable kernels as well
(and its a clean cherry-pick for all of them).  I'm queuing it for the
3.5 kernel.

Cheers,
-- 
Luis


>
> ------------------
>
> From: "Daniel Drake <dsd@laptop.org>"
>
> commit ea05fea9042620ac3b8ab9a3e5e4d2ed80c89244 upstream
>
> There is currently a race condition in the btmrvl_remove_card() which
> is causing hangs on suspend for OLPC. When the race occurs,
> kthread_stop() never returns.
>
> The problem is that btmrvl_service_main_thread() calls kthread_should_stop()
> and then does a fair number of things before restarting the loop and
> sleeping.
>
> If the thread gets stopped after kthread_should_stop() is checked, but
> before the sleep happens, the thread will go to sleep and won't necessarily
> be woken up.
>
> Move the kthread_should_stop() check into a race-free place.
>
> Signed-off-by: Daniel Drake <dsd@laptop.org>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
> ---
>  drivers/bluetooth/btmrvl_main.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bluetooth/btmrvl_main.c
> b/drivers/bluetooth/btmrvl_main.c
> index 3a4343b..9a9f518 100644
> --- a/drivers/bluetooth/btmrvl_main.c
> +++ b/drivers/bluetooth/btmrvl_main.c
> @@ -498,6 +498,10 @@ static int btmrvl_service_main_thread(void *data)
>  		add_wait_queue(&thread->wait_q, &wait);
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
> +		if (kthread_should_stop()) {
> +			BT_DBG("main_thread: break from main thread");
> +			break;
> +		}
>  
>  		if (adapter->wakeup_tries ||
>  				((!adapter->int_count) &&
> @@ -513,11 +517,6 @@ static int btmrvl_service_main_thread(void *data)
>  
>  		BT_DBG("main_thread woke up");
>  
> -		if (kthread_should_stop()) {
> -			BT_DBG("main_thread: break from main thread");
> -			break;
> -		}
> -
>  		spin_lock_irqsave(&priv->driver_lock, flags);
>  		if (adapter->int_count) {
>  			adapter->int_count = 0;

      reply	other threads:[~2013-06-28 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27 23:47 [PATCH 3.9-stable] Bluetooth: btmrvl: fix thread stopping race Jonghwan Choi
2013-06-28 11:26 ` Luis Henriques [this message]

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=8761wy8ohw.fsf@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=dsd@laptop.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=jhbird.choi@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=stable@vger.kernel.org \
    /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).