Bug 10432

Summary: Freeze during docking
Product: ACPI Reporter: Adrian Cox (adrian)
Component: Config-HotplugAssignee: Shaohua (shaohua.li)
Status: CLOSED DUPLICATE    
Severity: normal CC: acpi-bugzilla, bunk, elcapo, Jan.Becicka
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.25-rc8 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: Log of ACPI operations in loop
Log of ACPI operations during successful dock (CONFIG_SLAB)
acpidump output
Fix for the problem

Description Adrian Cox 2008-04-09 08:09:51 UTC
Latest working kernel version: 2.6.21
Earliest failing kernel version: 2.6.22
Distribution: Ubuntu
Hardware Environment: Dell Latitude D600, D/Dock docking station
Software Environment: Ubuntu 7.10
Problem Description:

The laptop freezes shortly after docking. This started as an Ubuntu bug which I have now reproduced using a mainline kernel:
https://bugs.launchpad.net/bugs/41091

My initial testing suggests that the problem occurs when CONFIG_SLUB is defined, but does not occur with CONFIG_SLAB. I have tested this using the Ubuntu 2.6.22 and 2.6.24 kernels, and the mainline 2.6.25-rc8.

Steps to reproduce:
Build a kernel with the ACPI dock module, and with CONFIG_SLUB.
Boot the laptop docked.
Undock - no problem.
Dock - the laptop freezes, though sysrq still works.
Forcibly undock - the laptop returns to life, sufficient to extract dmesg logs and cleanly shutdown.

I have some extra debugging information. Adding trace printk statements to dock.c reveals that shortly after I insert the laptop into the dock, the kernel calls dock_notify(). dock_notify() uses dock_present() to test for the docking station. dock_present() returns 0, which causes dock_notify() to return. The kernel then calls dock_notify() again, and the process repeats.

I have also captured a sysrq-t during a freeze, and the acpi tasks are below:

[  583.952325] kacpid        R running      0    42      2
[  583.952325]        f64e25b0 00000046 c03a63d6 00000004 c03ac9ec c0133f54 f64e270c f64e270c 
[  583.952325]        c180b200 f7572a80 c0455080 c0455080 c0455080 f64bb210 f4d4a238 c0213480 
[  583.952325]        f64bb214 c0133f6d c03d4200 c0455080 00000246 c0137470 f64bb21c f64bb210 
[  583.952325] Call Trace:
[  583.952325]  [<c0133f54>] run_workqueue+0x74/0x100
[  583.952325]  [<c0213480>] acpi_os_execute_deferred+0x0/0x25
[  583.952325]  [<c0133f6d>] run_workqueue+0x8d/0x100
[  583.952325]  [<c0137470>] prepare_to_wait+0x20/0x70
[  583.952325]  [<c01347c0>] worker_thread+0x0/0xf0
[  583.952325]  [<c013488f>] worker_thread+0xcf/0xf0
[  583.952325]  [<c01372c0>] autoremove_wake_function+0x0/0x50
[  583.952325]  [<c01347c0>] worker_thread+0x0/0xf0
[  583.952325]  [<c0136fd2>] kthread+0x42/0x70
[  583.952325]  [<c0136f90>] kthread+0x0/0x70
[  583.952325]  [<c0105f77>] kernel_thread_helper+0x7/0x10
[  583.952325]  =======================
[  583.952325] kacpi_notify  R running      0    43      2
[  583.952325]        f754d2cc c03a6f05 000000ff 00000000 00000087 00000000 00000000 00000000 
[  583.952325]        00000001 00000087 00000000 00000000 00000000 00000000 f6432370 c021ee44 
[  583.952325]        f4c511dc f754d2c0 c03a6874 00000008 f754d2cc 00000000 00000000 00000008 
[  583.952325] Call Trace:
[  583.952325]  [<c021ee44>] acpi_ex_write_data_to_field+0x386/0x3c6
[  583.952325]  [<c0224dc8>] acpi_ex_store_object_to_node+0x10c/0x1ff
[  583.952325]  [<c02252da>] acpi_ex_store+0x8a/0x3bc
[  583.952325]  [<c0221e2b>] acpi_ex_opcode_1A_1T_1R+0x3f6/0x584
[  583.952325]  [<c02165bf>] acpi_ds_exec_end_op+0x131/0x54e
[  583.952325]  [<c022e207>] acpi_ps_parse_loop+0x908/0xb2d
[  583.952325]  [<c022d082>] acpi_ps_parse_aml+0xd8/0x303
[  583.952325]  [<c022eb80>] acpi_ps_execute_method+0x179/0x26d
[  583.952325]  [<c022a1f8>] acpi_ns_evaluate+0x15c/0x20c
[  583.952325]  [<c0229b20>] acpi_evaluate_object+0x1ac/0x294
[  583.952325]  [<c0213e6e>] acpi_evaluate_integer+0x54/0xfc
[  583.952325]  [<c0213e96>] acpi_evaluate_integer+0x7c/0xfc
[  583.952325]  [<c0213480>] acpi_os_execute_deferred+0x0/0x25
[  583.952325]  [<f8866098>] dock_present+0x1b/0x30 [dock]
[  583.952325]  [<c02373f9>] acpi_bus_notify+0x17/0x1bd
[  583.952325]  [<f88668d2>] dock_notify+0x2b/0xb9 [dock]
[  583.952325]  [<c021b947>] acpi_ev_notify_dispatch+0x51/0x5a
[  583.952325]  [<c021349d>] acpi_os_execute_deferred+0x1d/0x25
[  583.952325]  [<c0133f54>] run_workqueue+0x74/0x100
[  583.952325]  [<c0137470>] prepare_to_wait+0x20/0x70
[  583.952325]  [<c01347c0>] worker_thread+0x0/0xf0
[  583.952325]  [<c013485c>] worker_thread+0x9c/0xf0
[  583.952325]  [<c01372c0>] autoremove_wake_function+0x0/0x50
[  583.952325]  [<c01347c0>] worker_thread+0x0/0xf0
[  583.952325]  [<c0136fd2>] kthread+0x42/0x70
[  583.952325]  [<c0136f90>] kthread+0x0/0x70
[  583.952325]  [<c0105f77>] kernel_thread_helper+0x7/0x10
Comment 1 Adrian Cox 2008-04-09 14:51:57 UTC
Created attachment 15705 [details]
Log of ACPI operations in loop

This is a section of log messages from the frozen state, taken with acpi_debug_level set to 0x8000ffff.
Comment 2 Adrian Cox 2008-04-10 00:16:43 UTC
Created attachment 15707 [details]
Log of ACPI operations during successful dock (CONFIG_SLAB)

I have built the same kernel source with CONFIG_SLAB instead of CONFIG_SLUB, and tested that docking works. The attached log file shows the events in a successful docking. There are still multiple notifications, but eventually the dock driver detects the dock as present, which never occurs in the CONFIG_SLUB kernel.
Comment 3 Shaohua 2008-05-06 00:24:44 UTC
can you please attach the acpidump output?

Can you enable slub debug in your config (SLUB_DEBUG_ON) and retest, maybe we can get more info.
Comment 4 Adrian Cox 2008-05-06 01:14:36 UTC
Created attachment 16040 [details]
acpidump output
Comment 5 Adrian Cox 2008-05-06 04:52:51 UTC
Created attachment 16044 [details]
Fix for the problem

This patch is a small change to <a href="http://bugzilla.kernel.org/show_bug.cgi?id=10431#c12">Shaohua's patch to bug 10431</a>.

The Dell sends a bus check on undock as well as on dock, so the previous patch would exit from dock_notify() leaving dock_in_progress() set. The variation calls complete_dock() for the failure case.

This works reliably on my Dell D600. I'm not sure why the original docking code worked with CONFIG_SLAB.
Comment 6 Shaohua 2008-05-06 19:06:35 UTC
Ok, this is great. I'll mark this one as duplicate of bug 10431. I'll attach a slightly modified patch there (added complete_dock() too), please try too.

*** This bug has been marked as a duplicate of bug 10431 ***