1 // SPDX-License-Identifier: MIT
3 * Copyright © 2022 Intel Corporation
6 #include "xe_guc_debugfs.h"
8 #include <drm/drm_debugfs.h>
9 #include <drm/drm_managed.h>
11 #include "xe_device.h"
14 #include "xe_guc_ct.h"
15 #include "xe_guc_log.h"
16 #include "xe_macros.h"
18 static struct xe_guc *node_to_guc(struct drm_info_node *node)
20 return node->info_ent->data;
23 static int guc_info(struct seq_file *m, void *data)
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);
29 xe_device_mem_access_get(xe);
30 xe_guc_print_info(guc, &p);
31 xe_device_mem_access_put(xe);
36 static int guc_log(struct seq_file *m, void *data)
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);
42 xe_device_mem_access_get(xe);
43 xe_guc_log_print(&guc->log, &p);
44 xe_device_mem_access_put(xe);
49 static const struct drm_info_list debugfs_list[] = {
50 {"guc_info", guc_info, 0},
51 {"guc_log", guc_log, 0},
54 void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent)
56 struct drm_minor *minor = guc_to_xe(guc)->drm.primary;
57 struct drm_info_list *local;
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);
65 memcpy(local, debugfs_list, DEBUGFS_SIZE);
68 for (i = 0; i < ARRAY_SIZE(debugfs_list); ++i)
71 drm_debugfs_create_files(local,
72 ARRAY_SIZE(debugfs_list),