Skip to content

Commit b2662d4

Browse files
shaoyunlalexdeucher
authored andcommitted
drm/amdgpu: SW part of MES event log enablement
This is the generic SW part, prepare the event log buffer and dump it through debugfs Signed-off-by: shaoyunl <[email protected]> Reviewed-by: Felix Kuehling <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent a2020be commit b2662d4

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
21472147
amdgpu_debugfs_firmware_init(adev);
21482148
amdgpu_ta_if_debugfs_init(adev);
21492149

2150+
amdgpu_debugfs_mes_event_log_init(adev);
2151+
21502152
#if defined(CONFIG_DRM_AMD_DC)
21512153
if (adev->dc_enabled)
21522154
dtn_debugfs_init(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ void amdgpu_debugfs_fini(struct amdgpu_device *adev);
3232
void amdgpu_debugfs_fence_init(struct amdgpu_device *adev);
3333
void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev);
3434
void amdgpu_debugfs_gem_init(struct amdgpu_device *adev);
35+
void amdgpu_debugfs_mes_event_log_init(struct amdgpu_device *adev);
36+

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ static int amdgpu_mes_doorbell_init(struct amdgpu_device *adev)
9898
return 0;
9999
}
100100

101+
static int amdgpu_mes_event_log_init(struct amdgpu_device *adev)
102+
{
103+
int r;
104+
105+
r = amdgpu_bo_create_kernel(adev, PAGE_SIZE, PAGE_SIZE,
106+
AMDGPU_GEM_DOMAIN_GTT,
107+
&adev->mes.event_log_gpu_obj,
108+
&adev->mes.event_log_gpu_addr,
109+
&adev->mes.event_log_cpu_addr);
110+
if (r) {
111+
dev_warn(adev->dev, "failed to create MES event log buffer (%d)", r);
112+
return r;
113+
}
114+
115+
memset(adev->mes.event_log_cpu_addr, 0, PAGE_SIZE);
116+
117+
return 0;
118+
119+
}
120+
101121
static void amdgpu_mes_doorbell_free(struct amdgpu_device *adev)
102122
{
103123
bitmap_free(adev->mes.doorbell_bitmap);
@@ -182,8 +202,14 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
182202
if (r)
183203
goto error;
184204

205+
r = amdgpu_mes_event_log_init(adev);
206+
if (r)
207+
goto error_doorbell;
208+
185209
return 0;
186210

211+
error_doorbell:
212+
amdgpu_mes_doorbell_free(adev);
187213
error:
188214
amdgpu_device_wb_free(adev, adev->mes.sch_ctx_offs);
189215
amdgpu_device_wb_free(adev, adev->mes.query_status_fence_offs);
@@ -199,6 +225,10 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
199225

200226
void amdgpu_mes_fini(struct amdgpu_device *adev)
201227
{
228+
amdgpu_bo_free_kernel(&adev->mes.event_log_gpu_obj,
229+
&adev->mes.event_log_gpu_addr,
230+
&adev->mes.event_log_cpu_addr);
231+
202232
amdgpu_device_wb_free(adev, adev->mes.sch_ctx_offs);
203233
amdgpu_device_wb_free(adev, adev->mes.query_status_fence_offs);
204234
amdgpu_device_wb_free(adev, adev->mes.read_val_offs);
@@ -1479,3 +1509,34 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
14791509
amdgpu_ucode_release(&adev->mes.fw[pipe]);
14801510
return r;
14811511
}
1512+
1513+
#if defined(CONFIG_DEBUG_FS)
1514+
1515+
static int amdgpu_debugfs_mes_event_log_show(struct seq_file *m, void *unused)
1516+
{
1517+
struct amdgpu_device *adev = m->private;
1518+
uint32_t *mem = (uint32_t *)(adev->mes.event_log_cpu_addr);
1519+
1520+
seq_hex_dump(m, "", DUMP_PREFIX_OFFSET, 32, 4,
1521+
mem, PAGE_SIZE, false);
1522+
1523+
return 0;
1524+
}
1525+
1526+
1527+
DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_mes_event_log);
1528+
1529+
#endif
1530+
1531+
void amdgpu_debugfs_mes_event_log_init(struct amdgpu_device *adev)
1532+
{
1533+
1534+
#if defined(CONFIG_DEBUG_FS)
1535+
struct drm_minor *minor = adev_to_drm(adev)->primary;
1536+
struct dentry *root = minor->debugfs_root;
1537+
1538+
debugfs_create_file("amdgpu_mes_event_log", 0444, root,
1539+
adev, &amdgpu_debugfs_mes_event_log_fops);
1540+
1541+
#endif
1542+
}

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ struct amdgpu_mes {
133133
uint32_t num_mes_dbs;
134134
unsigned long *doorbell_bitmap;
135135

136+
/* MES event log buffer */
137+
struct amdgpu_bo *event_log_gpu_obj;
138+
uint64_t event_log_gpu_addr;
139+
void *event_log_cpu_addr;
140+
136141
/* ip specific functions */
137142
const struct amdgpu_mes_funcs *funcs;
138143
};

0 commit comments

Comments
 (0)