linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RESEND 1/3] Bluetooth: Use cancel_work instead of cancel_work_sync
Date: Tue, 31 Jan 2012 10:43:02 +0200	[thread overview]
Message-ID: <1327999384-16094-2-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1327999384-16094-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Fix deadlock when cancelling delayed work.

[  584.676126] ======================================================
[  584.676126] [ INFO: possible circular locking dependency detected ]
[  584.676126] 3.2.0-rc2niko+ #44
[  584.676126] -------------------------------------------------------
[  584.676126] kworker/u:1/30 is trying to acquire lock:
[  584.676126]  (&hdev->lock){+.+.+.}, at: [<f81f001c>] hci_conn_timeout+0x6c/0x190 [bluetooth]
[  584.676126]
[  584.676126] but task is already holding lock:
[  584.676126]  ((&(&conn->disc_work)->work)){+.+...}, at: [<c1065a78>] process_one_work+0x108/0x460
[  584.676126]
[  584.676126] which lock already depends on the new lock.
[  584.676126]
[  584.676126]
[  584.676126] the existing dependency chain (in reverse order) is:
[  584.676126]
[  584.676126] -> #1 ((&(&conn->disc_work)->work)){+.+...}:
[  584.676126]        [<c1086748>] lock_acquire+0x88/0x110
[  584.676126]        [<c1066041>] wait_on_work+0x61/0x210
[  584.676126]        [<c106630a>] __cancel_work_timer+0x6a/0x110
[  584.676126]        [<c10663c0>] cancel_delayed_work_sync+0x10/0x20
[  584.676126]        [<f81f935b>] hci_event_packet+0x3b2b/0x4610 [bluetooth]
[  584.676126]        [<f81ea78e>] hci_rx_work+0x20e/0x4c0 [bluetooth]
[  584.676126]        [<c1065aec>] process_one_work+0x17c/0x460
[  584.676126]        [<c10672e4>] worker_thread+0x124/0x2c0
[  584.676126]        [<c106be44>] kthread+0x84/0x90
[  584.676126]        [<c1567f42>] kernel_thread_helper+0x6/0x10
[  584.676126]
[  584.676126] -> #0 (&hdev->lock){+.+.+.}:
[  584.676126]        [<c10852cd>] __lock_acquire+0xc0d/0x1ab0
[  584.676126]        [<c1086748>] lock_acquire+0x88/0x110
[  584.676126]        [<c155de50>] mutex_lock_nested+0x70/0x320
[  584.676126]        [<f81f001c>] hci_conn_timeout+0x6c/0x190 [bluetooth]
[  584.676126]        [<c1065aec>] process_one_work+0x17c/0x460
[  584.676126]        [<c10672e4>] worker_thread+0x124/0x2c0
[  584.676126]        [<c106be44>] kthread+0x84/0x90
[  584.676126]        [<c1567f42>] kernel_thread_helper+0x6/0x10
[  584.676126]
[  584.676126] other info that might help us debug this:
[  584.676126]
[  584.676126]  Possible unsafe locking scenario:
[  584.676126]
[  584.676126]        CPU0                    CPU1
[  584.676126]        ----                    ----
[  584.676126]   lock((&(&conn->disc_work)->work));
[  584.676126]                                lock(&hdev->lock);
[  584.676126]                                lock((&(&conn->disc_work)->work));
[  584.676126]   lock(&hdev->lock);
[  584.676126]
[  584.676126]  *** DEADLOCK ***
[  584.676126]
[  584.676126] 2 locks held by kworker/u:1/30:
[  584.676126]  #0:  (hdev->name){.+.+.+}, at: [<c1065a78>] process_one_work+0x108/0x460
[  584.676126]  #1:  ((&(&conn->disc_work)->work)){+.+...}, at: [<c1065a78>] process_one_work+0x108/0x460

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
v2 - use cancel_delayed_work instead of cancel_delayed_work_sync following
recommendation from Ulisses Furquim
---
 net/bluetooth/hci_conn.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 67c94c4..7ec6e54 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -433,7 +433,7 @@ int hci_conn_del(struct hci_conn *conn)
 
 	del_timer(&conn->idle_timer);
 
-	cancel_delayed_work_sync(&conn->disc_work);
+	cancel_delayed_work(&conn->disc_work);
 
 	del_timer(&conn->auto_accept_timer);
 
-- 
1.7.4.1


  reply	other threads:[~2012-01-31  8:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31  8:43 [RESEND 0/3] Fixes kernel crashes and warnings Emeltchenko Andrei
2012-01-31  8:43 ` Emeltchenko Andrei [this message]
2012-01-31 12:31   ` [RESEND 1/3] Bluetooth: Use cancel_work instead of cancel_work_sync Andre Guedes
2012-01-31 13:02     ` Emeltchenko Andrei
2012-01-31 15:11       ` Marcel Holtmann
2012-01-31 15:41         ` Ulisses Furquim
2012-01-31 15:58           ` Marcel Holtmann
2012-01-31 17:49             ` Ulisses Furquim
2012-02-01 13:32               ` Emeltchenko Andrei
2012-02-01 15:53                 ` Marcel Holtmann
2012-02-02  8:34                   ` Emeltchenko Andrei
2012-01-31 15:07   ` Marcel Holtmann
2012-01-31  8:43 ` [RESEND 2/3] Bluetooth: Use list _safe deleting from conn_hash_list Emeltchenko Andrei
2012-01-31 15:07   ` Marcel Holtmann
2012-01-31  8:43 ` [RESEND 3/3] Bluetooth: Use list _safe deleting from conn chan_list Emeltchenko Andrei
2012-01-31 15:08   ` Marcel Holtmann

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=1327999384-16094-2-git-send-email-Andrei.Emeltchenko.news@gmail.com \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@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).