drm/amdgpu: add reset register dump trace on GPU
authorSomalapuram Amaranath <Amaranath.Somalapuram@amd.com>
Wed, 23 Feb 2022 08:57:43 +0000 (14:27 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 23 Feb 2022 19:26:36 +0000 (14:26 -0500)
Dump the list of register values to trace event on GPU reset.

Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h

index 17ed7fd..ecf8c30 100644 (file)
@@ -4638,6 +4638,22 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
        return r;
 }
 
+static int amdgpu_reset_reg_dumps(struct amdgpu_device *adev)
+{
+       uint32_t reg_value;
+       int i;
+
+       lockdep_assert_held(&adev->reset_sem);
+       dump_stack();
+
+       for (i = 0; i < adev->num_regs; i++) {
+               reg_value = RREG32(adev->reset_dump_reg_list[i]);
+               trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list[i], reg_value);
+       }
+
+       return 0;
+}
+
 int amdgpu_do_asic_reset(struct list_head *device_list_handle,
                         struct amdgpu_reset_context *reset_context)
 {
@@ -4648,6 +4664,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
        /* Try reset handler method first */
        tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
                                    reset_list);
+       amdgpu_reset_reg_dumps(tmp_adev);
        r = amdgpu_reset_perform_reset(tmp_adev, reset_context);
        /* If reset handler not implemented, continue; otherwise return */
        if (r == -ENOSYS)
index a48b34d..06dfcf2 100644 (file)
@@ -536,6 +536,22 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,
                      __entry->seqno)
 );
 
+TRACE_EVENT(amdgpu_reset_reg_dumps,
+           TP_PROTO(uint32_t address, uint32_t value),
+           TP_ARGS(address, value),
+           TP_STRUCT__entry(
+                            __field(uint32_t, address)
+                            __field(uint32_t, value)
+                            ),
+           TP_fast_assign(
+                          __entry->address = address;
+                          __entry->value = value;
+                          ),
+           TP_printk("amdgpu register dump 0x%x: 0x%x",
+                     __entry->address,
+                     __entry->value)
+);
+
 #undef AMDGPU_JOB_GET_TIMELINE_NAME
 #endif