]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/gsc: Use scope-based cleanup
authorMatt Roper <matthew.d.roper@intel.com>
Tue, 18 Nov 2025 16:43:49 +0000 (08:43 -0800)
committerMatt Roper <matthew.d.roper@intel.com>
Wed, 19 Nov 2025 19:58:57 +0000 (11:58 -0800)
Use scope-based cleanup for forcewake and runtime PM to eliminate some
goto-based error handling and simplify other functions.

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-39-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
drivers/gpu/drm/xe/xe_gsc.c
drivers/gpu/drm/xe/xe_gsc_proxy.c

index dd69cb834f8e58828e1c391a111e32eb1212320e..a3157b0fe791d033d0e40a9c61f53329249d2c73 100644 (file)
@@ -352,7 +352,6 @@ static void gsc_work(struct work_struct *work)
        struct xe_gsc *gsc = container_of(work, typeof(*gsc), work);
        struct xe_gt *gt = gsc_to_gt(gsc);
        struct xe_device *xe = gt_to_xe(gt);
-       unsigned int fw_ref;
        u32 actions;
        int ret;
 
@@ -361,13 +360,12 @@ static void gsc_work(struct work_struct *work)
        gsc->work_actions = 0;
        spin_unlock_irq(&gsc->lock);
 
-       xe_pm_runtime_get(xe);
-       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
+       guard(xe_pm_runtime)(xe);
+       CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GSC);
 
        if (actions & GSC_ACTION_ER_COMPLETE) {
-               ret = gsc_er_complete(gt);
-               if (ret)
-                       goto out;
+               if (gsc_er_complete(gt))
+                       return;
        }
 
        if (actions & GSC_ACTION_FW_LOAD) {
@@ -380,10 +378,6 @@ static void gsc_work(struct work_struct *work)
 
        if (actions & GSC_ACTION_SW_PROXY)
                xe_gsc_proxy_request_handler(gsc);
-
-out:
-       xe_force_wake_put(gt_to_fw(gt), fw_ref);
-       xe_pm_runtime_put(xe);
 }
 
 void xe_gsc_hwe_irq_handler(struct xe_hw_engine *hwe, u16 intr_vec)
@@ -615,7 +609,6 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
 {
        struct xe_gt *gt = gsc_to_gt(gsc);
        struct xe_mmio *mmio = &gt->mmio;
-       unsigned int fw_ref;
 
        xe_uc_fw_print(&gsc->fw, p);
 
@@ -624,8 +617,8 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
        if (!xe_uc_fw_is_enabled(&gsc->fw))
                return;
 
-       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
-       if (!fw_ref)
+       CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GSC);
+       if (!fw_ref.domains)
                return;
 
        drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
@@ -635,6 +628,4 @@ void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
                        xe_mmio_read32(mmio, HECI_FWSTS4(MTL_GSC_HECI1_BASE)),
                        xe_mmio_read32(mmio, HECI_FWSTS5(MTL_GSC_HECI1_BASE)),
                        xe_mmio_read32(mmio, HECI_FWSTS6(MTL_GSC_HECI1_BASE)));
-
-       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
index 464282a89eef39619d0360188aed91c4163bec28..e7573a0c5e5d246357c03ca8238f2f35b8390040 100644 (file)
@@ -440,22 +440,19 @@ static void xe_gsc_proxy_remove(void *arg)
        struct xe_gsc *gsc = arg;
        struct xe_gt *gt = gsc_to_gt(gsc);
        struct xe_device *xe = gt_to_xe(gt);
-       unsigned int fw_ref = 0;
 
        if (!gsc->proxy.component_added)
                return;
 
        /* disable HECI2 IRQs */
-       xe_pm_runtime_get(xe);
-       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
-       if (!fw_ref)
-               xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n");
+       scoped_guard(xe_pm_runtime, xe) {
+               CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GSC);
+               if (!fw_ref.domains)
+                       xe_gt_err(gt, "failed to get forcewake to disable GSC interrupts\n");
 
-       /* try do disable irq even if forcewake failed */
-       gsc_proxy_irq_toggle(gsc, false);
-
-       xe_force_wake_put(gt_to_fw(gt), fw_ref);
-       xe_pm_runtime_put(xe);
+               /* try do disable irq even if forcewake failed */
+               gsc_proxy_irq_toggle(gsc, false);
+       }
 
        xe_gsc_wait_for_worker_completion(gsc);