Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: make xe_gt_idle_disable_c6() handle the forcewake internally

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>

authored by

Xin Wang and committed by
Rodrigo Vivi
1313351e d738e1be

+15 -21
+13 -8
drivers/gpu/drm/xe/xe_gt_idle.c
··· 322 322 { 323 323 struct kobject *kobj = arg; 324 324 struct xe_gt *gt = kobj_to_gt(kobj->parent); 325 - unsigned int fw_ref; 326 325 327 326 xe_gt_idle_disable_pg(gt); 328 327 329 - if (gt_to_xe(gt)->info.skip_guc_pc) { 330 - fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); 328 + if (gt_to_xe(gt)->info.skip_guc_pc) 331 329 xe_gt_idle_disable_c6(gt); 332 - xe_force_wake_put(gt_to_fw(gt), fw_ref); 333 - } 334 330 335 331 sysfs_remove_files(kobj, gt_idle_attrs); 336 332 kobject_put(kobj); ··· 386 390 RC_CTL_HW_ENABLE | RC_CTL_TO_MODE | RC_CTL_RC6_ENABLE); 387 391 } 388 392 389 - void xe_gt_idle_disable_c6(struct xe_gt *gt) 393 + int xe_gt_idle_disable_c6(struct xe_gt *gt) 390 394 { 395 + unsigned int fw_ref; 396 + 391 397 xe_device_assert_mem_access(gt_to_xe(gt)); 392 - xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GT); 393 398 394 399 if (IS_SRIOV_VF(gt_to_xe(gt))) 395 - return; 400 + return 0; 401 + 402 + fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); 403 + if (!fw_ref) 404 + return -ETIMEDOUT; 396 405 397 406 xe_mmio_write32(&gt->mmio, RC_CONTROL, 0); 398 407 xe_mmio_write32(&gt->mmio, RC_STATE, 0); 408 + 409 + xe_force_wake_put(gt_to_fw(gt), fw_ref); 410 + 411 + return 0; 399 412 }
+1 -1
drivers/gpu/drm/xe/xe_gt_idle.h
··· 13 13 14 14 int xe_gt_idle_init(struct xe_gt_idle *gtidle); 15 15 void xe_gt_idle_enable_c6(struct xe_gt *gt); 16 - void xe_gt_idle_disable_c6(struct xe_gt *gt); 16 + int xe_gt_idle_disable_c6(struct xe_gt *gt); 17 17 void xe_gt_idle_enable_pg(struct xe_gt *gt); 18 18 void xe_gt_idle_disable_pg(struct xe_gt *gt); 19 19 int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p);
+1 -12
drivers/gpu/drm/xe/xe_guc_pc.c
··· 1076 1076 { 1077 1077 struct xe_device *xe = pc_to_xe(pc); 1078 1078 struct xe_gt *gt = pc_to_gt(pc); 1079 - unsigned int fw_ref; 1080 1079 int ret = 0; 1081 1080 1082 1081 if (xe->info.skip_guc_pc) ··· 1085 1086 if (ret) 1086 1087 return ret; 1087 1088 1088 - fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); 1089 - if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) { 1090 - xe_force_wake_put(gt_to_fw(gt), fw_ref); 1091 - return -ETIMEDOUT; 1092 - } 1093 - 1094 - xe_gt_idle_disable_c6(gt); 1095 - 1096 - xe_force_wake_put(gt_to_fw(gt), fw_ref); 1097 - 1098 - return 0; 1089 + return xe_gt_idle_disable_c6(gt); 1099 1090 } 1100 1091 1101 1092 /**