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