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

drm/xe: Introduce the RPa information

RPa is the Achievable frequency, defined by PCODE at runtime
based on multiple running conditions.

v2: Remove RPA_MASK from i915 file

Cc: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Reviewed-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241220152936.623627-1-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

+73 -2
+4
drivers/gpu/drm/xe/regs/xe_regs.h
··· 44 44 45 45 #define MTL_RP_STATE_CAP XE_REG(0x138000) 46 46 47 + #define MTL_GT_RPA_FREQUENCY XE_REG(0x138008) 47 48 #define MTL_GT_RPE_FREQUENCY XE_REG(0x13800c) 48 49 49 50 #define MTL_MEDIAP_STATE_CAP XE_REG(0x138020) 50 51 #define MTL_RPN_CAP_MASK REG_GENMASK(24, 16) 51 52 #define MTL_RP0_CAP_MASK REG_GENMASK(8, 0) 53 + 54 + #define MTL_MPA_FREQUENCY XE_REG(0x138028) 55 + #define MTL_RPA_MASK REG_GENMASK(8, 0) 52 56 53 57 #define MTL_MPE_FREQUENCY XE_REG(0x13802c) 54 58 #define MTL_RPE_MASK REG_GENMASK(8, 0)
+15
drivers/gpu/drm/xe/xe_gt_freq.c
··· 115 115 } 116 116 static DEVICE_ATTR_RO(rpe_freq); 117 117 118 + static ssize_t rpa_freq_show(struct device *dev, 119 + struct device_attribute *attr, char *buf) 120 + { 121 + struct xe_guc_pc *pc = dev_to_pc(dev); 122 + u32 freq; 123 + 124 + xe_pm_runtime_get(dev_to_xe(dev)); 125 + freq = xe_guc_pc_get_rpa_freq(pc); 126 + xe_pm_runtime_put(dev_to_xe(dev)); 127 + 128 + return sysfs_emit(buf, "%d\n", freq); 129 + } 130 + static DEVICE_ATTR_RO(rpa_freq); 131 + 118 132 static ssize_t rpn_freq_show(struct device *dev, 119 133 struct device_attribute *attr, char *buf) 120 134 { ··· 216 202 &dev_attr_act_freq.attr, 217 203 &dev_attr_cur_freq.attr, 218 204 &dev_attr_rp0_freq.attr, 205 + &dev_attr_rpa_freq.attr, 219 206 &dev_attr_rpe_freq.attr, 220 207 &dev_attr_rpn_freq.attr, 221 208 &dev_attr_min_freq.attr,
+51 -2
drivers/gpu/drm/xe/xe_guc_pc.c
··· 38 38 39 39 #define FREQ_INFO_REC XE_REG(MCHBAR_MIRROR_BASE_SNB + 0x5ef0) 40 40 #define RPE_MASK REG_GENMASK(15, 8) 41 + #define RPA_MASK REG_GENMASK(31, 16) 41 42 42 43 #define GT_PERF_STATUS XE_REG(0x1381b4) 43 44 #define CAGF_MASK REG_GENMASK(19, 11) ··· 329 328 freq); 330 329 } 331 330 331 + static void mtl_update_rpa_value(struct xe_guc_pc *pc) 332 + { 333 + struct xe_gt *gt = pc_to_gt(pc); 334 + u32 reg; 335 + 336 + if (xe_gt_is_media_type(gt)) 337 + reg = xe_mmio_read32(&gt->mmio, MTL_MPA_FREQUENCY); 338 + else 339 + reg = xe_mmio_read32(&gt->mmio, MTL_GT_RPA_FREQUENCY); 340 + 341 + pc->rpa_freq = decode_freq(REG_FIELD_GET(MTL_RPA_MASK, reg)); 342 + } 343 + 332 344 static void mtl_update_rpe_value(struct xe_guc_pc *pc) 333 345 { 334 346 struct xe_gt *gt = pc_to_gt(pc); ··· 353 339 reg = xe_mmio_read32(&gt->mmio, MTL_GT_RPE_FREQUENCY); 354 340 355 341 pc->rpe_freq = decode_freq(REG_FIELD_GET(MTL_RPE_MASK, reg)); 342 + } 343 + 344 + static void tgl_update_rpa_value(struct xe_guc_pc *pc) 345 + { 346 + struct xe_gt *gt = pc_to_gt(pc); 347 + struct xe_device *xe = gt_to_xe(gt); 348 + u32 reg; 349 + 350 + /* 351 + * For PVC we still need to use fused RP1 as the approximation for RPe 352 + * For other platforms than PVC we get the resolved RPe directly from 353 + * PCODE at a different register 354 + */ 355 + if (xe->info.platform == XE_PVC) 356 + reg = xe_mmio_read32(&gt->mmio, PVC_RP_STATE_CAP); 357 + else 358 + reg = xe_mmio_read32(&gt->mmio, FREQ_INFO_REC); 359 + 360 + pc->rpa_freq = REG_FIELD_GET(RPA_MASK, reg) * GT_FREQUENCY_MULTIPLIER; 356 361 } 357 362 358 363 static void tgl_update_rpe_value(struct xe_guc_pc *pc) ··· 398 365 struct xe_gt *gt = pc_to_gt(pc); 399 366 struct xe_device *xe = gt_to_xe(gt); 400 367 401 - if (GRAPHICS_VERx100(xe) >= 1270) 368 + if (GRAPHICS_VERx100(xe) >= 1270) { 369 + mtl_update_rpa_value(pc); 402 370 mtl_update_rpe_value(pc); 403 - else 371 + } else { 372 + tgl_update_rpa_value(pc); 404 373 tgl_update_rpe_value(pc); 374 + } 405 375 406 376 /* 407 377 * RPe is decided at runtime by PCODE. In the rare case where that's ··· 481 445 u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc) 482 446 { 483 447 return pc->rp0_freq; 448 + } 449 + 450 + /** 451 + * xe_guc_pc_get_rpa_freq - Get the RPa freq 452 + * @pc: The GuC PC 453 + * 454 + * Returns: RPa freq. 455 + */ 456 + u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc) 457 + { 458 + pc_update_rp_values(pc); 459 + 460 + return pc->rpa_freq; 484 461 } 485 462 486 463 /**
+1
drivers/gpu/drm/xe/xe_guc_pc.h
··· 21 21 u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc); 22 22 int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq); 23 23 u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc); 24 + u32 xe_guc_pc_get_rpa_freq(struct xe_guc_pc *pc); 24 25 u32 xe_guc_pc_get_rpe_freq(struct xe_guc_pc *pc); 25 26 u32 xe_guc_pc_get_rpn_freq(struct xe_guc_pc *pc); 26 27 int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq);
+2
drivers/gpu/drm/xe/xe_guc_pc_types.h
··· 17 17 struct xe_bo *bo; 18 18 /** @rp0_freq: HW RP0 frequency - The Maximum one */ 19 19 u32 rp0_freq; 20 + /** @rpa_freq: HW RPa frequency - The Achievable one */ 21 + u32 rpa_freq; 20 22 /** @rpe_freq: HW RPe frequency - The Efficient one */ 21 23 u32 rpe_freq; 22 24 /** @rpn_freq: HW RPN frequency - The Minimum one */