gpu: nvgpu: return from worker if gpu is not up
Deepak Nibade [Wed, 20 Jan 2016 15:45:52 +0000 (20:45 +0530)]
During GPU shutdown path, it is possible that we
shut down the GPU while worker thread is still
running gk20a_channel_update()

Hence before accessing gp_put/get, check if GPU
is up or not

Bug 200166139

Change-Id: Iba3ec173041a84527c4700a93f20564a842cfb01
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/935193
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>

drivers/gpu/nvgpu/gk20a/channel_gk20a.c

index f6da58d..2938317 100644 (file)
@@ -1583,16 +1583,18 @@ static void gk20a_channel_clean_up_jobs(struct work_struct *work)
        if (!c)
                return;
 
+       if (!c->g->power_on) { /* shutdown case */
+               gk20a_channel_put(c);
+               return;
+       }
+
        vm = c->vm;
        platform = gk20a_get_platform(c->g->dev);
 
        mutex_lock(&c->submit_lock);
 
-       if (c->g->power_on) {
-               /* gp_put check needs to be done inside submit lock */
-               update_gp_get(c->g, c);
-               check_gp_put(c->g, c);
-       }
+       /* gp_put check needs to be done inside submit lock */
+       check_gp_put(c->g, c);
 
        gk20a_channel_cancel_job_clean_up(c, false);
 
@@ -1662,6 +1664,11 @@ void gk20a_channel_update(struct channel_gk20a *c, int nr_completed)
        if (!c)
                return;
 
+       if (!c->g->power_on) { /* shutdown case */
+               gk20a_channel_put(c);
+               return;
+       }
+
        update_gp_get(c->g, c);
        wake_up(&c->submit_wq);