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 18 static struct xe_guc *node_to_guc(struct drm_info_node *node) 19 { 20 return node->info_ent->data; 21 } 22 23 static int guc_info(struct seq_file *m, void *data) 24 { 25 struct xe_guc *guc = node_to_guc(m->private); 26 struct xe_device *xe = guc_to_xe(guc); 27 struct drm_printer p = drm_seq_file_printer(m); 28 29 xe_device_mem_access_get(xe); 30 xe_guc_print_info(guc, &p); 31 xe_device_mem_access_put(xe); 32 33 return 0; 34 } 35 36 static int guc_log(struct seq_file *m, void *data) 37 { 38 struct xe_guc *guc = node_to_guc(m->private); 39 struct xe_device *xe = guc_to_xe(guc); 40 struct drm_printer p = drm_seq_file_printer(m); 41 42 xe_device_mem_access_get(xe); 43 xe_guc_log_print(&guc->log, &p); 44 xe_device_mem_access_put(xe); 45 46 return 0; 47 } 48 49 static const struct drm_info_list debugfs_list[] = { 50 {"guc_info", guc_info, 0}, 51 {"guc_log", guc_log, 0}, 52 }; 53 54 void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent) 55 { 56 struct drm_minor *minor = guc_to_xe(guc)->drm.primary; 57 struct drm_info_list *local; 58 int i; 59 60 #define DEBUGFS_SIZE (ARRAY_SIZE(debugfs_list) * sizeof(struct drm_info_list)) 61 local = drmm_kmalloc(&guc_to_xe(guc)->drm, DEBUGFS_SIZE, GFP_KERNEL); 62 if (!local) 63 return; 64 65 memcpy(local, debugfs_list, DEBUGFS_SIZE); 66 #undef DEBUGFS_SIZE 67 68 for (i = 0; i < ARRAY_SIZE(debugfs_list); ++i) 69 local[i].data = guc; 70 71 drm_debugfs_create_files(local, 72 ARRAY_SIZE(debugfs_list), 73 parent, minor); 74 } 75