OSDN Git Service

msm: mdss: initialize the DP thread structures before kthread_run
authorPadmanabhan Komanduru <pkomandu@codeaurora.org>
Thu, 23 Feb 2017 13:05:50 +0000 (18:35 +0530)
committerPadmanabhan Komanduru <pkomandu@codeaurora.org>
Thu, 23 Feb 2017 13:13:42 +0000 (18:43 +0530)
The DP event thread has workqueue and spinlock resources which are
initialized as part of the kthread event. This can cause a race
condition where the spinlock is accessed during EV_USBPD_DISCOVER_MODES
event at the end of DP probe sequence before it is initialized. This is
because kthread_run API doesn't guarantee the execution of DP event
thread to the point where spinlock is initialized before the function
call returns. Hence, initialize the DP thread resources before the
kthread_run.

Change-Id: I05711c33a896d409d4417d09973c6dfec61e818f
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
drivers/video/fbdev/msm/mdss_dp.c

index bd8e710..f613f11 100644 (file)
@@ -2889,8 +2889,6 @@ static int mdss_dp_event_thread(void *data)
                return -EINVAL;
 
        ev_data = (struct mdss_dp_event_data *)data;
-       init_waitqueue_head(&ev_data->event_q);
-       spin_lock_init(&ev_data->event_lock);
 
        while (!kthread_should_stop()) {
                wait_event(ev_data->event_q,
@@ -3049,6 +3047,9 @@ static void mdss_dp_event_cleanup(struct mdss_dp_drv_pdata *dp)
 static int mdss_dp_event_setup(struct mdss_dp_drv_pdata *dp)
 {
 
+       init_waitqueue_head(&dp->dp_event.event_q);
+       spin_lock_init(&dp->dp_event.event_lock);
+
        dp->ev_thread = kthread_run(mdss_dp_event_thread,
                (void *)&dp->dp_event, "mdss_dp_event");
        if (IS_ERR(dp->ev_thread)) {