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

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Add a wrapper for SLPC set/unset params

Also, extract out the GuC RC related set/unset param functions
into xe_guc_rc file. GuC still allows us to override GuC RC mode
using an SLPC H2G interface. Continue to use that interface, but
move the related code to the newly created xe_guc_rc file.

Cc: Riana Tauro <riana.tauro@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Riana Tauro <riana.tauro@intel.com>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Link: https://patch.msgid.link/20260204014234.2867763-4-vinay.belgaumkar@intel.com

+70 -33
+31 -25
drivers/gpu/drm/xe/xe_guc_pc.c
··· 264 264 return ret; 265 265 } 266 266 267 + /** 268 + * xe_guc_pc_action_set_param() - Set value of SLPC param 269 + * @pc: Xe_GuC_PC instance 270 + * @id: Param id 271 + * @value: Value to set 272 + * 273 + * This function can be used to set any SLPC param. 274 + * 275 + * Return: 0 on Success 276 + */ 277 + int xe_guc_pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value) 278 + { 279 + xe_device_assert_mem_access(pc_to_xe(pc)); 280 + return pc_action_set_param(pc, id, value); 281 + } 282 + 283 + /** 284 + * xe_guc_pc_action_unset_param() - Revert to default value 285 + * @pc: Xe_GuC_PC instance 286 + * @id: Param id 287 + * 288 + * This function can be used revert any SLPC param to its default value. 289 + * 290 + * Return: 0 on Success 291 + */ 292 + int xe_guc_pc_action_unset_param(struct xe_guc_pc *pc, u8 id) 293 + { 294 + xe_device_assert_mem_access(pc_to_xe(pc)); 295 + return pc_action_unset_param(pc, id); 296 + } 297 + 267 298 static u32 decode_freq(u32 raw) 268 299 { 269 300 return DIV_ROUND_CLOSEST(raw * GT_FREQUENCY_MULTIPLIER, ··· 1074 1043 mutex_unlock(&pc->freq_lock); 1075 1044 1076 1045 return ret; 1077 - } 1078 - 1079 - /** 1080 - * xe_guc_pc_override_gucrc_mode - override GUCRC mode 1081 - * @pc: Xe_GuC_PC instance 1082 - * @mode: new value of the mode. 1083 - * 1084 - * Return: 0 on success, negative error code on error 1085 - */ 1086 - int xe_guc_pc_override_gucrc_mode(struct xe_guc_pc *pc, enum slpc_gucrc_mode mode) 1087 - { 1088 - guard(xe_pm_runtime)(pc_to_xe(pc)); 1089 - return pc_action_set_param(pc, SLPC_PARAM_PWRGATE_RC_MODE, mode); 1090 - } 1091 - 1092 - /** 1093 - * xe_guc_pc_unset_gucrc_mode - unset GUCRC mode override 1094 - * @pc: Xe_GuC_PC instance 1095 - * 1096 - * Return: 0 on success, negative error code on error 1097 - */ 1098 - int xe_guc_pc_unset_gucrc_mode(struct xe_guc_pc *pc) 1099 - { 1100 - guard(xe_pm_runtime)(pc_to_xe(pc)); 1101 - return pc_action_unset_param(pc, SLPC_PARAM_PWRGATE_RC_MODE); 1102 1046 } 1103 1047 1104 1048 static void pc_init_pcode_freq(struct xe_guc_pc *pc)
+2 -3
drivers/gpu/drm/xe/xe_guc_pc.h
··· 9 9 #include <linux/types.h> 10 10 11 11 struct xe_guc_pc; 12 - enum slpc_gucrc_mode; 13 12 struct drm_printer; 14 13 15 14 int xe_guc_pc_init(struct xe_guc_pc *pc); 16 15 int xe_guc_pc_start(struct xe_guc_pc *pc); 17 16 int xe_guc_pc_stop(struct xe_guc_pc *pc); 18 - int xe_guc_pc_override_gucrc_mode(struct xe_guc_pc *pc, enum slpc_gucrc_mode mode); 19 - int xe_guc_pc_unset_gucrc_mode(struct xe_guc_pc *pc); 20 17 void xe_guc_pc_print(struct xe_guc_pc *pc, struct drm_printer *p); 18 + int xe_guc_pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value); 19 + int xe_guc_pc_action_unset_param(struct xe_guc_pc *pc, u8 id); 21 20 22 21 u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc); 23 22 int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq);
+30
drivers/gpu/drm/xe/xe_guc_rc.c
··· 13 13 #include "xe_gt_printk.h" 14 14 #include "xe_guc.h" 15 15 #include "xe_guc_ct.h" 16 + #include "xe_guc_pc.h" 16 17 #include "xe_guc_rc.h" 17 18 #include "xe_pm.h" 18 19 ··· 128 127 } 129 128 130 129 return guc_action_setup_gucrc(guc, GUCRC_FIRMWARE_CONTROL); 130 + } 131 + 132 + /** 133 + * xe_guc_rc_set_mode() - set new GUCRC mode 134 + * @guc: Xe GuC instance 135 + * @mode: new value of the mode. 136 + * 137 + * Function to set GuC RC mode to one of the enum values. 138 + * 139 + * Returns: 0 on success, negative error code on error 140 + */ 141 + int xe_guc_rc_set_mode(struct xe_guc *guc, enum slpc_gucrc_mode mode) 142 + { 143 + guard(xe_pm_runtime_noresume)(guc_to_xe(guc)); 144 + return xe_guc_pc_action_set_param(&guc->pc, SLPC_PARAM_PWRGATE_RC_MODE, mode); 145 + } 146 + 147 + /** 148 + * xe_guc_rc_unset_mode() - revert to default mode 149 + * @guc: Xe GuC instance 150 + * 151 + * Function to revert GuC RC mode to platform defaults. 152 + * 153 + * Returns: 0 on success, negative error code on error 154 + */ 155 + int xe_guc_rc_unset_mode(struct xe_guc *guc) 156 + { 157 + guard(xe_pm_runtime_noresume)(guc_to_xe(guc)); 158 + return xe_guc_pc_action_unset_param(&guc->pc, SLPC_PARAM_PWRGATE_RC_MODE); 131 159 }
+3
drivers/gpu/drm/xe/xe_guc_rc.h
··· 7 7 #define _XE_GUC_RC_H_ 8 8 9 9 struct xe_guc; 10 + enum slpc_gucrc_mode; 10 11 11 12 int xe_guc_rc_init(struct xe_guc *guc); 12 13 int xe_guc_rc_enable(struct xe_guc *guc); 13 14 void xe_guc_rc_disable(struct xe_guc *guc); 15 + int xe_guc_rc_set_mode(struct xe_guc *guc, enum slpc_gucrc_mode mode); 16 + int xe_guc_rc_unset_mode(struct xe_guc *guc); 14 17 15 18 #endif
+4 -5
drivers/gpu/drm/xe/xe_oa.c
··· 29 29 #include "xe_gt.h" 30 30 #include "xe_gt_mcr.h" 31 31 #include "xe_gt_printk.h" 32 - #include "xe_guc_pc.h" 32 + #include "xe_guc_rc.h" 33 33 #include "xe_macros.h" 34 34 #include "xe_mmio.h" 35 35 #include "xe_oa.h" ··· 875 875 876 876 /* Wa_1509372804:pvc: Unset the override of GUCRC mode to enable rc6 */ 877 877 if (stream->override_gucrc) 878 - xe_gt_WARN_ON(gt, xe_guc_pc_unset_gucrc_mode(&gt->uc.guc.pc)); 878 + xe_gt_WARN_ON(gt, xe_guc_rc_unset_mode(&gt->uc.guc)); 879 879 880 880 xe_oa_free_configs(stream); 881 881 xe_file_put(stream->xef); ··· 1765 1765 * state. Prevent this by overriding GUCRC mode. 1766 1766 */ 1767 1767 if (XE_GT_WA(stream->gt, 1509372804)) { 1768 - ret = xe_guc_pc_override_gucrc_mode(&gt->uc.guc.pc, 1769 - SLPC_GUCRC_MODE_GUCRC_NO_RC6); 1768 + ret = xe_guc_rc_set_mode(&gt->uc.guc, SLPC_GUCRC_MODE_GUCRC_NO_RC6); 1770 1769 if (ret) 1771 1770 goto err_free_configs; 1772 1771 ··· 1823 1824 xe_force_wake_put(gt_to_fw(gt), stream->fw_ref); 1824 1825 xe_pm_runtime_put(stream->oa->xe); 1825 1826 if (stream->override_gucrc) 1826 - xe_gt_WARN_ON(gt, xe_guc_pc_unset_gucrc_mode(&gt->uc.guc.pc)); 1827 + xe_gt_WARN_ON(gt, xe_guc_rc_unset_mode(&gt->uc.guc)); 1827 1828 err_free_configs: 1828 1829 xe_oa_free_configs(stream); 1829 1830 exit: