linux/drivers/media/usb/dvb-usb-v2
Changbing Xiong 7a0af6ed97 [media] media: fix kernel deadlock due to tuner pull-out while playing
Normally, ADAP_STREAMING bit is set in dvb_usb_start_feed and cleared in
dvb_usb_stop_feed.

But in exceptional cases, for example, when the tv is playing programs
and the tuner is pulled out, then dvb_usbv2_disconnect is called.

In such case, it will first call dvb_usbv2_adapter_frontend_exit to stop
dvb_frontend_thread, and then call dvb_usbv2_adapter_dvb_exit to clear
ADAP_STREAMING bit.

At this point, if dvb_frontend_thread is sleeping and waiting for
ADAP_STREAMING to be cleared to get out of sleep. then
dvb_frontend_thread can never be stoped, because clearing ADAP_STREAMING
bit is performed after dvb_frontend_thread is stopped (i.e. performed in
dvb_usbv2_adapter_dvb_exit).

So, deadlock:

[  240.822037] INFO: task khubd:497 blocked for more than 120 seconds.
[  240.822655] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  240.830493] khubd           D c0013b3c     0   497      2 0x00000000
[  240.836996] [<c0013b3c>] (__schedule+0x200/0x54c) from [<c00110f4>] (schedule_timeout+0x14c/0x19c)
[  240.845940] [<c00110f4>] (schedule_timeout+0x14c/0x19c) from [<c00137f4>] (wait_for_common+0xac/0x150)
[  240.855234] [<c00137f4>] (wait_for_common+0xac/0x150) from [<c004989c>] (kthread_stop+0x58/0x90)
[  240.864004] [<c004989c>] (kthread_stop+0x58/0x90) from [<c03b2ebc>] (dvb_frontend_stop+0x3c/0x9c)
[  240.872849] [<c03b2ebc>] (dvb_frontend_stop+0x3c/0x9c) from [<c03b2f3c>] (dvb_unregister_frontend+0x20/0xd8)
[  240.882666] [<c03b2f3c>] (dvb_unregister_frontend+0x20/0xd8) from [<c03ed938>] (dvb_usbv2_exit+0x68/0xfc)
[  240.892204] [<c03ed938>] (dvb_usbv2_exit+0x68/0xfc) from [<c03eda18>] (dvb_usbv2_disconnect+0x4c/0x70)
[  240.901499] [<c03eda18>] (dvb_usbv2_disconnect+0x4c/0x70) from [<c031c050>] (usb_unbind_interface+0x58/0x188)
[  240.911395] [<c031c050>] (usb_unbind_interface+0x58/0x188) from [<c02c3e78>] (__device_release_driver+0x74/0xd0)
[  240.921544] [<c02c3e78>] (__device_release_driver+0x74/0xd0) from [<c02c3ef0>] (device_release_driver+0x1c/0x28)
[  240.931697] [<c02c3ef0>] (device_release_driver+0x1c/0x28) from [<c02c39b8>] (bus_remove_device+0xc4/0xe4)
[  240.941332] [<c02c39b8>] (bus_remove_device+0xc4/0xe4) from [<c02c1344>] (device_del+0xf4/0x178)
[  240.950106] [<c02c1344>] (device_del+0xf4/0x178) from [<c0319eb0>] (usb_disable_device+0xa0/0x1c8)
[  240.959040] [<c0319eb0>] (usb_disable_device+0xa0/0x1c8) from [<c03128b4>] (usb_disconnect+0x88/0x188)
[  240.968326] [<c03128b4>] (usb_disconnect+0x88/0x188) from [<c0313edc>] (hub_thread+0x4d0/0x1200)
[  240.977100] [<c0313edc>] (hub_thread+0x4d0/0x1200) from [<c0049690>] (kthread+0xa4/0xb0)
[  240.985174] [<c0049690>] (kthread+0xa4/0xb0) from [<c0009118>] (ret_from_fork+0x14/0x3c)
[  240.993259] INFO: task kdvb-ad-0-fe-0:3256 blocked for more than 120 seconds.
[  241.000349] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  241.008162] kdvb-ad-0-fe-0  D c0013b3c     0  3256      2 0x00000000
[  241.014507] [<c0013b3c>] (__schedule+0x200/0x54c) from [<c03eda44>] (wait_schedule+0x8/0x10)
[  241.022924] [<c03eda44>] (wait_schedule+0x8/0x10) from [<c001120c>] (__wait_on_bit+0x74/0xb8)
[  241.031434] [<c001120c>] (__wait_on_bit+0x74/0xb8) from [<c00112b8>] (out_of_line_wait_on_bit+0x68/0x70)
[  241.040902] [<c00112b8>] (out_of_line_wait_on_bit+0x68/0x70) from [<c03e5e88>] (dvb_usb_fe_sleep+0xf4/0xfc)
[  241.050618] [<c03e5e88>] (dvb_usb_fe_sleep+0xf4/0xfc) from [<c03b4b74>] (dvb_frontend_thread+0x124/0x4e8)
[  241.060164] [<c03b4b74>] (dvb_frontend_thread+0x124/0x4e8) from [<c0049690>] (kthread+0xa4/0xb0)
[  241.068929] [<c0049690>] (kthread+0xa4/0xb0) from [<c0009118>] (ret_from_fork+0x14/0x3c)

