diff options
author | matthieu castet <castet.matthieu@free.fr> | 2010-05-05 14:59:20 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:59:15 -0400 |
commit | e36309f54a6196792fce74100356ebdeaecabd56 (patch) | |
tree | bcc850769467a6d1df47834e66cc90a95de88886 /drivers/media/dvb | |
parent | 8b661b508b3a4c8d9fc7a4b10507d3f1172947c3 (diff) |
V4L/DVB: fix dvb frontend lockup
If my dvb device is removed while in use, I got the following oops:
[ 4920.484084] Call Trace:
[ 4920.484102] [<c102daad>] ? default_wake_function+0x0/0x8
[ 4920.484147] [<f8cb09e1>] ? dvb_unregister_frontend+0x95/0xcc [dvb_core]
[ 4920.484157] [<c1044412>] ? autoremove_wake_function+0x0/0x2d
[ 4920.484168] [<f8dd1af2>] ? dvb_usb_adapter_frontend_exit+0x12/0x21 [dvb_usb]
[ 4920.484176] [<f8dd12f1>] ? dvb_usb_exit+0x26/0x88 [dvb_usb]
[ 4920.484184] [<f8dd138d>] ? dvb_usb_device_exit+0x3a/0x4a [dvb_usb]
[ 4920.484217] [<f7fe1b08>] ? usb_unbind_interface+0x3f/0xb4 [usbcore]
[ 4920.484227] [<c11a4178>] ? __device_release_driver+0x74/0xb7
[ 4920.484233] [<c11a4247>] ? device_release_driver+0x15/0x1e
[ 4920.484243] [<c11a3a33>] ? bus_remove_device+0x6e/0x87
[ 4920.484249] [<c11a26d6>] ? device_del+0xfa/0x152
[ 4920.484264] [<f7fdf609>] ? usb_disable_device+0x59/0xb9 [usbcore]
[ 4920.484279] [<f7fdb9ee>] ? usb_disconnect+0x70/0xdc [usbcore]
[ 4920.484294] [<f7fdc728>] ? hub_thread+0x521/0xe1d [usbcore]
[ 4920.484301] [<c1044412>] ? autoremove_wake_function+0x0/0x2d
[ 4920.484316] [<f7fdc207>] ? hub_thread+0x0/0xe1d [usbcore]
[ 4920.484321] [<c10441e0>] ? kthread+0x61/0x66
[ 4920.484327] [<c104417f>] ? kthread+0x0/0x66
[ 4920.484336] [<c1003d47>] ? kernel_thread_helper+0x7/0x10
If there are users (for example users == -2) :
- dvb_unregister_frontend :
- stop kernel thread with dvb_frontend_stop :
- fepriv->exit = 1;
- thread loop catch stop event and break while loop
- fepriv->thread = NULL; and fepriv->exit = 0;
- dvb_unregister_frontend wait on "fepriv->dvbdev->wait_queue" that fepriv->dvbdev->users==-1.
The user finish :
- dvb_frontend_release - set users to -1
- don't wait wait_queue because fepriv->exit != 1
=> dvb_unregister_frontend never exit the wait queue.
Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 55ea260572bf..6932def4d266 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -95,6 +95,10 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open( | |||
95 | * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. | 95 | * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. |
96 | */ | 96 | */ |
97 | 97 | ||
98 | #define DVB_FE_NO_EXIT 0 | ||
99 | #define DVB_FE_NORMAL_EXIT 1 | ||
100 | #define DVB_FE_DEVICE_REMOVED 2 | ||
101 | |||
98 | static DEFINE_MUTEX(frontend_mutex); | 102 | static DEFINE_MUTEX(frontend_mutex); |
99 | 103 | ||
100 | struct dvb_frontend_private { | 104 | struct dvb_frontend_private { |
@@ -497,7 +501,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe) | |||
497 | { | 501 | { |
498 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 502 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
499 | 503 | ||
500 | if (fepriv->exit) | 504 | if (fepriv->exit != DVB_FE_NO_EXIT) |
501 | return 1; | 505 | return 1; |
502 | 506 | ||
503 | if (fepriv->dvbdev->writers == 1) | 507 | if (fepriv->dvbdev->writers == 1) |
@@ -559,7 +563,7 @@ restart: | |||
559 | 563 | ||
560 | if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { | 564 | if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { |
561 | /* got signal or quitting */ | 565 | /* got signal or quitting */ |
562 | fepriv->exit = 1; | 566 | fepriv->exit = DVB_FE_NORMAL_EXIT; |
563 | break; | 567 | break; |
564 | } | 568 | } |
565 | 569 | ||
@@ -673,7 +677,10 @@ restart: | |||
673 | } | 677 | } |
674 | 678 | ||
675 | fepriv->thread = NULL; | 679 | fepriv->thread = NULL; |
676 | fepriv->exit = 0; | 680 | if (kthread_should_stop()) |
681 | fepriv->exit = DVB_FE_DEVICE_REMOVED; | ||
682 | else | ||
683 | fepriv->exit = DVB_FE_NO_EXIT; | ||
677 | mb(); | 684 | mb(); |
678 | 685 | ||
679 | dvb_frontend_wakeup(fe); | 686 | dvb_frontend_wakeup(fe); |
@@ -686,7 +693,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe) | |||
686 | 693 | ||
687 | dprintk ("%s\n", __func__); | 694 | dprintk ("%s\n", __func__); |
688 | 695 | ||
689 | fepriv->exit = 1; | 696 | fepriv->exit = DVB_FE_NORMAL_EXIT; |
690 | mb(); | 697 | mb(); |
691 | 698 | ||
692 | if (!fepriv->thread) | 699 | if (!fepriv->thread) |
@@ -755,7 +762,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) | |||
755 | dprintk ("%s\n", __func__); | 762 | dprintk ("%s\n", __func__); |
756 | 763 | ||
757 | if (fepriv->thread) { | 764 | if (fepriv->thread) { |
758 | if (!fepriv->exit) | 765 | if (fepriv->exit == DVB_FE_NO_EXIT) |
759 | return 0; | 766 | return 0; |
760 | else | 767 | else |
761 | dvb_frontend_stop (fe); | 768 | dvb_frontend_stop (fe); |
@@ -767,7 +774,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) | |||
767 | return -EINTR; | 774 | return -EINTR; |
768 | 775 | ||
769 | fepriv->state = FESTATE_IDLE; | 776 | fepriv->state = FESTATE_IDLE; |
770 | fepriv->exit = 0; | 777 | fepriv->exit = DVB_FE_NO_EXIT; |
771 | fepriv->thread = NULL; | 778 | fepriv->thread = NULL; |
772 | mb(); | 779 | mb(); |
773 | 780 | ||
@@ -1490,7 +1497,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
1490 | 1497 | ||
1491 | dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); | 1498 | dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); |
1492 | 1499 | ||
1493 | if (fepriv->exit) | 1500 | if (fepriv->exit != DVB_FE_NO_EXIT) |
1494 | return -ENODEV; | 1501 | return -ENODEV; |
1495 | 1502 | ||
1496 | if ((file->f_flags & O_ACCMODE) == O_RDONLY && | 1503 | if ((file->f_flags & O_ACCMODE) == O_RDONLY && |
@@ -1916,6 +1923,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) | |||
1916 | int ret; | 1923 | int ret; |
1917 | 1924 | ||
1918 | dprintk ("%s\n", __func__); | 1925 | dprintk ("%s\n", __func__); |
1926 | if (fepriv->exit == DVB_FE_DEVICE_REMOVED) | ||
1927 | return -ENODEV; | ||
1919 | 1928 | ||
1920 | if (adapter->mfe_shared) { | 1929 | if (adapter->mfe_shared) { |
1921 | mutex_lock (&adapter->mfe_lock); | 1930 | mutex_lock (&adapter->mfe_lock); |
@@ -2008,7 +2017,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) | |||
2008 | ret = dvb_generic_release (inode, file); | 2017 | ret = dvb_generic_release (inode, file); |
2009 | 2018 | ||
2010 | if (dvbdev->users == -1) { | 2019 | if (dvbdev->users == -1) { |
2011 | if (fepriv->exit == 1) { | 2020 | if (fepriv->exit != DVB_FE_NO_EXIT) { |
2012 | fops_put(file->f_op); | 2021 | fops_put(file->f_op); |
2013 | file->f_op = NULL; | 2022 | file->f_op = NULL; |
2014 | wake_up(&dvbdev->wait_queue); | 2023 | wake_up(&dvbdev->wait_queue); |