1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #include "xe_gt_debugfs.h" 7 8 #include <linux/debugfs.h> 9 #include <linux/panic.h> 10 #include <linux/string.h> 11 12 #include <drm/drm_debugfs.h> 13 #include <drm/drm_managed.h> 14 #include <linux/math.h> 15 16 #include "regs/xe_engine_regs.h" 17 #include "regs/xe_gt_regs.h" 18 #include "xe_device.h" 19 #include "xe_force_wake.h" 20 #include "xe_gt.h" 21 #include "xe_gt_mcr.h" 22 #include "xe_gt_idle.h" 23 #include "xe_gt_printk.h" 24 #include "xe_gt_sriov_pf_debugfs.h" 25 #include "xe_gt_sriov_vf_debugfs.h" 26 #include "xe_gt_stats.h" 27 #include "xe_gt_topology.h" 28 #include "xe_guc_hwconfig.h" 29 #include "xe_guc_submit.h" 30 #include "xe_hw_engine.h" 31 #include "xe_lrc.h" 32 #include "xe_mmio.h" 33 #include "xe_mocs.h" 34 #include "xe_pat.h" 35 #include "xe_pm.h" 36 #include "xe_reg_sr.h" 37 #include "xe_reg_whitelist.h" 38 #include "xe_sa.h" 39 #include "xe_sriov.h" 40 #include "xe_sriov_vf_ccs.h" 41 #include "xe_tuning.h" 42 #include "xe_uc_debugfs.h" 43 #include "xe_wa.h" 44 45 static struct xe_gt *node_to_gt(struct drm_info_node *node) 46 { 47 return node->dent->d_parent->d_inode->i_private; 48 } 49 50 /** 51 * xe_gt_debugfs_simple_show - A show callback for struct drm_info_list 52 * @m: the &seq_file 53 * @data: data used by the drm debugfs helpers 54 * 55 * This callback can be used in struct drm_info_list to describe debugfs 56 * files that are &xe_gt specific. 57 * 58 * It is assumed that those debugfs files will be created on directory entry 59 * which struct dentry d_inode->i_private points to &xe_gt. 60 * 61 * This function assumes that &m->private will be set to the &struct 62 * drm_info_node corresponding to the instance of the info on a given &struct 63 * drm_minor (see struct drm_info_list.show for details). 64 * 65 * This function also assumes that struct drm_info_list.data will point to the 66 * function code that will actually print a file content:: 67 * 68 * int (*print)(struct xe_gt *, struct drm_printer *) 69 * 70 * Example:: 71 * 72 * int foo(struct xe_gt *gt, struct drm_printer *p) 73 * { 74 * drm_printf(p, "GT%u\n", gt->info.id); 75 * return 0; 76 * } 77 * 78 * static const struct drm_info_list bar[] = { 79 * { name = "foo", .show = xe_gt_debugfs_simple_show, .data = foo }, 80 * }; 81 * 82 * dir = debugfs_create_dir("gt", parent); 83 * dir->d_inode->i_private = gt; 84 * drm_debugfs_create_files(bar, ARRAY_SIZE(bar), dir, minor); 85 * 86 * Return: 0 on success or a negative error code on failure. 87 */ 88 int xe_gt_debugfs_simple_show(struct seq_file *m, void *data) 89 { 90 struct drm_printer p = drm_seq_file_printer(m); 91 struct drm_info_node *node = m->private; 92 struct xe_gt *gt = node_to_gt(node); 93 int (*print)(struct xe_gt *, struct drm_printer *) = node->info_ent->data; 94 95 if (WARN_ON(!print)) 96 return -EINVAL; 97 98 return print(gt, &p); 99 } 100 101 /** 102 * xe_gt_debugfs_show_with_rpm - A show callback for struct drm_info_list 103 * @m: the &seq_file 104 * @data: data used by the drm debugfs helpers 105 * 106 * Similar to xe_gt_debugfs_simple_show() but implicitly takes a RPM ref. 107 * 108 * Return: 0 on success or a negative error code on failure. 109 */ 110 int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data) 111 { 112 struct drm_info_node *node = m->private; 113 struct xe_gt *gt = node_to_gt(node); 114 struct xe_device *xe = gt_to_xe(gt); 115 116 guard(xe_pm_runtime)(xe); 117 return xe_gt_debugfs_simple_show(m, data); 118 } 119 120 static int hw_engines(struct xe_gt *gt, struct drm_printer *p) 121 { 122 static const struct { 123 struct xe_reg reg; 124 bool has_fw; 125 } msg_idle_reg[XE_NUM_HW_ENGINES] = { 126 [XE_HW_ENGINE_RCS0] = { MSG_IDLE_CS, true }, 127 [XE_HW_ENGINE_BCS0] = { MSG_IDLE_BCS0, true }, 128 [XE_HW_ENGINE_BCS1] = { MSG_IDLE_BCS1, false }, 129 [XE_HW_ENGINE_BCS2] = { MSG_IDLE_BCS2, false }, 130 [XE_HW_ENGINE_BCS3] = { MSG_IDLE_BCS3, false }, 131 [XE_HW_ENGINE_BCS4] = { MSG_IDLE_BCS4, false }, 132 [XE_HW_ENGINE_BCS5] = { MSG_IDLE_BCS5, false }, 133 [XE_HW_ENGINE_BCS6] = { MSG_IDLE_BCS6, false }, 134 [XE_HW_ENGINE_BCS7] = { MSG_IDLE_BCS7, false }, 135 [XE_HW_ENGINE_BCS8] = { MSG_IDLE_BCS8, false }, 136 [XE_HW_ENGINE_VCS0] = { MSG_IDLE_VCS0, true }, 137 [XE_HW_ENGINE_VCS1] = { MSG_IDLE_VCS1, true }, 138 [XE_HW_ENGINE_VCS2] = { MSG_IDLE_VCS2, true }, 139 [XE_HW_ENGINE_VCS3] = { MSG_IDLE_VCS3, true }, 140 [XE_HW_ENGINE_VCS4] = { MSG_IDLE_VCS4, true }, 141 [XE_HW_ENGINE_VCS5] = { MSG_IDLE_VCS5, true }, 142 [XE_HW_ENGINE_VCS6] = { MSG_IDLE_VCS6, true }, 143 [XE_HW_ENGINE_VCS7] = { MSG_IDLE_VCS7, true }, 144 [XE_HW_ENGINE_VECS0] = { MSG_IDLE_VECS0, true }, 145 [XE_HW_ENGINE_VECS1] = { MSG_IDLE_VECS1, true }, 146 [XE_HW_ENGINE_VECS2] = { MSG_IDLE_VECS2, true }, 147 [XE_HW_ENGINE_VECS3] = { MSG_IDLE_VECS3, true }, 148 [XE_HW_ENGINE_CCS0] = { MSG_IDLE_CS, true }, 149 [XE_HW_ENGINE_CCS1] = { MSG_IDLE_CS, true }, 150 [XE_HW_ENGINE_CCS2] = { MSG_IDLE_CS, true }, 151 [XE_HW_ENGINE_CCS3] = { MSG_IDLE_CS, true }, 152 [XE_HW_ENGINE_GSCCS0] = { MSG_IDLE_GSCCS0, false }, 153 }; 154 struct xe_hw_engine *hwe; 155 enum xe_hw_engine_id id; 156 157 CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FORCEWAKE_ALL); 158 if (!xe_force_wake_ref_has_domain(fw_ref.domains, XE_FORCEWAKE_ALL)) 159 return -ETIMEDOUT; 160 161 for_each_hw_engine(hwe, gt, id) { 162 struct xe_reg reg = msg_idle_reg[id].reg; 163 u32 val; 164 165 xe_hw_engine_print(hwe, p); 166 167 val = xe_mmio_read32(>->mmio, reg); 168 169 if (msg_idle_reg[id].has_fw) 170 drm_printf(p, "\tpipe %s, C6 %s, fw_req 0x%02x\n", 171 val & MSG_IDLE_INDICATION ? "idle" : "busy", 172 val & MSG_IDLE_C6_ALLOWED ? "allowed" : "not allowed", 173 REG_FIELD_GET(MSG_IDLE_FW_REQ, val)); 174 else 175 drm_printf(p, "\tpipe %s, C6 %s\n", 176 val & MSG_IDLE_INDICATION ? "idle" : "busy", 177 val & MSG_IDLE_C6_ALLOWED ? "allowed" : "not allowed"); 178 179 drm_puts(p, "\n"); 180 } 181 182 return 0; 183 } 184 185 static int multi_queue_active_lrca(struct xe_gt *gt, struct drm_printer *p) 186 { 187 struct xe_guc *guc = >->uc.guc; 188 struct xe_hw_engine *hwe; 189 enum xe_hw_engine_id id; 190 191 for_each_hw_engine(hwe, gt, id) { 192 u32 cur_lrca, active_id, lrca; 193 unsigned int fw_ref; 194 195 if (!xe_gt_supports_multi_queue(gt, hwe->class)) 196 continue; 197 198 /* 199 * Forcewake is dropped before xe_guc_submit_active_multi_queue_lrca() 200 * below, which takes guc->submission_state.lock, to avoid holding a 201 * GT forcewake ref across a mutex acquired elsewhere in the opposite 202 * order. 203 */ 204 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); 205 if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) { 206 drm_printf(p, "%s\tforcewake failed, skipping\n", hwe->name); 207 xe_force_wake_put(gt_to_fw(gt), fw_ref); 208 continue; 209 } 210 211 cur_lrca = xe_mmio_read32(>->mmio, 212 RING_CURRENT_LRCA(hwe->mmio_base)); 213 active_id = xe_lrc_get_multi_queue_active_queue_id(hwe); 214 215 xe_force_wake_put(gt_to_fw(gt), fw_ref); 216 217 lrca = xe_guc_submit_active_multi_queue_lrca(guc, hwe, cur_lrca, 218 active_id); 219 220 drm_printf(p, "%s\tactive_queue_id %u\tcurrent_lrca 0x%08x\tactive_lrca 0x%08x\n", 221 hwe->name, active_id, cur_lrca, lrca); 222 } 223 224 return 0; 225 } 226 227 static int steering(struct xe_gt *gt, struct drm_printer *p) 228 { 229 xe_gt_mcr_steering_dump(gt, p); 230 return 0; 231 } 232 233 static int register_save_restore(struct xe_gt *gt, struct drm_printer *p) 234 { 235 struct xe_hw_engine *hwe; 236 enum xe_hw_engine_id id; 237 238 xe_reg_sr_dump(>->reg_sr, p); 239 drm_printf(p, "\n"); 240 241 drm_printf(p, "Engine\n"); 242 for_each_hw_engine(hwe, gt, id) 243 xe_reg_sr_dump(&hwe->reg_sr, p); 244 drm_printf(p, "\n"); 245 246 drm_printf(p, "LRC\n"); 247 for_each_hw_engine(hwe, gt, id) 248 xe_reg_sr_dump(&hwe->reg_lrc, p); 249 drm_printf(p, "\n"); 250 251 drm_printf(p, "Whitelist\n"); 252 for_each_hw_engine(hwe, gt, id) { 253 xe_reg_whitelist_dump(&hwe->reg_whitelist, p); 254 xe_reg_whitelist_dump(&hwe->oa_whitelist, p); 255 } 256 257 return 0; 258 } 259 260 /* 261 * Check the registers referenced on a save-restore list and report any 262 * save-restore entries that did not get applied. 263 */ 264 static int register_save_restore_check(struct xe_gt *gt, struct drm_printer *p) 265 { 266 struct xe_hw_engine *hwe; 267 enum xe_hw_engine_id id; 268 269 CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FORCEWAKE_ALL); 270 if (!xe_force_wake_ref_has_domain(fw_ref.domains, XE_FORCEWAKE_ALL)) { 271 drm_printf(p, "ERROR: Could not acquire forcewake\n"); 272 return -ETIMEDOUT; 273 } 274 275 xe_reg_sr_readback_check(>->reg_sr, gt, p); 276 for_each_hw_engine(hwe, gt, id) 277 xe_reg_sr_readback_check(&hwe->reg_sr, gt, p); 278 for_each_hw_engine(hwe, gt, id) 279 xe_reg_sr_lrc_check(&hwe->reg_lrc, gt, hwe, p); 280 281 return 0; 282 } 283 284 static int rcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 285 { 286 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER); 287 return 0; 288 } 289 290 static int ccs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 291 { 292 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE); 293 return 0; 294 } 295 296 static int bcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 297 { 298 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY); 299 return 0; 300 } 301 302 static int vcs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 303 { 304 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE); 305 return 0; 306 } 307 308 static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p) 309 { 310 xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE); 311 return 0; 312 } 313 314 static int hwconfig(struct xe_gt *gt, struct drm_printer *p) 315 { 316 xe_guc_hwconfig_dump(>->uc.guc, p); 317 return 0; 318 } 319 320 /* 321 * only for GT debugfs files which can be safely used on the VF as well: 322 * - without access to the GT privileged registers 323 * - without access to the PF specific data 324 */ 325 static const struct drm_info_list vf_safe_debugfs_list[] = { 326 { "topology", .show = xe_gt_debugfs_show_with_rpm, .data = xe_gt_topology_dump }, 327 { "register-save-restore", 328 .show = xe_gt_debugfs_show_with_rpm, .data = register_save_restore }, 329 { "workarounds", .show = xe_gt_debugfs_show_with_rpm, .data = xe_wa_gt_dump }, 330 { "tunings", .show = xe_gt_debugfs_show_with_rpm, .data = xe_tuning_dump }, 331 { "default_lrc_rcs", .show = xe_gt_debugfs_show_with_rpm, .data = rcs_default_lrc }, 332 { "default_lrc_ccs", .show = xe_gt_debugfs_show_with_rpm, .data = ccs_default_lrc }, 333 { "default_lrc_bcs", .show = xe_gt_debugfs_show_with_rpm, .data = bcs_default_lrc }, 334 { "default_lrc_vcs", .show = xe_gt_debugfs_show_with_rpm, .data = vcs_default_lrc }, 335 { "default_lrc_vecs", .show = xe_gt_debugfs_show_with_rpm, .data = vecs_default_lrc }, 336 { "hwconfig", .show = xe_gt_debugfs_show_with_rpm, .data = hwconfig }, 337 { "pat_sw_config", .show = xe_gt_debugfs_simple_show, .data = xe_pat_dump_sw_config }, 338 { "register-save-restore-check", 339 .show = xe_gt_debugfs_show_with_rpm, .data = register_save_restore_check }, 340 }; 341 342 /* everything else should be added here */ 343 static const struct drm_info_list pf_only_debugfs_list[] = { 344 { "hw_engines", .show = xe_gt_debugfs_show_with_rpm, .data = hw_engines }, 345 { "mocs", .show = xe_gt_debugfs_show_with_rpm, .data = xe_mocs_dump }, 346 { "pat", .show = xe_gt_debugfs_show_with_rpm, .data = xe_pat_dump }, 347 { "powergate_info", .show = xe_gt_debugfs_show_with_rpm, .data = xe_gt_idle_pg_print }, 348 { "steering", .show = xe_gt_debugfs_show_with_rpm, .data = steering }, 349 }; 350 351 static const struct drm_info_list multi_queue_debugfs_list[] = { 352 { "multi_queue_active_lrca", 353 .show = xe_gt_debugfs_show_with_rpm, .data = multi_queue_active_lrca }, 354 }; 355 356 static ssize_t write_to_gt_call(const char __user *userbuf, size_t count, loff_t *ppos, 357 void (*call)(struct xe_gt *), struct xe_gt *gt) 358 { 359 bool yes; 360 int ret; 361 362 if (*ppos) 363 return -EINVAL; 364 ret = kstrtobool_from_user(userbuf, count, &yes); 365 if (ret < 0) 366 return ret; 367 if (yes) 368 call(gt); 369 return count; 370 } 371 372 static ssize_t stats_write(struct file *file, const char __user *userbuf, 373 size_t count, loff_t *ppos) 374 { 375 struct seq_file *s = file->private_data; 376 struct xe_gt *gt = s->private; 377 378 return write_to_gt_call(userbuf, count, ppos, xe_gt_stats_clear, gt); 379 } 380 381 static int stats_show(struct seq_file *s, void *unused) 382 { 383 struct drm_printer p = drm_seq_file_printer(s); 384 struct xe_gt *gt = s->private; 385 386 return xe_gt_stats_print_info(gt, &p); 387 } 388 DEFINE_SHOW_STORE_ATTRIBUTE(stats); 389 390 static void force_reset(struct xe_gt *gt) 391 { 392 struct xe_device *xe = gt_to_xe(gt); 393 394 guard(xe_pm_runtime)(xe); 395 xe_gt_reset_async(gt); 396 } 397 398 static ssize_t force_reset_write(struct file *file, 399 const char __user *userbuf, 400 size_t count, loff_t *ppos) 401 { 402 struct seq_file *s = file->private_data; 403 struct xe_gt *gt = s->private; 404 405 return write_to_gt_call(userbuf, count, ppos, force_reset, gt); 406 } 407 408 static int force_reset_show(struct seq_file *s, void *unused) 409 { 410 struct xe_gt *gt = s->private; 411 412 force_reset(gt); /* to be deprecated! */ 413 return 0; 414 } 415 DEFINE_SHOW_STORE_ATTRIBUTE(force_reset); 416 417 static void force_reset_sync(struct xe_gt *gt) 418 { 419 struct xe_device *xe = gt_to_xe(gt); 420 421 guard(xe_pm_runtime)(xe); 422 xe_gt_reset(gt); 423 } 424 425 static ssize_t force_reset_sync_write(struct file *file, 426 const char __user *userbuf, 427 size_t count, loff_t *ppos) 428 { 429 struct seq_file *s = file->private_data; 430 struct xe_gt *gt = s->private; 431 432 return write_to_gt_call(userbuf, count, ppos, force_reset_sync, gt); 433 } 434 435 static int force_reset_sync_show(struct seq_file *s, void *unused) 436 { 437 struct xe_gt *gt = s->private; 438 439 force_reset_sync(gt); /* to be deprecated! */ 440 return 0; 441 } 442 DEFINE_SHOW_STORE_ATTRIBUTE(force_reset_sync); 443 444 #define U1_15_ONE 0x8000 445 #define U1_15_INT_BITS GENMASK(15, 15) 446 #define U1_15_FRACTION_BITS GENMASK(14, 0) 447 448 static void u1_15_decode(u16 num, u16 *i, u32 *frac) 449 { 450 /* 451 * In U1.15 format, uppermost bit is integer value and the 452 * rest 15 are the fraction. 453 */ 454 455 *i = FIELD_GET(U1_15_INT_BITS, num); 456 *frac = FIELD_GET(U1_15_FRACTION_BITS, num); 457 } 458 459 static void u1_15_decode_decimal(u16 value, u16 *i, u32 *frac, int digits) 460 { 461 u1_15_decode(value, i, frac); 462 *frac = (*frac * int_pow(10, digits)) / (FIELD_MAX(U1_15_FRACTION_BITS) + 1); 463 } 464 465 static int gt_ia_bias_show(struct seq_file *s, void *unused) 466 { 467 struct xe_gt *gt = s->private; 468 struct xe_device *xe = gt_to_xe(gt); 469 u32 val; 470 u32 ia_frac, gt_frac; 471 u16 ia_raw, gt_raw; 472 u16 ia_int, gt_int; 473 474 guard(xe_pm_runtime)(xe); 475 val = xe_mmio_read32(>->mmio, GT_IA_PERF_BIAS_REG); 476 477 ia_raw = REG_FIELD_GET(IA_BIAS, val); 478 gt_raw = REG_FIELD_GET(GT_BIAS, val); 479 480 u1_15_decode_decimal(ia_raw, &ia_int, &ia_frac, 4); 481 u1_15_decode_decimal(gt_raw, >_int, >_frac, 4); 482 483 seq_printf(s, "0x%x (GT: %u.%04u, IA: %u.%04u)\n", 484 val, gt_int, gt_frac, ia_int, ia_frac); 485 486 return 0; 487 } 488 489 static ssize_t gt_ia_bias_write(struct file *file, 490 const char __user *userbuf, 491 size_t count, loff_t *ppos) 492 { 493 struct seq_file *s = file->private_data; 494 struct xe_gt *gt = s->private; 495 struct xe_device *xe = gt_to_xe(gt); 496 u32 val; 497 int ret; 498 499 ret = kstrtou32_from_user(userbuf, count, 0, &val); 500 if (ret) 501 return ret; 502 503 if (REG_FIELD_GET(IA_BIAS, val) > U1_15_ONE || 504 REG_FIELD_GET(GT_BIAS, val) > U1_15_ONE) 505 return -EINVAL; 506 507 if (REG_FIELD_GET(IA_BIAS, val) < IA_BIAS_DEFAULT || 508 REG_FIELD_GET(GT_BIAS, val) < GT_BIAS_DEFAULT) 509 return -EINVAL; 510 511 guard(xe_pm_runtime)(xe); 512 xe_mmio_write32(>->mmio, GT_IA_PERF_BIAS_REG, val); 513 514 return count; 515 } 516 DEFINE_SHOW_STORE_ATTRIBUTE(gt_ia_bias); 517 518 static const char * const gpgpu_preemption_level_names[] = { 519 [XE_GPGPU_PREEMPT_DEFAULT] = "default", 520 [XE_GPGPU_PREEMPT_MID_THREAD] = "mid-thread", 521 [XE_GPGPU_PREEMPT_THREAD_GROUP] = "thread-group", 522 [XE_GPGPU_PREEMPT_COMMAND] = "command", 523 }; 524 525 static int gpgpu_preemption_level_show(struct seq_file *m, void *unused) 526 { 527 struct xe_gt *gt = m->private; 528 529 seq_printf(m, "%s\n", gpgpu_preemption_level_names[gt->gpgpu_preemption_level]); 530 531 return 0; 532 } 533 534 static ssize_t gpgpu_preemption_level_write(struct file *file, 535 const char __user *ubuf, 536 size_t len, loff_t *offp) 537 { 538 struct seq_file *m = file->private_data; 539 struct xe_gt *gt = m->private; 540 enum xe_gpgpu_preempt_level new_level; 541 char buf[16]; 542 ssize_t copied; 543 int idx; 544 545 if (*offp) 546 return -EINVAL; 547 548 copied = simple_write_to_buffer(buf, sizeof(buf) - 1, offp, ubuf, len); 549 if (copied < 0) 550 return copied; 551 552 buf[copied] = '\0'; 553 idx = sysfs_match_string(gpgpu_preemption_level_names, strim(buf)); 554 if (idx < 0) 555 return idx; 556 557 new_level = (enum xe_gpgpu_preempt_level)idx; 558 559 if (new_level == XE_GPGPU_PREEMPT_MID_THREAD && gt->info.has_wmtp_disabled) { 560 xe_gt_warn(gt, "MTP fused off in hardware, cannot select mid-thread\n"); 561 return -EINVAL; 562 } 563 564 if (new_level != XE_GPGPU_PREEMPT_DEFAULT) { 565 add_taint(TAINT_USER, LOCKDEP_STILL_OK); 566 xe_gt_notice(gt, 567 "GPGPU preemption overridden to '%s' (applies to new LRCs only)\n", 568 gpgpu_preemption_level_names[new_level]); 569 } 570 571 gt->gpgpu_preemption_level = new_level; 572 573 return copied; 574 } 575 DEFINE_SHOW_STORE_ATTRIBUTE(gpgpu_preemption_level); 576 577 void xe_gt_debugfs_register(struct xe_gt *gt) 578 { 579 struct xe_device *xe = gt_to_xe(gt); 580 struct drm_minor *minor = gt_to_xe(gt)->drm.primary; 581 struct dentry *parent = gt->tile->debugfs; 582 struct dentry *root; 583 char symlink[16]; 584 char name[8]; 585 586 xe_gt_assert(gt, minor->debugfs_root); 587 588 if (IS_ERR(parent)) 589 return; 590 591 snprintf(name, sizeof(name), "gt%d", gt->info.id); 592 root = debugfs_create_dir(name, parent); 593 if (IS_ERR(root)) { 594 drm_warn(&xe->drm, "Create GT directory failed"); 595 return; 596 } 597 598 /* 599 * Store the xe_gt pointer as private data of the gt/ directory node 600 * so other GT specific attributes under that directory may refer to 601 * it by looking at its parent node private data. 602 */ 603 root->d_inode->i_private = gt; 604 605 /* VF safe */ 606 debugfs_create_file("stats", 0600, root, gt, &stats_fops); 607 debugfs_create_file("force_reset", 0600, root, gt, &force_reset_fops); 608 debugfs_create_file("force_reset_sync", 0600, root, gt, &force_reset_sync_fops); 609 610 if (GRAPHICS_VER(xe) >= 20 && (gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK)) 611 debugfs_create_file("gpgpu_preemption_level", 0600, root, 612 gt, &gpgpu_preemption_level_fops); 613 614 drm_debugfs_create_files(vf_safe_debugfs_list, 615 ARRAY_SIZE(vf_safe_debugfs_list), 616 root, minor); 617 618 if (!IS_SRIOV_VF(xe)) 619 drm_debugfs_create_files(pf_only_debugfs_list, 620 ARRAY_SIZE(pf_only_debugfs_list), 621 root, minor); 622 623 if (!IS_SRIOV_VF(xe) && xe_gt_has_multi_queue(gt)) 624 drm_debugfs_create_files(multi_queue_debugfs_list, 625 ARRAY_SIZE(multi_queue_debugfs_list), 626 root, minor); 627 628 if (xe_gt_is_main_type(gt) && !IS_DGFX(xe) && !IS_SRIOV_VF(xe)) 629 debugfs_create_file("gt_ia_bias", 0600, root, gt, >_ia_bias_fops); 630 631 xe_uc_debugfs_register(>->uc, root); 632 633 if (IS_SRIOV_PF(xe)) 634 xe_gt_sriov_pf_debugfs_register(gt, root); 635 else if (IS_SRIOV_VF(xe)) 636 xe_gt_sriov_vf_debugfs_register(gt, root); 637 638 /* 639 * Backwards compatibility only: create a link for the legacy clients 640 * who may expect gt/ directory at the root level, not the tile level. 641 */ 642 snprintf(symlink, sizeof(symlink), "tile%u/%s", gt->tile->id, name); 643 debugfs_create_symlink(name, minor->debugfs_root, symlink); 644 } 645