Simplify error path cleanup for IFPC-disable critical sections.

Note that this moves where we re-enable IFPC until after the
wake_up_all(), but that is harmless.

Signed-off-by: Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/msm_gpu.h      | 4 ++++
 drivers/gpu/drm/msm/msm_perfcntr.c | 7 +------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 2e1b1bea37ce..4e18c2427c69 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -381,6 +381,10 @@ msm_gpu_sysprof_no_ifpc(struct msm_gpu *gpu)
        return refcount_read(&gpu->sysprof_active) > 1;
 }
 
+DEFINE_GUARD(ifpc_disable, struct msm_gpu *,
+            if (_T->funcs->ifpc_update) _T->funcs->ifpc_update(_T, true),
+            if (_T->funcs->ifpc_update) _T->funcs->ifpc_update(_T, false));
+
 /*
  * The number of priority levels provided by drm gpu scheduler.  The
  * DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some
diff --git a/drivers/gpu/drm/msm/msm_perfcntr.c 
b/drivers/gpu/drm/msm/msm_perfcntr.c
index 7b4a6e49d3a7..995857273aca 100644
--- a/drivers/gpu/drm/msm/msm_perfcntr.c
+++ b/drivers/gpu/drm/msm/msm_perfcntr.c
@@ -259,8 +259,7 @@ sample_worker(struct kthread_work *work)
        }
 
        /* Inhibit IFPC while accessing registers: */
-       if (gpu->funcs->ifpc_update)
-               gpu->funcs->ifpc_update(gpu, true);
+       guard(ifpc_disable)(gpu);
 
        if (gpu->funcs->perfcntr_flush)
                gpu->funcs->perfcntr_flush(gpu);
@@ -296,10 +295,6 @@ sample_worker(struct kthread_work *work)
                }
        }
 
-       /* Re-enable IFPC: */
-       if (gpu->funcs->ifpc_update)
-               gpu->funcs->ifpc_update(gpu, false);
-
        smp_store_release(&stream->fifo.head, head);
        wake_up_all(&stream->poll_wq);
 }
-- 
2.56.0

Reply via email to