Guard rpm helpers in try_context_registration with
is_intel_rpm_allowed

Avoid rpm helpers in guc_init_engine_stats and
rpm helpers not needed at higher level functions.
as intel_guc_submission_enable is called from
intel_gt_init_hw (which already holds wakeref)

Signed-off-by: Tilak Tangudu <[email protected]>
---
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 28 +++++++++++--------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index e62ea35513ea..1be469810154 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1364,18 +1364,16 @@ static int guc_action_enable_usage_stats(struct 
intel_guc *guc)
 static void guc_init_engine_stats(struct intel_guc *guc)
 {
        struct intel_gt *gt = guc_to_gt(guc);
-       intel_wakeref_t wakeref;
+       int ret;
 
        mod_delayed_work(system_highpri_wq, &guc->timestamp.work,
                         guc->timestamp.ping_delay);
 
-       with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref) {
-               int ret = guc_action_enable_usage_stats(guc);
+       ret = guc_action_enable_usage_stats(guc);
 
-               if (ret)
-                       drm_err(&gt->i915->drm,
-                               "Failed to enable usage stats: %d!\n", ret);
-       }
+       if (ret)
+               drm_err(&gt->i915->drm,
+                       "Failed to enable usage stats: %d!\n", ret);
 }
 
 void intel_guc_busyness_park(struct intel_gt *gt)
@@ -2478,7 +2476,7 @@ static int try_context_registration(struct intel_context 
*ce, bool loop)
        struct intel_engine_cs *engine = ce->engine;
        struct intel_runtime_pm *runtime_pm = engine->uncore->rpm;
        struct intel_guc *guc = &engine->gt->uc.guc;
-       intel_wakeref_t wakeref;
+       intel_wakeref_t wakeref = 0;
        u32 ctx_id = ce->guc_id.id;
        bool context_registered;
        int ret = 0;
@@ -2522,13 +2520,19 @@ static int try_context_registration(struct 
intel_context *ce, bool loop)
                 * If stealing the guc_id, this ce has the same guc_id as the
                 * context whose guc_id was stolen.
                 */
-               with_intel_runtime_pm(runtime_pm, wakeref)
-                       ret = deregister_context(ce, ce->guc_id.id);
+               if (is_intel_rpm_allowed(runtime_pm))
+                       wakeref = intel_runtime_pm_get(runtime_pm);
+               ret = deregister_context(ce, ce->guc_id.id);
+               if (wakeref)
+                       intel_runtime_pm_put(runtime_pm, wakeref);
                if (unlikely(ret == -ENODEV))
                        ret = 0;        /* Will get registered later */
        } else {
-               with_intel_runtime_pm(runtime_pm, wakeref)
-                       ret = register_context(ce, loop);
+               if (is_intel_rpm_allowed(runtime_pm))
+                       wakeref = intel_runtime_pm_get(runtime_pm);
+               ret = register_context(ce, loop);
+               if (wakeref)
+                       intel_runtime_pm_put(runtime_pm, wakeref);
                if (unlikely(ret == -EBUSY)) {
                        clr_ctx_id_mapping(guc, ctx_id);
                } else if (unlikely(ret == -ENODEV)) {
-- 
2.25.1

Reply via email to