drm/msm: Fix cx collapse issue during recovery
authorAkhil P Oommen <quic_akhilpo@quicinc.com>
Thu, 18 Aug 2022 20:22:12 +0000 (01:52 +0530)
committerRob Clark <robdclark@chromium.org>
Sun, 28 Aug 2022 16:29:27 +0000 (09:29 -0700)
There are some hardware logic under CX domain. For a successful
recovery, we should ensure cx headswitch collapses to ensure all the
stale states are cleard out. This is especially true to for a6xx family
where we can GMU co-processor.

Currently, cx doesn't collapse due to a devlink between gpu and its
smmu. So the *struct gpu device* needs to be runtime suspended to ensure
that the iommu driver removes its vote on cx gdsc.

Signed-off-by: Akhil P Oommen <quic_akhilpo@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/498398/
Link: https://lore.kernel.org/r/20220819015030.v5.4.I4ac27a0b34ea796ce0f938bb509e257516bc6f57@changeid
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/msm_gpu.c

index c8ad8aeca777f1d491421753303e0db3f5a6d984..aa2ec986136142b52a27bf2fbc0775f81b2bf9fb 100644 (file)
@@ -1261,7 +1261,7 @@ static void a6xx_recover(struct msm_gpu *gpu)
 {
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
        struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
-       int i;
+       int i, active_submits;
 
        adreno_dump_info(gpu);
 
@@ -1278,8 +1278,34 @@ static void a6xx_recover(struct msm_gpu *gpu)
         */
        gmu_write(&a6xx_gpu->gmu, REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE, 0);
 
-       gpu->funcs->pm_suspend(gpu);
-       gpu->funcs->pm_resume(gpu);
+       pm_runtime_dont_use_autosuspend(&gpu->pdev->dev);
+
+       /* active_submit won't change until we make a submission */
+       mutex_lock(&gpu->active_lock);
+       active_submits = gpu->active_submits;
+
+       /*
+        * Temporarily clear active_submits count to silence a WARN() in the
+        * runtime suspend cb
+        */
+       gpu->active_submits = 0;
+
+       /* Drop the rpm refcount from active submits */
+       if (active_submits)
+               pm_runtime_put(&gpu->pdev->dev);
+
+       /* And the final one from recover worker */
+       pm_runtime_put_sync(&gpu->pdev->dev);
+
+       pm_runtime_use_autosuspend(&gpu->pdev->dev);
+
+       if (active_submits)
+               pm_runtime_get(&gpu->pdev->dev);
+
+       pm_runtime_get_sync(&gpu->pdev->dev);
+
+       gpu->active_submits = active_submits;
+       mutex_unlock(&gpu->active_lock);
 
        msm_gpu_hw_init(gpu);
 }
index da6242cbf87d0d3bef2028194379df5c37d95223..9ec9a99ffe77a9cd954522f9fed7ee02b0e46b25 100644 (file)
@@ -422,9 +422,7 @@ static void recover_worker(struct kthread_work *work)
                /* retire completed submits, plus the one that hung: */
                retire_submits(gpu);
 
-               pm_runtime_get_sync(&gpu->pdev->dev);
                gpu->funcs->recover(gpu);
-               pm_runtime_put_sync(&gpu->pdev->dev);
 
                /*
                 * Replay all remaining submits starting with highest priority
@@ -441,7 +439,7 @@ static void recover_worker(struct kthread_work *work)
                }
        }
 
-       pm_runtime_put_sync(&gpu->pdev->dev);
+       pm_runtime_put(&gpu->pdev->dev);
 
        mutex_unlock(&gpu->lock);