1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6 #include "xe_guc_debugfs.h" 7 8 #include <drm/drm_debugfs.h> 9 #include <drm/drm_managed.h> 10 11 #include "xe_device.h" 12 #include "xe_gt.h" 13 #include "xe_guc.h" 14 #include "xe_guc_ct.h" 15 #include "xe_guc_log.h" 16 #include "xe_macros.h" 17 #include "xe_pm.h" 18 19 static struct xe_guc *node_to_guc(struct drm_info_node *node) 20 { 21 return node->info_ent->data; 22 } 23 24 static int guc_info(struct seq_file *m, void *data) 25 { 26 struct xe_guc *guc = node_to_guc(m->private); 27 struct xe_device *xe = guc_to_xe(guc); 28 struct drm_printer p = drm_seq_file_printer(m); 29 30 xe_pm_runtime_get(xe); 31 xe_guc_print_info(guc, &p); 32 xe_pm_runtime_put(xe); 33 34 return 0; 35 } 36 37 static int guc_log(struct seq_file *m, void *data) 38 { 39 struct xe_guc *guc = node_to_guc(m->private); 40 struct xe_device *xe = guc_to_xe(guc); 41 struct drm_printer p = drm_seq_file_printer(m); 42 43 xe_pm_runtime_get(xe); 44 xe_guc_log_print(&guc->log, &p); 45 xe_pm_runtime_put(xe); 46 47 return 0; 48 } 49 50 static int guc_ctb(struct seq_file *m, void *data) 51 { 52 struct xe_guc *guc = node_to_guc(m->private); 53 struct xe_device *xe = guc_to_xe(guc); 54 struct drm_printer p = drm_seq_file_printer(m); 55 56 xe_pm_runtime_get(xe); 57 xe_guc_ct_print(&guc->ct, &p, true); 58 xe_pm_runtime_put(xe); 59 60 return 0; 61 } 62 63 static const struct drm_info_list debugfs_list[] = { 64 {"guc_info", guc_info, 0}, 65 {"guc_log", guc_log, 0}, 66 {"guc_ctb", guc_ctb, 0}, 67 }; 68 69 void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent) 70 { 71 struct drm_minor *minor = guc_to_xe(guc)->drm.primary; 72 struct drm_info_list *local; 73 int i; 74 75 #define DEBUGFS_SIZE (ARRAY_SIZE(debugfs_list) * sizeof(struct drm_info_list)) 76 local = drmm_kmalloc(&guc_to_xe(guc)->drm, DEBUGFS_SIZE, GFP_KERNEL); 77 if (!local) 78 return; 79 80 memcpy(local, debugfs_list, DEBUGFS_SIZE); 81 #undef DEBUGFS_SIZE 82 83 for (i = 0; i < ARRAY_SIZE(debugfs_list); ++i) 84 local[i].data = guc; 85 86 drm_debugfs_create_files(local, 87 ARRAY_SIZE(debugfs_list), 88 parent, minor); 89 } 90