1 // SPDX-License-Identifier: MIT 2 3 /* 4 * Copyright © 2019 Intel Corporation 5 */ 6 7 #include <linux/seq_file.h> 8 #include <linux/string_helpers.h> 9 10 #include "i915_drv.h" 11 #include "i915_reg.h" 12 #include "intel_gt.h" 13 #include "intel_gt_clock_utils.h" 14 #include "intel_gt_debugfs.h" 15 #include "intel_gt_pm.h" 16 #include "intel_gt_pm_debugfs.h" 17 #include "intel_gt_regs.h" 18 #include "intel_llc.h" 19 #include "intel_mchbar_regs.h" 20 #include "intel_pcode.h" 21 #include "intel_rc6.h" 22 #include "intel_rps.h" 23 #include "intel_runtime_pm.h" 24 #include "intel_uncore.h" 25 #include "vlv_sideband.h" 26 27 void intel_gt_pm_debugfs_forcewake_user_open(struct intel_gt *gt) 28 { 29 atomic_inc(>->user_wakeref); 30 intel_gt_pm_get_untracked(gt); 31 if (GRAPHICS_VER(gt->i915) >= 6) 32 intel_uncore_forcewake_user_get(gt->uncore); 33 } 34 35 void intel_gt_pm_debugfs_forcewake_user_release(struct intel_gt *gt) 36 { 37 if (GRAPHICS_VER(gt->i915) >= 6) 38 intel_uncore_forcewake_user_put(gt->uncore); 39 intel_gt_pm_put_untracked(gt); 40 atomic_dec(>->user_wakeref); 41 } 42 43 static int forcewake_user_open(struct inode *inode, struct file *file) 44 { 45 struct intel_gt *gt = inode->i_private; 46 47 intel_gt_pm_debugfs_forcewake_user_open(gt); 48 49 return 0; 50 } 51 52 static int forcewake_user_release(struct inode *inode, struct file *file) 53 { 54 struct intel_gt *gt = inode->i_private; 55 56 intel_gt_pm_debugfs_forcewake_user_release(gt); 57 58 return 0; 59 } 60 61 static const struct file_operations forcewake_user_fops = { 62 .owner = THIS_MODULE, 63 .open = forcewake_user_open, 64 .release = forcewake_user_release, 65 }; 66 67 static int fw_domains_show(struct seq_file *m, void *data) 68 { 69 struct intel_gt *gt = m->private; 70 struct intel_uncore *uncore = gt->uncore; 71 struct intel_uncore_forcewake_domain *fw_domain; 72 unsigned int tmp; 73 74 seq_printf(m, "user.bypass_count = %u\n", 75 uncore->user_forcewake_count); 76 77 for_each_fw_domain(fw_domain, uncore, tmp) 78 seq_printf(m, "%s.wake_count = %u\n", 79 intel_uncore_forcewake_domain_to_str(fw_domain->id), 80 READ_ONCE(fw_domain->wake_count)); 81 82 return 0; 83 } 84 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(fw_domains); 85 86 static int vlv_drpc(struct seq_file *m) 87 { 88 struct intel_gt *gt = m->private; 89 struct intel_uncore *uncore = gt->uncore; 90 u32 rcctl1, pw_status, mt_fwake_req; 91 92 mt_fwake_req = intel_uncore_read_fw(uncore, FORCEWAKE_MT); 93 pw_status = intel_uncore_read(uncore, VLV_GTLC_PW_STATUS); 94 rcctl1 = intel_uncore_read(uncore, GEN6_RC_CONTROL); 95 96 seq_printf(m, "RC6 Enabled: %s\n", 97 str_yes_no(rcctl1 & (GEN7_RC_CTL_TO_MODE | 98 GEN6_RC_CTL_EI_MODE(1)))); 99 seq_printf(m, "Multi-threaded Forcewake Request: 0x%x\n", mt_fwake_req); 100 seq_printf(m, "Render Power Well: %s\n", 101 (pw_status & VLV_GTLC_PW_RENDER_STATUS_MASK) ? "Up" : "Down"); 102 seq_printf(m, "Media Power Well: %s\n", 103 (pw_status & VLV_GTLC_PW_MEDIA_STATUS_MASK) ? "Up" : "Down"); 104 105 intel_rc6_print_residency(m, "Render RC6 residency since boot:", INTEL_RC6_RES_RC6); 106 intel_rc6_print_residency(m, "Media RC6 residency since boot:", INTEL_RC6_RES_VLV_MEDIA); 107 108 return fw_domains_show(m, NULL); 109 } 110 111 static int gen6_drpc(struct seq_file *m) 112 { 113 struct intel_gt *gt = m->private; 114 struct drm_i915_private *i915 = gt->i915; 115 struct intel_uncore *uncore = gt->uncore; 116 u32 gt_core_status, mt_fwake_req, rcctl1, rc6vids = 0; 117 u32 gen9_powergate_enable = 0, gen9_powergate_status = 0; 118 119 mt_fwake_req = intel_uncore_read_fw(uncore, FORCEWAKE_MT); 120 gt_core_status = intel_uncore_read_fw(uncore, GEN6_GT_CORE_STATUS); 121 122 rcctl1 = intel_uncore_read(uncore, GEN6_RC_CONTROL); 123 if (GRAPHICS_VER(i915) >= 9) { 124 gen9_powergate_enable = 125 intel_uncore_read(uncore, GEN9_PG_ENABLE); 126 gen9_powergate_status = 127 intel_uncore_read(uncore, GEN9_PWRGT_DOMAIN_STATUS); 128 } 129 130 if (GRAPHICS_VER(i915) <= 7) 131 snb_pcode_read(gt->uncore, GEN6_PCODE_READ_RC6VIDS, &rc6vids, NULL); 132 133 seq_printf(m, "RC1e Enabled: %s\n", 134 str_yes_no(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE)); 135 seq_printf(m, "RC6 Enabled: %s\n", 136 str_yes_no(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); 137 if (GRAPHICS_VER(i915) >= 9) { 138 seq_printf(m, "Render Well Gating Enabled: %s\n", 139 str_yes_no(gen9_powergate_enable & GEN9_RENDER_PG_ENABLE)); 140 seq_printf(m, "Media Well Gating Enabled: %s\n", 141 str_yes_no(gen9_powergate_enable & GEN9_MEDIA_PG_ENABLE)); 142 } 143 seq_printf(m, "Deep RC6 Enabled: %s\n", 144 str_yes_no(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE)); 145 seq_printf(m, "Deepest RC6 Enabled: %s\n", 146 str_yes_no(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE)); 147 seq_puts(m, "Current RC state: "); 148 switch (gt_core_status & GEN6_RCn_MASK) { 149 case GEN6_RC0: 150 if (gt_core_status & GEN6_CORE_CPD_STATE_MASK) 151 seq_puts(m, "Core Power Down\n"); 152 else 153 seq_puts(m, "on\n"); 154 break; 155 case GEN6_RC3: 156 seq_puts(m, "RC3\n"); 157 break; 158 case GEN6_RC6: 159 seq_puts(m, "RC6\n"); 160 break; 161 case GEN6_RC7: 162 seq_puts(m, "RC7\n"); 163 break; 164 default: 165 seq_puts(m, "Unknown\n"); 166 break; 167 } 168 169 seq_printf(m, "Core Power Down: %s\n", 170 str_yes_no(gt_core_status & GEN6_CORE_CPD_STATE_MASK)); 171 seq_printf(m, "Multi-threaded Forcewake Request: 0x%x\n", mt_fwake_req); 172 if (GRAPHICS_VER(i915) >= 9) { 173 seq_printf(m, "Render Power Well: %s\n", 174 (gen9_powergate_status & 175 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); 176 seq_printf(m, "Media Power Well: %s\n", 177 (gen9_powergate_status & 178 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); 179 } 180 181 /* Not exactly sure what this is */ 182 intel_rc6_print_residency(m, "RC6 \"Locked to RPn\" residency since boot:", 183 INTEL_RC6_RES_RC6_LOCKED); 184 intel_rc6_print_residency(m, "RC6 residency since boot:", INTEL_RC6_RES_RC6); 185 intel_rc6_print_residency(m, "RC6+ residency since boot:", INTEL_RC6_RES_RC6p); 186 intel_rc6_print_residency(m, "RC6++ residency since boot:", INTEL_RC6_RES_RC6pp); 187 188 if (GRAPHICS_VER(i915) <= 7) { 189 seq_printf(m, "RC6 voltage: %dmV\n", 190 GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff))); 191 seq_printf(m, "RC6+ voltage: %dmV\n", 192 GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff))); 193 seq_printf(m, "RC6++ voltage: %dmV\n", 194 GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff))); 195 } 196 197 return fw_domains_show(m, NULL); 198 } 199 200 static int ilk_drpc(struct seq_file *m) 201 { 202 struct intel_gt *gt = m->private; 203 struct intel_uncore *uncore = gt->uncore; 204 u32 rgvmodectl, rstdbyctl; 205 u16 crstandvid; 206 207 rgvmodectl = intel_uncore_read(uncore, MEMMODECTL); 208 rstdbyctl = intel_uncore_read(uncore, RSTDBYCTL); 209 crstandvid = intel_uncore_read16(uncore, CRSTANDVID); 210 211 seq_printf(m, "HD boost: %s\n", 212 str_yes_no(rgvmodectl & MEMMODE_BOOST_EN)); 213 seq_printf(m, "Boost freq: %d\n", 214 (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >> 215 MEMMODE_BOOST_FREQ_SHIFT); 216 seq_printf(m, "HW control enabled: %s\n", 217 str_yes_no(rgvmodectl & MEMMODE_HWIDLE_EN)); 218 seq_printf(m, "SW control enabled: %s\n", 219 str_yes_no(rgvmodectl & MEMMODE_SWMODE_EN)); 220 seq_printf(m, "Gated voltage change: %s\n", 221 str_yes_no(rgvmodectl & MEMMODE_RCLK_GATE)); 222 seq_printf(m, "Starting frequency: P%d\n", 223 (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT); 224 seq_printf(m, "Max P-state: P%d\n", 225 (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT); 226 seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK)); 227 seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f)); 228 seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f)); 229 seq_printf(m, "Render standby enabled: %s\n", 230 str_yes_no(!(rstdbyctl & RCX_SW_EXIT))); 231 seq_puts(m, "Current RS state: "); 232 switch (rstdbyctl & RSX_STATUS_MASK) { 233 case RSX_STATUS_ON: 234 seq_puts(m, "on\n"); 235 break; 236 case RSX_STATUS_RC1: 237 seq_puts(m, "RC1\n"); 238 break; 239 case RSX_STATUS_RC1E: 240 seq_puts(m, "RC1E\n"); 241 break; 242 case RSX_STATUS_RS1: 243 seq_puts(m, "RS1\n"); 244 break; 245 case RSX_STATUS_RS2: 246 seq_puts(m, "RS2 (RC6)\n"); 247 break; 248 case RSX_STATUS_RS3: 249 seq_puts(m, "RC3 (RC6+)\n"); 250 break; 251 default: 252 seq_puts(m, "unknown\n"); 253 break; 254 } 255 256 return 0; 257 } 258 259 static int mtl_drpc(struct seq_file *m) 260 { 261 struct intel_gt *gt = m->private; 262 struct intel_uncore *uncore = gt->uncore; 263 u32 gt_core_status, rcctl1, mt_fwake_req; 264 u32 mtl_powergate_enable = 0, mtl_powergate_status = 0; 265 266 mt_fwake_req = intel_uncore_read_fw(uncore, FORCEWAKE_MT); 267 gt_core_status = intel_uncore_read(uncore, MTL_MIRROR_TARGET_WP1); 268 269 rcctl1 = intel_uncore_read(uncore, GEN6_RC_CONTROL); 270 mtl_powergate_enable = intel_uncore_read(uncore, GEN9_PG_ENABLE); 271 mtl_powergate_status = intel_uncore_read(uncore, 272 GEN9_PWRGT_DOMAIN_STATUS); 273 274 seq_printf(m, "RC6 Enabled: %s\n", 275 str_yes_no(rcctl1 & GEN6_RC_CTL_RC6_ENABLE)); 276 if (gt->type == GT_MEDIA) { 277 seq_printf(m, "Media Well Gating Enabled: %s\n", 278 str_yes_no(mtl_powergate_enable & GEN9_MEDIA_PG_ENABLE)); 279 } else { 280 seq_printf(m, "Render Well Gating Enabled: %s\n", 281 str_yes_no(mtl_powergate_enable & GEN9_RENDER_PG_ENABLE)); 282 } 283 284 seq_puts(m, "Current RC state: "); 285 switch (REG_FIELD_GET(MTL_CC_MASK, gt_core_status)) { 286 case MTL_CC0: 287 seq_puts(m, "RC0\n"); 288 break; 289 case MTL_CC6: 290 seq_puts(m, "RC6\n"); 291 break; 292 default: 293 seq_puts(m, "Unknown\n"); 294 break; 295 } 296 297 seq_printf(m, "Multi-threaded Forcewake Request: 0x%x\n", mt_fwake_req); 298 if (gt->type == GT_MEDIA) 299 seq_printf(m, "Media Power Well: %s\n", 300 (mtl_powergate_status & 301 GEN9_PWRGT_MEDIA_STATUS_MASK) ? "Up" : "Down"); 302 else 303 seq_printf(m, "Render Power Well: %s\n", 304 (mtl_powergate_status & 305 GEN9_PWRGT_RENDER_STATUS_MASK) ? "Up" : "Down"); 306 307 /* Works for both render and media gt's */ 308 intel_rc6_print_residency(m, "RC6 residency since boot:", INTEL_RC6_RES_RC6); 309 310 return fw_domains_show(m, NULL); 311 } 312 313 static int drpc_show(struct seq_file *m, void *unused) 314 { 315 struct intel_gt *gt = m->private; 316 struct drm_i915_private *i915 = gt->i915; 317 intel_wakeref_t wakeref; 318 int err = -ENODEV; 319 320 with_intel_runtime_pm(gt->uncore->rpm, wakeref) { 321 if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70)) 322 err = mtl_drpc(m); 323 else if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) 324 err = vlv_drpc(m); 325 else if (GRAPHICS_VER(i915) >= 6) 326 err = gen6_drpc(m); 327 else 328 err = ilk_drpc(m); 329 } 330 331 return err; 332 } 333 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(drpc); 334 335 void intel_gt_pm_frequency_dump(struct intel_gt *gt, struct drm_printer *p) 336 { 337 struct drm_i915_private *i915 = gt->i915; 338 struct intel_uncore *uncore = gt->uncore; 339 struct intel_rps *rps = >->rps; 340 intel_wakeref_t wakeref; 341 342 wakeref = intel_runtime_pm_get(uncore->rpm); 343 344 if (GRAPHICS_VER(i915) == 5) { 345 u16 rgvswctl = intel_uncore_read16(uncore, MEMSWCTL); 346 u16 rgvstat = intel_uncore_read16(uncore, MEMSTAT_ILK); 347 348 drm_printf(p, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf); 349 drm_printf(p, "Requested VID: %d\n", rgvswctl & 0x3f); 350 drm_printf(p, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >> 351 MEMSTAT_VID_SHIFT); 352 drm_printf(p, "Current P-state: %d\n", 353 REG_FIELD_GET(MEMSTAT_PSTATE_MASK, rgvstat)); 354 } else if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) { 355 u32 rpmodectl, freq_sts; 356 357 rpmodectl = intel_uncore_read(uncore, GEN6_RP_CONTROL); 358 drm_printf(p, "Video Turbo Mode: %s\n", 359 str_yes_no(rpmodectl & GEN6_RP_MEDIA_TURBO)); 360 drm_printf(p, "HW control enabled: %s\n", 361 str_yes_no(rpmodectl & GEN6_RP_ENABLE)); 362 drm_printf(p, "SW control enabled: %s\n", 363 str_yes_no((rpmodectl & GEN6_RP_MEDIA_MODE_MASK) == GEN6_RP_MEDIA_SW_MODE)); 364 365 vlv_punit_get(i915); 366 freq_sts = vlv_punit_read(i915, PUNIT_REG_GPU_FREQ_STS); 367 vlv_punit_put(i915); 368 369 drm_printf(p, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts); 370 drm_printf(p, "DDR freq: %d MHz\n", i915->mem_freq); 371 372 drm_printf(p, "actual GPU freq: %d MHz\n", 373 intel_gpu_freq(rps, (freq_sts >> 8) & 0xff)); 374 375 drm_printf(p, "current GPU freq: %d MHz\n", 376 intel_gpu_freq(rps, rps->cur_freq)); 377 378 drm_printf(p, "max GPU freq: %d MHz\n", 379 intel_gpu_freq(rps, rps->max_freq)); 380 381 drm_printf(p, "min GPU freq: %d MHz\n", 382 intel_gpu_freq(rps, rps->min_freq)); 383 384 drm_printf(p, "idle GPU freq: %d MHz\n", 385 intel_gpu_freq(rps, rps->idle_freq)); 386 387 drm_printf(p, "efficient (RPe) frequency: %d MHz\n", 388 intel_gpu_freq(rps, rps->efficient_freq)); 389 } else if (GRAPHICS_VER(i915) >= 6) { 390 gen6_rps_frequency_dump(rps, p); 391 } else { 392 drm_puts(p, "no P-state info available\n"); 393 } 394 395 intel_runtime_pm_put(uncore->rpm, wakeref); 396 } 397 398 static int frequency_show(struct seq_file *m, void *unused) 399 { 400 struct intel_gt *gt = m->private; 401 struct drm_printer p = drm_seq_file_printer(m); 402 403 intel_gt_pm_frequency_dump(gt, &p); 404 405 return 0; 406 } 407 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(frequency); 408 409 static int llc_show(struct seq_file *m, void *data) 410 { 411 struct intel_gt *gt = m->private; 412 struct drm_i915_private *i915 = gt->i915; 413 const bool edram = GRAPHICS_VER(i915) > 8; 414 struct intel_rps *rps = >->rps; 415 unsigned int max_gpu_freq, min_gpu_freq; 416 intel_wakeref_t wakeref; 417 int gpu_freq, ia_freq; 418 419 seq_printf(m, "LLC: %s\n", str_yes_no(HAS_LLC(i915))); 420 seq_printf(m, "%s: %uMB\n", edram ? "eDRAM" : "eLLC", 421 i915->edram_size_mb); 422 423 min_gpu_freq = rps->min_freq; 424 max_gpu_freq = rps->max_freq; 425 if (IS_GEN9_BC(i915) || GRAPHICS_VER(i915) >= 11) { 426 /* Convert GT frequency to 50 HZ units */ 427 min_gpu_freq /= GEN9_FREQ_SCALER; 428 max_gpu_freq /= GEN9_FREQ_SCALER; 429 } 430 431 seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n"); 432 433 wakeref = intel_runtime_pm_get(gt->uncore->rpm); 434 for (gpu_freq = min_gpu_freq; gpu_freq <= max_gpu_freq; gpu_freq++) { 435 ia_freq = gpu_freq; 436 snb_pcode_read(gt->uncore, GEN6_PCODE_READ_MIN_FREQ_TABLE, 437 &ia_freq, NULL); 438 seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", 439 intel_gpu_freq(rps, 440 (gpu_freq * 441 (IS_GEN9_BC(i915) || 442 GRAPHICS_VER(i915) >= 11 ? 443 GEN9_FREQ_SCALER : 1))), 444 ((ia_freq >> 0) & 0xff) * 100, 445 ((ia_freq >> 8) & 0xff) * 100); 446 } 447 intel_runtime_pm_put(gt->uncore->rpm, wakeref); 448 449 return 0; 450 } 451 452 static bool llc_eval(void *data) 453 { 454 struct intel_gt *gt = data; 455 456 return HAS_LLC(gt->i915); 457 } 458 459 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(llc); 460 461 static const char *rps_power_to_str(unsigned int power) 462 { 463 static const char * const strings[] = { 464 [LOW_POWER] = "low power", 465 [BETWEEN] = "mixed", 466 [HIGH_POWER] = "high power", 467 }; 468 469 if (power >= ARRAY_SIZE(strings) || !strings[power]) 470 return "unknown"; 471 472 return strings[power]; 473 } 474 475 static int rps_boost_show(struct seq_file *m, void *data) 476 { 477 struct intel_gt *gt = m->private; 478 struct drm_i915_private *i915 = gt->i915; 479 struct intel_rps *rps = >->rps; 480 481 seq_printf(m, "RPS enabled? %s\n", 482 str_yes_no(intel_rps_is_enabled(rps))); 483 seq_printf(m, "RPS active? %s\n", 484 str_yes_no(intel_rps_is_active(rps))); 485 seq_printf(m, "GPU busy? %s, %llums\n", 486 str_yes_no(gt->awake), 487 ktime_to_ms(intel_gt_get_awake_time(gt))); 488 seq_printf(m, "Boosts outstanding? %d\n", 489 atomic_read(&rps->num_waiters)); 490 seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive)); 491 seq_printf(m, "Frequency requested %d, actual %d\n", 492 intel_gpu_freq(rps, rps->cur_freq), 493 intel_rps_read_actual_frequency(rps)); 494 seq_printf(m, " min hard:%d, soft:%d; max soft:%d, hard:%d\n", 495 intel_gpu_freq(rps, rps->min_freq), 496 intel_gpu_freq(rps, rps->min_freq_softlimit), 497 intel_gpu_freq(rps, rps->max_freq_softlimit), 498 intel_gpu_freq(rps, rps->max_freq)); 499 seq_printf(m, " idle:%d, efficient:%d, boost:%d\n", 500 intel_gpu_freq(rps, rps->idle_freq), 501 intel_gpu_freq(rps, rps->efficient_freq), 502 intel_gpu_freq(rps, rps->boost_freq)); 503 504 seq_printf(m, "Wait boosts: %d\n", READ_ONCE(rps->boosts)); 505 506 if (GRAPHICS_VER(i915) >= 6 && intel_rps_is_active(rps)) { 507 struct intel_uncore *uncore = gt->uncore; 508 u32 rpup, rpupei; 509 u32 rpdown, rpdownei; 510 511 intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); 512 rpup = intel_uncore_read_fw(uncore, GEN6_RP_CUR_UP) & GEN6_RP_EI_MASK; 513 rpupei = intel_uncore_read_fw(uncore, GEN6_RP_CUR_UP_EI) & GEN6_RP_EI_MASK; 514 rpdown = intel_uncore_read_fw(uncore, GEN6_RP_CUR_DOWN) & GEN6_RP_EI_MASK; 515 rpdownei = intel_uncore_read_fw(uncore, GEN6_RP_CUR_DOWN_EI) & GEN6_RP_EI_MASK; 516 intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL); 517 518 seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n", 519 rps_power_to_str(rps->power.mode)); 520 seq_printf(m, " Avg. up: %d%% [above threshold? %d%%]\n", 521 rpup && rpupei ? 100 * rpup / rpupei : 0, 522 rps->power.up_threshold); 523 seq_printf(m, " Avg. down: %d%% [below threshold? %d%%]\n", 524 rpdown && rpdownei ? 100 * rpdown / rpdownei : 0, 525 rps->power.down_threshold); 526 } else { 527 seq_puts(m, "\nRPS Autotuning inactive\n"); 528 } 529 530 return 0; 531 } 532 533 static bool rps_eval(void *data) 534 { 535 struct intel_gt *gt = data; 536 537 if (intel_guc_slpc_is_used(>->uc.guc)) 538 return false; 539 else 540 return HAS_RPS(gt->i915); 541 } 542 543 DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(rps_boost); 544 545 static int perf_limit_reasons_get(void *data, u64 *val) 546 { 547 struct intel_gt *gt = data; 548 intel_wakeref_t wakeref; 549 550 with_intel_runtime_pm(gt->uncore->rpm, wakeref) 551 *val = intel_uncore_read(gt->uncore, intel_gt_perf_limit_reasons_reg(gt)); 552 553 return 0; 554 } 555 556 static int perf_limit_reasons_clear(void *data, u64 val) 557 { 558 struct intel_gt *gt = data; 559 intel_wakeref_t wakeref; 560 561 /* 562 * Clear the upper 16 "log" bits, the lower 16 "status" bits are 563 * read-only. The upper 16 "log" bits are identical to the lower 16 564 * "status" bits except that the "log" bits remain set until cleared. 565 */ 566 with_intel_runtime_pm(gt->uncore->rpm, wakeref) 567 intel_uncore_rmw(gt->uncore, intel_gt_perf_limit_reasons_reg(gt), 568 GT0_PERF_LIMIT_REASONS_LOG_MASK, 0); 569 570 return 0; 571 } 572 573 static bool perf_limit_reasons_eval(void *data) 574 { 575 struct intel_gt *gt = data; 576 577 return i915_mmio_reg_valid(intel_gt_perf_limit_reasons_reg(gt)); 578 } 579 580 DEFINE_SIMPLE_ATTRIBUTE(perf_limit_reasons_fops, perf_limit_reasons_get, 581 perf_limit_reasons_clear, "0x%llx\n"); 582 583 void intel_gt_pm_debugfs_register(struct intel_gt *gt, struct dentry *root) 584 { 585 static const struct intel_gt_debugfs_file files[] = { 586 { "drpc", &drpc_fops, NULL }, 587 { "frequency", &frequency_fops, NULL }, 588 { "forcewake", &fw_domains_fops, NULL }, 589 { "forcewake_user", &forcewake_user_fops, NULL}, 590 { "llc", &llc_fops, llc_eval }, 591 { "rps_boost", &rps_boost_fops, rps_eval }, 592 { "perf_limit_reasons", &perf_limit_reasons_fops, perf_limit_reasons_eval }, 593 }; 594 595 intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt); 596 } 597