@@ -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+
101121static 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 );
187213error :
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
200226void 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+ }
0 commit comments