Bug 14553

Summary: INFO: possible circular locking dependency detected
Product: ACPI Reporter: Dariush Forouher (dariush)
Component: OtherAssignee: acpi_other
Severity: normal CC: lenb, rui.zhang, yu.c.chen
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.32-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: kernel config
complete dmesg output
patch to fix the issue

Description Dariush Forouher 2009-11-07 11:24:47 UTC
Created attachment 23688 [details]
kernel config

Got this lockdep warning while putting my Dell Latitude D630 into the docking station (while it was running):

No idea if this is really ACPI-related, bugzilla just asked me to put a label on it.


[ INFO: possible circular locking dependency detected ]
2.6.32-rc6-00035-g8b17a4f #1
kacpi_hotplug/246 is trying to acquire lock:
 (kacpid){+.+.+.}, at: [<ffffffff8105bbd0>] flush_workqueue+0x0/0xb0

but task is already holding lock:
 (&dpc->work){+.+.+.}, at: [<ffffffff8105abe9>] worker_thread+0x189/0x310

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #1 (&dpc->work){+.+.+.}:
       [<ffffffff8107382e>] __lock_acquire+0x135e/0x1ce0
       [<ffffffff8107420c>] lock_acquire+0x5c/0x80
       [<ffffffff8105ac35>] worker_thread+0x1d5/0x310
       [<ffffffff8105f3a6>] kthread+0x96/0xa0
       [<ffffffff8100c39a>] child_rip+0xa/0x20

-> #0 (kacpid){+.+.+.}:
       [<ffffffff8107415d>] __lock_acquire+0x1c8d/0x1ce0
       [<ffffffff8107420c>] lock_acquire+0x5c/0x80
       [<ffffffff8105bc1e>] flush_workqueue+0x4e/0xb0
       [<ffffffff812dfe59>] acpi_os_wait_events_complete+0x10/0x1e
       [<ffffffff812dfe84>] acpi_os_execute_deferred+0x1d/0x31
       [<ffffffff8105ac3b>] worker_thread+0x1db/0x310
       [<ffffffff8105f3a6>] kthread+0x96/0xa0
       [<ffffffff8100c39a>] child_rip+0xa/0x20

other info that might help us debug this:

2 locks held by kacpi_hotplug/246:
 #0:  (kacpi_hotplug){+.+...}, at: [<ffffffff8105abe9>] worker_thread+0x189/0x310
 #1:  (&dpc->work){+.+.+.}, at: [<ffffffff8105abe9>] worker_thread+0x189/0x310

stack backtrace:
Pid: 246, comm: kacpi_hotplug Not tainted 2.6.32-rc6-00035-g8b17a4f #1
Call Trace:
 [<ffffffff81071e60>] print_circular_bug+0x100/0x110
 [<ffffffff8107415d>] __lock_acquire+0x1c8d/0x1ce0
 [<ffffffff810701bb>] ? add_lock_to_list+0x5b/0xe0
 [<ffffffff810738ca>] ? __lock_acquire+0x13fa/0x1ce0
 [<ffffffff810715ed>] ? trace_hardirqs_on_caller+0x14d/0x1a0
 [<ffffffff810410df>] ? finish_task_switch+0x6f/0x100
 [<ffffffff812dfe67>] ? acpi_os_execute_deferred+0x0/0x31
 [<ffffffff8107420c>] lock_acquire+0x5c/0x80
 [<ffffffff8105bbd0>] ? flush_workqueue+0x0/0xb0
 [<ffffffff8105bc1e>] flush_workqueue+0x4e/0xb0
 [<ffffffff8105bbd0>] ? flush_workqueue+0x0/0xb0
 [<ffffffff812dfe59>] acpi_os_wait_events_complete+0x10/0x1e
 [<ffffffff812dfe84>] acpi_os_execute_deferred+0x1d/0x31
 [<ffffffff8105ac3b>] worker_thread+0x1db/0x310
 [<ffffffff8105abe9>] ? worker_thread+0x189/0x310
 [<ffffffff8104396f>] ? try_to_wake_up+0xaf/0x220
 [<ffffffff8105f720>] ? autoremove_wake_function+0x0/0x40
 [<ffffffff8107164d>] ? trace_hardirqs_on+0xd/0x10
 [<ffffffff8105aa60>] ? worker_thread+0x0/0x310
 [<ffffffff8105f3a6>] kthread+0x96/0xa0
 [<ffffffff8100c39a>] child_rip+0xa/0x20
 [<ffffffff8100bd3c>] ? restore_args+0x0/0x30
 [<ffffffff8105f310>] ? kthread+0x0/0xa0
 [<ffffffff8100c390>] ? child_rip+0x0/0x20
ACPI: \_SB_.PCI0.PCIE.GDCK - docking
Comment 1 Dariush Forouher 2009-11-07 11:30:07 UTC
Created attachment 23689 [details]
complete dmesg output
Comment 2 Zhang Rui 2009-11-09 08:37:42 UTC
here is the call trace when a dock is plugged:

in kacpi_notify_wq:

then kacpi_hp_wq is running:

so you're right that this is a circular locking issue.
Comment 3 Zhang Rui 2009-11-09 08:47:19 UTC
(In reply to comment #2)
> so you're right that this is a circular locking issue.

hmm, it's okay to flush kacpi_notify_wq in kacpi_hotplug_wq.
please ignore the last comment.
Comment 4 Shaohua 2009-12-10 02:51:57 UTC
Created attachment 24127 [details]
patch to fix the issue

attached patch should fix the issue
Comment 5 Zhang Rui 2009-12-22 03:48:18 UTC
patch has been sent to acpi mail list.

could you please give the patch at comment#4 a try?
Comment 6 Dariush Forouher 2009-12-22 09:17:45 UTC
Will do. I have no access to the docking station until the new year, I'll report back then. Thanks and happy holidays!
Comment 7 Dariush Forouher 2010-01-03 21:19:18 UTC
Yes, the patch removes the lockdep warning (tested on top of 2.6.32).
Comment 8 Len Brown 2010-03-23 04:19:47 UTC
applied http://patchwork.kernel.org/patch/66412/
to acpi tree
Comment 9 Len Brown 2010-04-16 19:57:16 UTC
commit bc73675b99fd9850dd914be01d71af99c5d2a1ae
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Mon Mar 22 15:48:54 2010 +0800

    ACPI: fixes a false alarm from lockdep
    fixes a false alarm from lockdep, as acpi hotplug workqueue waits other
    Original-patch-from: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Shaohua Li <shaohua.li@intel.com>
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>

shipped in 2.6.34-rc4