media: tegra: avp: Fix avp_svc_thread shutdown
Kaz Fukuoka [Wed, 6 Jul 2011 01:36:27 +0000 (18:36 -0700)]
Fix the race condition between kthread_stop() and wait.
Without this fix, the following message was printed.
"avp_svc_thread: timed out while waiting for kthread_stop"

bug 840262
bug 836806

Original-Change-Id: I5acf75859e6512923506a3c508f62e7d7ef9a1dc
Reviewed-on: http://git-master/r/39736
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Rf58fd998c20b6ba03077e0a06cb1ac3d89826f77

drivers/media/video/tegra/avp/avp_svc.c

index 715e948..37a8ecd 100644 (file)
@@ -656,10 +656,14 @@ static int avp_svc_thread(void *data)
                DBG(AVP_DBG_TRACE_SVC, "%s: got message\n", __func__);
 
                if (ret == -ECONNRESET || ret == -ENOTCONN) {
+                       wait_queue_head_t wq;
+                       init_waitqueue_head(&wq);
+
                        pr_info("%s: AVP seems to be down; "
                                "wait for kthread_stop\n", __func__);
                        timeout = msecs_to_jiffies(100);
-                       timeout = schedule_timeout_interruptible(timeout);
+                       timeout = wait_event_interruptible_timeout(wq,
+                                       kthread_should_stop(), timeout);
                        if (timeout == 0)
                                pr_err("%s: timed out while waiting for "
                                        "kthread_stop\n", __func__);