Fix it by calling dvb_usbv2_adapter_frontend_exit() latter.

Test enviroment: odroidx2 + Hauppauge(WinTV-Aero-M)

Signed-off-by: Changbing Xiong <cb.xiong@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-09-02 11:47:56 -03:00
..
af9015.c [media] rc-core: document the protocol type 2014-07-23 21:50:48 -03:00
af9015.h [media] af9015: do not use buffers from stack for usb_bulk_msg() 2013-03-18 16:51:17 -03:00
af9035.c [media] af9035: override tuner for AVerMedia A835B devices 2014-07-26 12:04:10 -03:00
af9035.h [media] af9033: Don't export functions for the hardware filter 2014-03-14 20:26:59 -03:00
anysee.c [media] rc-core: document the protocol type 2014-07-23 21:50:48 -03:00
anysee.h [media] anysee: do not use buffers from stack for usb_bulk_msg() 2013-03-18 16:54:26 -03:00
au6610.c [media] au6610: use Kernel dev_foo() logging 2012-09-23 20:50:03 -03:00
au6610.h
az6007.c [media] rc-core: document the protocol type 2014-07-23 21:50:48 -03:00
ce6230.c [media] ce6230: use Kernel dev_foo() logging 2012-09-23 20:50:42 -03:00
ce6230.h [media] dvb_usb_v2: use dvb_usb_dbg_usb_control_msg() 2012-09-15 11:35:59 -03:00
dvb_usb_common.h
dvb_usb_core.c [media] media: fix kernel deadlock due to tuner pull-out while playing 2014-09-02 11:47:56 -03:00
dvb_usb_urb.c [media] dvb_usb_v2: make checkpatch.pl happy 2013-03-23 09:59:56 -03:00
dvb_usb.h [media] dvb_usb_v2: get rid of deferred probe 2013-08-18 07:55:06 -03:00
ec168.c [media] ec168: fix error return code 2014-01-07 09:19:03 -02:00
ec168.h [media] ec168: declare MODULE_FIRMWARE 2012-09-23 20:08:21 -03:00
gl861.c [media] gl861: use Kernel dev_foo() logging 2012-09-23 20:50:13 -03:00
gl861.h
Kconfig [media] rtl2832_sdr: fix Kconfig dependencies 2014-07-22 01:36:29 -03:00
lmedm04.c [media] rc-core: document the protocol type 2014-07-23 21:50:48 -03:00
lmedm04.h
Makefile [media] rtl28xxu: do not hard depend on staging SDR module 2014-04-15 09:48:27 -03:00
mxl111sf-demod.c [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-demod.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-gpio.c [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-gpio.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-i2c.c [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-i2c.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-phy.c [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-phy.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-reg.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-tuner.c [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
mxl111sf-tuner.h [media] mxl111sf: Fix compile when CONFIG_DVB_USB_MXL111SF is unset 2014-02-04 06:37:32 -02:00
mxl111sf.c [media] media: usb: dvb-usb-v2: mxl111sf.c: Cleaning up uninitialized variables 2014-07-04 15:43:34 -03:00
mxl111sf.h [media] update Michael Krufky's email address 2014-02-04 06:34:21 -02:00
rtl28xxu.c [media] rtl28xxu: add [1b80:d3b0] Sveon STV21 2014-07-26 10:52:28 -03:00
rtl28xxu.h [media] rtl28xxu: use muxed RTL2832 I2C adapters for E4000 and RTL2832_SDR 2014-03-14 05:35:24 -03:00
usb_urb.c [media] dvb_usb_v2: make checkpatch.pl happy 2013-03-23 09:59:56 -03:00