]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe: make xe_gt_idle_disable_c6() handle the forcewake internally
authorXin Wang <x.wang@intel.com>
Wed, 27 Aug 2025 00:06:32 +0000 (17:06 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 27 Aug 2025 13:31:30 +0000 (09:31 -0400)
Move forcewake_get() into xe_gt_idle_enable_c6() to streamline the
code and make it easier to use.

Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Xin Wang <x.wang@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250827000633.1369890-2-x.wang@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_gt_idle.c
drivers/gpu/drm/xe/xe_gt_idle.h
drivers/gpu/drm/xe/xe_guc_pc.c

index ffb210216aa99fcd4d459cbbaf69987e1d158382..f8950a52d0a485297e886b62029769611db2cea6 100644 (file)
@@ -322,15 +322,11 @@ static void gt_idle_fini(void *arg)
 {
        struct kobject *kobj = arg;
        struct xe_gt *gt = kobj_to_gt(kobj->parent);
-       unsigned int fw_ref;
 
        xe_gt_idle_disable_pg(gt);
 
-       if (gt_to_xe(gt)->info.skip_guc_pc) {
-               fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (gt_to_xe(gt)->info.skip_guc_pc)
                xe_gt_idle_disable_c6(gt);
-               xe_force_wake_put(gt_to_fw(gt), fw_ref);
-       }
 
        sysfs_remove_files(kobj, gt_idle_attrs);
        kobject_put(kobj);
@@ -390,14 +386,23 @@ void xe_gt_idle_enable_c6(struct xe_gt *gt)
                        RC_CTL_HW_ENABLE | RC_CTL_TO_MODE | RC_CTL_RC6_ENABLE);
 }
 
-void xe_gt_idle_disable_c6(struct xe_gt *gt)
+int xe_gt_idle_disable_c6(struct xe_gt *gt)
 {
+       unsigned int fw_ref;
+
        xe_device_assert_mem_access(gt_to_xe(gt));
-       xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GT);
 
        if (IS_SRIOV_VF(gt_to_xe(gt)))
-               return;
+               return 0;
+
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return -ETIMEDOUT;
 
        xe_mmio_write32(&gt->mmio, RC_CONTROL, 0);
        xe_mmio_write32(&gt->mmio, RC_STATE, 0);
+
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
+
+       return 0;
 }
index 591a01e181bcc27b8bf6729efea2c46276abcc2b..9c34a155e1024988a9f06c648704021b55500903 100644 (file)
@@ -13,7 +13,7 @@ struct xe_gt;
 
 int xe_gt_idle_init(struct xe_gt_idle *gtidle);
 void xe_gt_idle_enable_c6(struct xe_gt *gt);
-void xe_gt_idle_disable_c6(struct xe_gt *gt);
+int xe_gt_idle_disable_c6(struct xe_gt *gt);
 void xe_gt_idle_enable_pg(struct xe_gt *gt);
 void xe_gt_idle_disable_pg(struct xe_gt *gt);
 int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p);
index 0f8430acd16dc2fcd2bcd05092d428cbab6ff441..88557e86d63714378d7d40e6dcd0ad8e99cd6db2 100644 (file)
@@ -1076,7 +1076,6 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
 {
        struct xe_device *xe = pc_to_xe(pc);
        struct xe_gt *gt = pc_to_gt(pc);
-       unsigned int fw_ref;
        int ret = 0;
 
        if (xe->info.skip_guc_pc)
@@ -1086,17 +1085,7 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
        if (ret)
                return ret;
 
-       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
-       if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) {
-               xe_force_wake_put(gt_to_fw(gt), fw_ref);
-               return -ETIMEDOUT;
-       }
-
-       xe_gt_idle_disable_c6(gt);
-
-       xe_force_wake_put(gt_to_fw(gt), fw_ref);
-
-       return 0;
+       return xe_gt_idle_disable_c6(gt);
 }
 
 /**