drm/amdgpu: add debugfs for reset registers list
Subsystems (2)
PATCH 1/2 drm/amdgpu: add debugfs for reset registers list
List of register to be populated for dump collection during the GPU reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 60 +++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -1097,6 +1097,9 @@ struct amdgpu_device {struct amdgpu_reset_control *reset_cntl;uint32_t ip_versions[HW_ID_MAX ][HWIP_MAX_INSTANCE ]; + +/* reset dump register */ +long reset_dump_reg_list[128 ]; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +60 -0
72 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 drm/amdgpu: add reset register trace function on GPU reset
Dump the list of register values to trace event on GPU reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +20 -1
@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,return r; } +static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ +int i; +uint32_t reg_value[128 ]; + +for (i =0 ; adev->reset_dump_reg_list[i] !=0 ; i++) { +if (adev->asic_type >=CHIP_NAVI10 ) + reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); +else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + +trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list, reg_value, i); + +return 0 ; +} +int amdgpu_do_asic_reset (struct list_head *device_list_handle,struct amdgpu_reset_context *reset_context) {
@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false;if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; - }else + }else { +amdgpu_reset_reg_dumps (tmp_adev); r =amdgpu_asic_reset (tmp_adev); + }if (r) { dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19 -0
@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), +TP_ARGS (address, value, length), +TP_STRUCT__entry ( + __array(long, address, 128) + __array(uint32_t, value, 128) +__field (int, len) + ), +TP_fast_assign ( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), +TP_printk ("amdgpu register dump offset: %s value: %s " , +__print_array (__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); +#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif
Signature · 1 line
2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 14 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,return r; } +static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ +int i; +uint32_t reg_value[128 ]; + +for (i =0 ; adev->reset_dump_reg_list[i] !=0 ; i++) { +if (adev->asic_type >=CHIP_NAVI10 )
This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using SOC15_REG_ENTRY_OFFSET() or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.
Alex
Quoted 58 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + +trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list, reg_value, i); + +return 0 ; +} +int amdgpu_do_asic_reset (struct list_head *device_list_handle,struct amdgpu_reset_context *reset_context) {@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false;if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; - }else + }else { +amdgpu_reset_reg_dumps (tmp_adev); r =amdgpu_asic_reset (tmp_adev); + }if (r) { dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-1@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), +TP_ARGS (address, value, length), +TP_STRUCT__entry ( + __array(long, address, 128) + __array(uint32_t, value, 128) +__field (int, len) + ), +TP_fast_assign ( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), +TP_printk ("amdgpu register dump offset: %s value: %s " , +__print_array (__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); +#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif --2.25.1
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 18 lines
Quoted 16 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,return r; }
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ +int i; +uint32_t reg_value[128 ]; + +for (i =0 ; adev->reset_dump_reg_list[i] !=0 ; i++) { +if (adev->asic_type >=CHIP_NAVI10 )This check should be against
CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset usingSOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use RREG32() here and always encode the full register offset.
Regards,
Christian.
Quoted 61 lines
Alex
Quoted 58 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +13
-1+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + +trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list, reg_value, i); + +return 0 ; +} +int amdgpu_do_asic_reset (struct list_head *device_list_handle,struct amdgpu_reset_context *reset_context) {@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false;if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; - }else + }else { +amdgpu_reset_reg_dumps (tmp_adev); r =amdgpu_asic_reset (tmp_adev); + }if (r) { dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-1@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), +TP_ARGS (address, value, length), +TP_STRUCT__entry ( + __array(long, address, 128) + __array(uint32_t, value, 128) +__field (int, len) + ), +TP_fast_assign ( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), +TP_printk ("amdgpu register dump offset: %s value: %s " , +__print_array (__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); +#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif --2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 36 lines · Christian König
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 19 lines
Quoted 17 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.
Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.
Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 67 lines
Quoted 66 lines
Alex
Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] = RREG32_SOC15_IP(GC, adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list, reg_value,i);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len, 8), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 1 line
2.25.1
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 54 lines · Christian König
Quoted 37 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 20 lines
Quoted 18 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);
Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Regards,
Christian.
Quoted 73 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 68 lines
Quoted 67 lines
Alex
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] = RREG32_SOC15_IP(GC, adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 61 lines · Christian König
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 60 lines · Christian König
Quoted 37 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 20 lines
Quoted 18 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
Quoted 9 lines
Quoted 1 line
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Regards,
Christian.
Thanks Christian.
should I consider using gfxoff like below code or not required:amdgpu_gfx_off_ctrl(adev, false); amdgpu_gfx_off_ctrl(adev, true);
Regards,
S.Amarnath
Quoted 74 lines
Quoted 73 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 68 lines
Quoted 67 lines
Alex
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] = RREG32_SOC15_IP(GC, adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Am 10.02.22 um 08:34 schrieb Somalapuram, Amaranath:
Quoted 70 lines · Christian König
Quoted 68 lines
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 55 lines · Christian König
Quoted 38 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 21 lines
Quoted 19 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19
+++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Quoted 8 lines
Quoted 3 lines
Regards,
Christian.Thanks Christian.
should I consider using gfxoff like below code or not required:
amdgpu_gfx_off_ctrl(adev, false);amdgpu_gfx_off_ctrl(adev, true);
That's a really good question I can't fully answer.
I think we don't want that because the GPU is stuck when the dump is made, but better let Alex comment as well.
Regards,
Christian.
Quoted 78 lines
Regards,
S.Amarnath
Quoted 73 lines
Quoted 72 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 67 lines
Quoted 66 lines
Alex
Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + +trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list, reg_value, i); + + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 80 lines · Christian König
Am 10.02.22 um 08:34 schrieb Somalapuram, Amaranath:
Quoted 70 lines · Christian König
Quoted 68 lines
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 55 lines · Christian König
Quoted 38 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 21 lines
Quoted 19 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19
+++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct · line 4544
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Quoted 8 lines
Quoted 3 lines
Regards,
Christian.Thanks Christian.
should I consider using gfxoff like below code or not required:
amdgpu_gfx_off_ctrl(adev, false);amdgpu_gfx_off_ctrl(adev, true);
Quoted 6 lines
That's a really good question I can't fully answer.
I think we don't want that because the GPU is stuck when the dump is made, but better let Alex comment as well.
Regards,
Christian.
I had a quick look at the function amdgpu_gfx_off_ctrl, and it locks this mutex internally:mutex_lock(&adev->gfx.gfx_off_mutex);
and the reference state is tracked in:adev->gfx.gfx_off_state
We can do something like this maybe:
- If (adev->gfx_off_state == 0) {
trylock(gfx_off_mutex)
read_regs_now;
unlock_mutex();
}
How does it sounds ?
- Shashank
Quoted 80 lines
Quoted 79 lines
Regards,
S.Amarnath
Quoted 73 lines
Quoted 72 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 67 lines
Quoted 66 lines
Alex
Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + +trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list, reg_value, i); + + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Am 10.02.22 um 14:18 schrieb Sharma, Shashank:
Quoted 97 lines · Christian König
Quoted 80 lines
Am 10.02.22 um 08:34 schrieb Somalapuram, Amaranath:
Quoted 70 lines · Christian König
Quoted 68 lines
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 55 lines · Christian König
Quoted 38 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 21 lines
Quoted 19 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19
+++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct · line 4544
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Quoted 8 lines
Quoted 3 lines
Regards,
Christian.Thanks Christian.
should I consider using gfxoff like below code or not required:
amdgpu_gfx_off_ctrl(adev, false);amdgpu_gfx_off_ctrl(adev, true);Quoted 6 lines
That's a really good question I can't fully answer.
I think we don't want that because the GPU is stuck when the dump is made, but better let Alex comment as well.
Regards,
Christian.I had a quick look at the function
amdgpu_gfx_off_ctrl, and it locks this mutex internally:mutex_lock(&adev->gfx.gfx_off_mutex);and the reference state is tracked in:
adev->gfx.gfx_off_state
Quoted 8 lines
We can do something like this maybe:
- If (adev->gfx_off_state== 0) {
trylock(gfx_off_mutex)
read_regs_now;
unlock_mutex();
}How does it sounds ?
As far as I know that won't work. GFX_off is only disabled intentionally in very few places.
So we will probably never get a register trace with that.
Regards,
Christian.
Quoted 83 lines
- Shashank
Quoted 81 lines
Quoted 80 lines
Regards,
S.Amarnath
Quoted 74 lines
Quoted 73 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 68 lines
Quoted 67 lines
Alex
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 105 lines · Christian König
Am 10.02.22 um 14:18 schrieb Sharma, Shashank:
Quoted 104 lines · Christian König
Quoted 80 lines
Am 10.02.22 um 08:34 schrieb Somalapuram, Amaranath:
Quoted 70 lines · Christian König
Quoted 68 lines
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 55 lines · Christian König
Quoted 38 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 21 lines
Quoted 19 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19
+++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct · line 4544
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Quoted 8 lines
Quoted 3 lines
Regards,
Christian.Thanks Christian.
should I consider using gfxoff like below code or not required:
amdgpu_gfx_off_ctrl(adev, false);amdgpu_gfx_off_ctrl(adev, true);Quoted 6 lines
That's a really good question I can't fully answer.
I think we don't want that because the GPU is stuck when the dump is made, but better let Alex comment as well.
Regards,
Christian.I had a quick look at the function
amdgpu_gfx_off_ctrl, and it locks this mutex internally:mutex_lock(&adev->gfx.gfx_off_mutex);and the reference state is tracked in:
adev->gfx.gfx_off_stateWe can do something like this maybe:
- If (adev->gfx_off_state== 0) {
trylock(gfx_off_mutex)
read_regs_now;
unlock_mutex();
}
Quoted 6 lines
Quoted 1 line
How does it sounds ?
As far as I know that won't work.
GFX_offis only disabled intentionally in very few places.So we will probably never get a register trace with that.
Ok, I don't know much about this feature, but due to the name I was udner the impression that gfx_off will be mostly disabled. But if it is hardly ever disabled, we need more infomrmation about it first, like when is this disabled and why ?
Alex ?
- Shashank
Quoted 87 lines
Regards,
Christian.Quoted 83 lines
- Shashank
Quoted 81 lines
Quoted 80 lines
Regards,
S.Amarnath
Quoted 74 lines
Quoted 73 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 68 lines
Quoted 67 lines
Alex
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Quoted 130 lines · Shashank
Quoted 118 lines · Christian König
Am 10.02.22 um 14:18 schrieb Sharma, Shashank:
Quoted 117 lines · Christian König
Quoted 91 lines
Am 10.02.22 um 08:34 schrieb Somalapuram, Amaranath:
Quoted 81 lines · Christian König
Quoted 79 lines
Am 10.02.22 um 06:29 schrieb Somalapuram, Amaranath:
Quoted 64 lines · Christian König
Quoted 48 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 33 lines
Quoted 18 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by: Somalapuram Amaranath
<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct · line 4544
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0return r; } +static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ +int i; +uint32_t reg_value[128 ]; + +for (i =0 ; adev->reset_dump_reg_list[i] !=0 ; i++) { +if (adev->asic_type >=CHIP_NAVI10 )This check should be against
CHIP_VEGA10. Also, this only allows for
GC registers. If we wanted to dump other registers, we'd need aQuoted 8 lines
different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think
about how to handle gfxoff in this case. gfxoff needs to be disabled
or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
Quoted 6 lines
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] =
RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);Quoted 7 lines
ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
No, that won't work.
What you need to do is to use the full 32bit address of the register. Userspace can worry about figuring out which ip, instance, base and reg to resolve into that address.
Quoted 8 lines
Quoted 3 lines
Regards,
Christian.Thanks Christian.
should I consider using gfxoff like below code or not required:
amdgpu_gfx_off_ctrl(adev, false);amdgpu_gfx_off_ctrl(adev, true);Quoted 7 lines
That's a really good question I can't fully answer.
I think we don't want that because the GPU is stuck when the dump is made, but better let Alex comment as well.
Regards,
Christian.I had a quick look at the function
amdgpu_gfx_off_ctrl, and it locks this mutex internally:mutex_lock(&adev->gfx.gfx_off_mutex);and the reference state is tracked in:
adev->gfx.gfx_off_stateWe can do something like this maybe:
- If (adev->gfx_off_state== 0) {
trylock(gfx_off_mutex)
read_regs_now;
unlock_mutex();
}Quoted 7 lines
Quoted 1 line
How does it sounds ?
As far as I know that won't work.
GFX_offis only disabled intentionally in very few places.So we will probably never get a register trace with that.
Quoted 6 lines
Ok, I don't know much about this feature, but due to the name I was udner the impression that
gfx_offwill be mostly disabled. But if it is hardly ever disabled, we need more infomrmation about it first, like when is this disabled and why ?Alex ?
gfxoff is enabled most of the time. The only times we disable it are for certain features (reading gfx or sdma MMIO registers, using SQTT, etc.). The two main cases where it would get disabled are calling the READ_MMR query to the INFO ioctl and if you change the power state to a profiling mode (either via sysfs or the context ioctl). If you don't disable gfx off and you access a register via MMIO, the GFX block will hang. So depending on the the nature of the hang, gfxoff may or may not be a problem. E.g., if the hang is caused by VCN or some power management thing gfxoff may still kick in and power down the gfx block. If the gfx block itself is hung, then most likely gfxoff would not be active since the gfx block is active (and hung). So if we didn't disable gfxoff and it is active, and then we try and read the registers, we'll hang the gfx block. That's probably fine since we'll be reseting the GPU anyway, but it will mean any registers in the dump will be worthless.
Alex
Quoted 96 lines
- Shashank
Quoted 93 lines
Regards,
Christian.Quoted 89 lines
- Shashank
Quoted 87 lines
Quoted 86 lines
Regards,
S.Amarnath
Quoted 80 lines
Quoted 79 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Quoted 72 lines
Quoted 71 lines
Alex
Quoted 67 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] =RREG32_SOC15_IP (GC , adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ +return 0 ; +} +int amdgpu_do_asic_reset (struct list_head *device_list_handle, struct amdgpu_reset_context
*reset_context)
{drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false;if (!queue_work (system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY ; - }else + }else { +amdgpu_reset_reg_dumps (tmp_adev); r =amdgpu_asic_reset (tmp_adev); + }if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-1@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), +TP_ARGS (address, value, length), +TP_STRUCT__entry ( + __array(long, address, 128) + __array(uint32_t, value, 128) +__field (int, len) + ), +TP_fast_assign ( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), +__print_array (__entry->value, __entry->len,8 ) + ) +); +#undef AMDGPU_JOB_GET_TIMELINE_NAME#endif --2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
In reply to Somalapuram, AmaranathQuoted 57 lines · Amaranath
Quoted 36 lines · Christian König
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 19 lines
Quoted 17 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
Quoted 8 lines
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Why cant we use just a simple array adev->reset_dump_reg_list[10] for both ip and reg offsets ?
Userspace can provide the IP engine enum in first entry of the array,
reset_dump_reg_list[0], and register offsets in other entries starting from 1. We can convert that into desirable engine substring using an array of char *, something like:
const char *ip_engine_name_substing[] = {
/* Same order as enum amd_hw_ip_block_type */
"GC", "HDP", ......
}engine enum;
u32 ip = adev->reset_dump_reg_list[0];
const char *ip_name = ip_engine_name_subs[ip];
for (i = 0; i < 9; i++) {
reg_val = RREG_SOC15_IP(ip_name, reset_dump_reg_list[i+1]);
}- Shashank
Quoted 67 lines
Quoted 67 lines
Quoted 66 lines
Alex
Quoted 62 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] = RREG32_SOC15_IP(GC, adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list, reg_value,i);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len, 8), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 1 line
2.25.1
Re: [PATCH 2/2] drm/amdgpu: add reset register trace function on GPU reset
Am 10.02.22 um 12:59 schrieb Sharma, Shashank:
Quoted 65 lines · Amaranath
Quoted 62 lines · Christian König
Quoted 37 lines
Am 08.02.22 um 16:28 schrieb Alex Deucher:
Quoted 20 lines
Quoted 18 lines · Somalapuram Amaranath
Dump the list of register values to trace event on GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 21
++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 19 +++++++++++++++++++2 files changed, 39 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -4534,6 +4534,23 @@ int amdgpu_device_pre_asic_reset(structamdgpu_device *adev, return r; }Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, · line 4543
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-0+static int amdgpu_reset_reg_dumps (struct amdgpu_device *adev) +{ + int i; + uint32_t reg_value[128]; + + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++) { + if (adev->asic_type >= CHIP_NAVI10)This check should be against CHIP_VEGA10. Also, this only allows for GC registers. If we wanted to dump other registers, we'd need a different macro. Might be better to just use RREG32 here for everything and then encode the full offset using
SOC15_REG_ENTRY_OFFSET()or a similar macro. Also, we need to think about how to handle gfxoff in this case. gfxoff needs to be disabled or we'll hang the chip if we try and read GC or SDMA registers via MMIO which will adversely affect the hang signature.Quoted 7 lines
Well this should execute right before a GPU reset, so I think it shouldn't matter if we hang the chip or not as long as the read comes back correctly (I remember a very long UVD debug session because of this).
But in general I agree, we should just use
RREG32()here and always encode the full register offset.Regards,
Christian.Can I use something like this:
+ reg_value[i] = RREG32((adev->reg_offset[adev->reset_dump_reg_list[i][0]]
+ [adev->reset_dump_reg_list[i][1]]
+ [adev->reset_dump_reg_list[i][2]])
+ + adev->reset_dump_reg_list[i][3]);ip --> adev->reset_dump_reg_list[i][0]
inst --> adev->reset_dump_reg_list[i][1]
BASE_IDX--> adev->reset_dump_reg_list[i][2]
reg --> adev->reset_dump_reg_list[i][3]
Quoted 8 lines
Quoted 4 lines
which requires 4 values in user space for each register.
using any existing macro like RREG32_SOC15** will not be able to pass proper argument from user space (like ip##_HWIP or reg##_BASE_IDX)
Why cant we use just a simple array adev->reset_dump_reg_list[10] for both ip and reg offsets ?
That won't work. The IPs are separated into several base registers, see how the SOC15 functions work.
But that's also not necessary. Userspace should have the same information as the kernel about which IP is mapped where.
So all we need here is the already resolved 32bit value of which register to read and are basically done.
Regards,
Christian.
Quoted 87 lines
Userspace can provide the IP engine enum in first entry of the array,
reset_dump_reg_list[0], and register offsets in other entries starting from 1. We can convert that into desirable engine substring using an array of char *, something like:const char *ip_engine_name_substing[] = {
/* Same order as enumamd_hw_ip_block_type*/
"GC", "HDP", ......
}engine enum;
u32 ip = adev->reset_dump_reg_list[0];
const char*ip_name= ip_engine_name_subs[ip];for (i = 0; i < 9; i++) {
reg_val =RREG_SOC15_IP(ip_name, reset_dump_reg_list[i+1]); }- Shashank
Quoted 68 lines
Quoted 68 lines
Quoted 67 lines
Alex
Quoted 63 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ reg_value[i] = RREG32_SOC15_IP(GC, adev->reset_dump_reg_list[i]); + else + reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); + } + + trace_amdgpu_reset_reg_dumps(adev->reset_dump_reg_list,
reg_value, i);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +int
amdgpu_do_asic_reset(struct list_head *device_list_handle, struct amdgpu_reset_context *reset_context){drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4567,8 +4584,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle, tmp_adev->gmc.xgmi.pending_reset = false; if (!queue_work(system_unbound_wq, &tmp_adev->xgmi_reset_work)) r = -EALREADY; - } else + } else { +amdgpu_reset_reg_dumps (tmp_adev); r = amdgpu_asic_reset(tmp_adev); + } if (r) {dev_err(tmp_adev->dev, "ASIC reset failed with error, %d for drm dev, %s",
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19
-0@@ -537,6 +537,25 @@ TRACE_EVENT(amdgpu_ib_pipe_sync, __entry->seqno) ); +TRACE_EVENT (amdgpu_reset_reg_dumps, + TP_PROTO(long *address, uint32_t *value, int length), + TP_ARGS(address, value, length), + TP_STRUCT__entry( + __array(long, address, 128) + __array(uint32_t, value, 128) + __field(int, len) + ), + TP_fast_assign( + memcpy(__entry->address, address, 128); + memcpy(__entry->value, value, 128); + __entry->len = length; + ), + TP_printk("amdgpu register dump offset: %s value: %s ", + __print_array(__entry->address, __entry->len,8 ), + __print_array(__entry->value, __entry->len, 8) + ) +); + #undef AMDGPU_JOB_GET_TIMELINE_NAME #endifSignature · 2 lines
-- 2.25.1
Christian König
maintainerAm 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 13 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 60 +++++++++++++++++++++ 2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1102
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device {struct amdgpu_reset_control *reset_cntl;uint32_t ip_versions[HW_ID_MAX ][HWIP_MAX_INSTANCE ]; + +/* reset dump register */ +long reset_dump_reg_list[128 ];
I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.
Quoted 81 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0};static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +60
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); +static ssize_t amdgpu_reset_dump_register_list_read (struct file *f, +char __user *buf,size_t size,loff_t *pos) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; +char *reg_offset; +int i, r, len; + + reg_offset =kmalloc (2048 ,GFP_KERNEL ); +memset (reg_offset,0 ,2048 ); +for (i =0 ; adev->reset_dump_reg_list[i] !=0 ; i++) +sprintf (reg_offset +strlen (reg_offset),"0x%lx " , adev->reset_dump_reg_list[i]); + +sprintf (reg_offset +strlen (reg_offset),"\n" ); + len =strlen (reg_offset); + +if (*pos >= len) +return 0 ; + + r =copy_to_user (buf, reg_offset, len); + *pos += len - r; +kfree (reg_offset); + +return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, +size_t size,loff_t *pos) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; +char *reg_offset, *reg; +int ret, i =0 ; + + reg_offset =kmalloc (size,GFP_KERNEL ); +memset (reg_offset,0 , size); + ret =copy_from_user (reg_offset, buf, size); + +if (ret) +return -EFAULT ; + +while ((reg =strsep (®_offset," " )) !=NULL ) { + ret =kstrtol (reg,16 , &adev->reset_dump_reg_list[i]); +if (ret) +return -EINVAL ; + i++; + } + +kfree (reg_offset); + +return size; +} + +static const struct file_operations amdgpu_reset_dump_register_list = { + .owner =THIS_MODULE , + .read = amdgpu_reset_dump_register_list_read, + .write = amdgpu_reset_dump_register_list_write, + .llseek = default_llseek +}; +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops);debugfs_create_file ("amdgpu_vm_info" ,0444 , root, adev, &amdgpu_debugfs_vm_info_fops); +debugfs_create_file ("amdgpu_reset_dump_register_list" ,0644 , root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios; adev->debugfs_vbios_blob.size = adev->bios_size;
Amar,
Apart from the long comment,there are a few more bugs in the patch, which I have mentioned here inline. Please check them out.
- Shashank
Quoted 39 lines · Christian König
Am 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 13 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 60 +++++++++++++++++++++2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1101
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + /* reset dump register */ + long reset_dump_reg_list[128];I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0}; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static ssize_t amdgpu_reset_dump_register_list_read (struct file *f, + char __user *buf, size_t size, loff_t *pos) +{
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1621
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset; + int i, r, len; + + reg_offset = kmalloc(2048, GFP_KERNEL); + memset(reg_offset, 0, 2048); + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++)
This loop termination condition is incorrect, why are we running the loop until adev->reset_dump_reg_list[i] != 0 ?
What if I have 10 registers to dump, but my 4th register value is 0 ? It will break the loop at 4 and we will not get all values.
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+ sprintf(reg_offset + strlen(reg_offset), "0x%lx ", adev->reset_dump_reg_list[i]); + + sprintf(reg_offset + strlen(reg_offset), "\n");
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1632
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +8
-0+ len = strlen(reg_offset); + + if (*pos >= len) + return 0; + + r = copy_to_user(buf, reg_offset, len); + *pos += len - r; + kfree(reg_offset);
Also, why are we doing a dynamic memory allocation for reg_offest ? We can simply use adev->reset_dump_reg_list[i] isnt't it ?
simply
for (i=0; i<num_of_regs;i++) {
copy_to_user(buf, adev->reg_list[i], sizeof(uint64_t));
}Or without even a loop, simply:copy_to_user(buf, &adev->reg_list, num_regs * sizeof(uint64_t));
- Shashank
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +8
-0+ + return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = (struct amdgpu_device
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1647
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0*)file_inode(f)->i_private; + char *reg_offset, *reg; + int ret, i = 0; + + reg_offset = kmalloc(size, GFP_KERNEL); + memset(reg_offset, 0, size); + ret = copy_from_user(reg_offset, buf, size); +
We are not allowing user to write into the list, so this whole function can just be a NOOP.
- Shashank
Quoted 35 lines
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +22
-0+ if (ret) + return -EFAULT; + + while ((reg = strsep(®_offset, " ")) != NULL) { + ret = kstrtol(reg, 16, &adev->reset_dump_reg_list[i]); + if (ret) + return -EINVAL; + i++; + } + + kfree(reg_offset); + + return size; +} + +static const struct file_operations amdgpu_reset_dump_register_list = { + .owner = THIS_MODULE, + .read = amdgpu_reset_dump_register_list_read, + .write = amdgpu_reset_dump_register_list_write, + .llseek = default_llseek +}; +int
amdgpu_debugfs_init(struct amdgpu_device *adev)
{
struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops); debugfs_create_file("amdgpu_vm_info", 0444, root, adev, &amdgpu_debugfs_vm_info_fops); + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios; adev->debugfs_vbios_blob.size = adev->bios_size;
Quoted 2 lines · Shashank
I thought we spoke and agreed about:
- Not doing dynamic memory allocation during a reset call,
as there is a redesign debugfs call will happen during the application initialization and not during reset.
Quoted 1 line
- Not doing string operations, but just dumping register values by index.
I think your referring to the second patch which happens during reset and no string operation in second patch.
Quoted 38 lines
NACK !
- Shashank
Amar,
Apart from the long comment,there are a few more bugs in the patch, which I have mentioned here inline. Please check them out.- Shashank
Quoted 28 lines · Christian König
Am 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 14 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 60
+++++++++++++++++++++2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1101
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + /* reset dump register */ + long reset_dump_reg_list[128];I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.
will change uint32_t.
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0}; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static ssize_t amdgpu_reset_dump_register_list_read (struct file *f, + char __user *buf, size_t size, loff_t *pos) +{Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1621
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset; + int i, r, len; + + reg_offset = kmalloc(2048, GFP_KERNEL); + memset(reg_offset, 0, 2048); + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++)This loop termination condition is incorrect, why are we running the loop until adev->reset_dump_reg_list[i] != 0 ?
Quoted 2 lines
What if I have 10 registers to dump, but my 4th register value is 0 ? It will break the loop at 4 and we will not get all values.
agreed, i try to avoid one more variable in adev
Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+ sprintf(reg_offset + strlen(reg_offset), "0x%lx ", adev->reset_dump_reg_list[i]); + + sprintf(reg_offset + strlen(reg_offset), "\n");Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1632
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +8
-0+ len = strlen(reg_offset); + + if (*pos >= len) + return 0; + + r = copy_to_user(buf, reg_offset, len); + *pos += len - r; + kfree(reg_offset);Also, why are we doing a dynamic memory allocation for
reg_offest? We can simply use adev->reset_dump_reg_list[i] isnt't it ?simply
for (i=0; i<num_of_regs;i++) {
copy_to_user(buf, adev->reg_list[i],sizeof(uint64_t)); }
Quoted 4 lines
Or without even a loop, simply:
copy_to_user(buf, &adev->reg_list, num_regs * sizeof(uint64_t));- Shashank
it will not be in user readable format for debugfs, (if non readable is acceptable I will change this)
Quoted 21 lines
+
Quoted 17 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5
-0+ return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1647
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset, *reg; + int ret, i = 0; + + reg_offset = kmalloc(size, GFP_KERNEL); + memset(reg_offset, 0, size); + ret = copy_from_user(reg_offset, buf, size); +We are not allowing user to write into the list, so this whole function can just be a NOOP.
Quoted 1 line
- Shashank
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16
-0+ if (ret) + return -EFAULT; + + while ((reg = strsep(®_offset, " ")) != NULL) { + ret = kstrtol(reg, 16, &adev->reset_dump_reg_list[i]); + if (ret) + return -EINVAL; + i++; + } + + kfree(reg_offset); + + return size; +} + +static const struct file_operations amdgpu_reset_dump_register_list= {
+ .owner =THIS_MODULE,
+ .read =amdgpu_reset_dump_register_list_read, + .write =amdgpu_reset_dump_register_list_write, + .llseek =default_llseekdrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+}; +int
amdgpu_debugfs_init(struct amdgpu_device *adev)
{
struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops); debugfs_create_file("amdgpu_vm_info", 0444, root, adev, &amdgpu_debugfs_vm_info_fops); + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios;
adev->debugfs_vbios_blob.size=adev->bios_size;
Quoted 8 lines · Amaranath
Quoted 2 lines · Shashank
I thought we spoke and agreed about:
- Not doing dynamic memory allocation during a reset call,as there is a redesign debugfs call will happen during the application initialization and not during reset.
Quoted 1 line
- Not doing string operations, but just dumping register values by index.
I think your referring to the second patch which happens during reset and no string operation in second patch.
Pls see my comment in the end.
Quoted 49 lines
Quoted 38 lines
NACK !
- Shashank
Amar,
Apart from the long comment,there are a few more bugs in the patch, which I have mentioned here inline. Please check them out.- Shashank
Quoted 28 lines · Christian König
Am 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 14 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 60
+++++++++++++++++++++2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1101
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + /* reset dump register */ + long reset_dump_reg_list[128];I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.will change
uint32_t.Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0}; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1619
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ char __user *buf, size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset; + int i, r, len; + + reg_offset = kmalloc(2048, GFP_KERNEL);
We also want to understand how does the value 2048 came into picture, probably a macro which calculates the size preprocessing time will work better.
#define #define N_REGS_DUMP_GPU_RESET 10
#define BUFFER_SZ(N_REGS_DUMP_GPU_RESET * (sizeof uint64_t) + 1)
This first macro can be used later for the loop count for registers as well.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1621
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ memset(reg_offset, 0, 2048); + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++)This loop termination condition is incorrect, why are we running the loop until adev->reset_dump_reg_list[i] != 0 ?
What if I have 10 registers to dump, but my 4th register value is 0 ? It will break the loop at 4 and we will not get all values.
agreed, i try to avoid one more variable in adev
Not by the cost of logic of course :).
Now you can run this loop here.
for (i = 0; i < N_REGS...; i++) {
register_value_copy_here;
}Quoted 21 lines
Quoted 21 lines
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ sprintf(reg_offset + strlen(reg_offset), "0x%lx ", adev->reset_dump_reg_list[i]); +Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1632
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+ sprintf(reg_offset + strlen(reg_offset), "\n"); + len = strlen(reg_offset); + + if (*pos >= len) + return 0; + + r = copy_to_user(buf, reg_offset, len); + *pos += len - r; + kfree(reg_offset);Also, why are we doing a dynamic memory allocation for
reg_offest? We can simply use adev->reset_dump_reg_list[i] isnt't it ?simply
for (i=0; i<num_of_regs;i++) {
copy_to_user(buf, adev->reg_list[i],sizeof(uint64_t)); }
Quoted 7 lines
Quoted 4 lines
Or without even a loop, simply:
copy_to_user(buf, &adev->reg_list, num_regs * sizeof(uint64_t));- Shashank
it will not be in user readable format for debugfs, (if non readable is acceptable I will change this)
We are just adding 0x in front of the reg value, so honestly I don't see a huge improvement in the user readability, but if you still want to do the dynamic allocation of memory, add the register offset or name as well, I mean then it should read like:
0x1234 = 0xABCD0x1238 = 0xFFFF
- Shashank
Quoted 61 lines
Quoted 21 lines
+
Quoted 17 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5
-0+ return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1647
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset, *reg; + int ret, i = 0; + + reg_offset = kmalloc(size, GFP_KERNEL); + memset(reg_offset, 0, size); + ret = copy_from_user(reg_offset, buf, size); +We are not allowing user to write into the list, so this whole function can just be a NOOP.
Quoted 1 line
- Shashank
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16
-0+ if (ret) + return -EFAULT; + + while ((reg = strsep(®_offset, " ")) != NULL) { + ret = kstrtol(reg, 16, &adev->reset_dump_reg_list[i]); + if (ret) + return -EINVAL; + i++; + } + + kfree(reg_offset); + + return size; +} + +static const struct file_operations amdgpu_reset_dump_register_list= {
+ .owner =THIS_MODULE,
+ .read =amdgpu_reset_dump_register_list_read, + .write =amdgpu_reset_dump_register_list_write, + .llseek =default_llseekdrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+}; +int
amdgpu_debugfs_init(struct amdgpu_device *adev)
{
struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops); debugfs_create_file("amdgpu_vm_info", 0444, root, adev, &amdgpu_debugfs_vm_info_fops); + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios;
adev->debugfs_vbios_blob.size=adev->bios_size;
Quoted 2 lines
Quoted 2 lines
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
I missed this comment in the last patch, and this makes me a bit confused. During the design phase, did we agree to have this whole list loaded from user ? which means that if user doesn't define the list at init, we will not send the trace_event().
Or was it kernel has a list, and user can modify if he wants to, and we will dump the values as per the register list.
@Christian ?
Regards
Shashank
Quoted 194 lines · Shashank
Quoted 9 lines · Amaranath
Quoted 2 lines · Shashank
I thought we spoke and agreed about:
- Not doing dynamic memory allocation during a reset call,as there is a redesign debugfs call will happen during the application initialization and not during reset.
Quoted 2 lines
- Not doing string operations, but just dumping register values by index.
I think your referring to the second patch which happens during reset and no string operation in second patch.
Pls see my comment in the end.
Quoted 49 lines
Quoted 38 lines
NACK !
- Shashank
Amar,
Apart from the long comment,there are a few more bugs in the patch, which I have mentioned here inline. Please check them out.- Shashank
Quoted 28 lines · Christian König
Am 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 14 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 60
+++++++++++++++++++++2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1101
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + /* reset dump register */ + long reset_dump_reg_list[128];I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.will change
uint32_t.Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0}; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1619
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ char __user *buf, size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset; + int i, r, len; + + reg_offset = kmalloc(2048, GFP_KERNEL);We also want to understand how does the value 2048 came into picture, probably a macro which calculates the size preprocessing time will work better.
#define #define
N_REGS_DUMP_GPU_RESET10
#defineBUFFER_SZ(N_REGS_DUMP_GPU_RESET * (sizeof uint64_t) + 1)This first macro can be used later for the loop count for registers as well.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1621
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ memset(reg_offset, 0, 2048); + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++)This loop termination condition is incorrect, why are we running the loop until adev->reset_dump_reg_list[i] != 0 ?
What if I have 10 registers to dump, but my 4th register value is 0 ? It will break the loop at 4 and we will not get all values.
agreed, i try to avoid one more variable in adev
Not by the cost of logic of course :).
Now you can run this loop here.
for (i = 0; i <
N_REGS...; i++) {
register_value_copy_here;
}Quoted 21 lines
Quoted 21 lines
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ sprintf(reg_offset + strlen(reg_offset), "0x%lx ", adev->reset_dump_reg_list[i]); +Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1632
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+ sprintf(reg_offset + strlen(reg_offset), "\n"); + len = strlen(reg_offset); + + if (*pos >= len) + return 0; + + r = copy_to_user(buf, reg_offset, len); + *pos += len - r; + kfree(reg_offset);Also, why are we doing a dynamic memory allocation for
reg_offest? We can simply use adev->reset_dump_reg_list[i] isnt't it ?simply
for (i=0; i<num_of_regs;i++) {
copy_to_user(buf, adev->reg_list[i],sizeof(uint64_t)); }Quoted 7 lines
Quoted 4 lines
Or without even a loop, simply:
copy_to_user(buf, &adev->reg_list, num_regs * sizeof(uint64_t));- Shashank
it will not be in user readable format for debugfs, (if non readable is acceptable I will change this)
We are just adding 0x in front of the reg value, so honestly I don't see a huge improvement in the user readability, but if you still want to do the dynamic allocation of memory, add the register offset or name as well, I mean then it should read like:
0x1234=0xABCD0x1238=0xFFFF- Shashank
Quoted 61 lines
Quoted 21 lines
+
Quoted 17 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5
-0+ return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1647
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset, *reg; + int ret, i = 0; + + reg_offset = kmalloc(size, GFP_KERNEL); + memset(reg_offset, 0, size); + ret = copy_from_user(reg_offset, buf, size); +We are not allowing user to write into the list, so this whole function can just be a NOOP.
Quoted 1 line
- Shashank
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +16
-0+ if (ret) + return -EFAULT; + + while ((reg = strsep(®_offset, " ")) != NULL) { + ret = kstrtol(reg, 16, &adev->reset_dump_reg_list[i]); + if (ret) + return -EINVAL; + i++; + } + + kfree(reg_offset); + + return size; +} + +static const struct file_operations
amdgpu_reset_dump_register_list= {
+ .owner =THIS_MODULE,
+ .read =amdgpu_reset_dump_register_list_read, + .write =amdgpu_reset_dump_register_list_write, + .llseek =default_llseekdrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+}; +int
amdgpu_debugfs_init(struct amdgpu_device *adev)
{
struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops); debugfs_create_file("amdgpu_vm_info", 0444, root, adev, &amdgpu_debugfs_vm_info_fops); + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios;
adev->debugfs_vbios_blob.size=adev->bios_size;
Sharma, Shashank
Reviewed-byBased on confirmation from Christian, it seems my understanding of the design was not correct, and user must add a list of registers to dump.
That resolves most of my comments automatically, @Amar, please fix a max register condition in the loop, to handle the negative testing case and the uint32_t stuff. With those two changes in place, feel free to use for this patch:
- Shashank
Quoted 207 lines · Shashank
Quoted 2 lines
Quoted 2 lines
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
I missed this comment in the last patch, and this makes me a bit confused. During the design phase, did we agree to have this whole list loaded from user ? which means that if user doesn't define the list at init, we will not send the
trace_event().Or was it kernel has a list, and user can modify if he wants to, and we will dump the values as per the register list.
@Christian ?
Regards
ShashankQuoted 195 lines · Shashank
Quoted 9 lines · Amaranath
Quoted 2 lines · Shashank
I thought we spoke and agreed about:
- Not doing dynamic memory allocation during a reset call,as there is a redesign debugfs call will happen during the application initialization and not during reset.
Quoted 2 lines
- Not doing string operations, but just dumping register values by index.
I think your referring to the second patch which happens during reset and no string operation in second patch.
Pls see my comment in the end.
Quoted 50 lines
Quoted 38 lines
NACK !
- Shashank
Amar,
Apart from the long comment,there are a few more bugs in the patch, which I have mentioned here inline. Please check them out.- Shashank
Quoted 28 lines · Christian König
Am 08.02.22 um 09:16 schrieb Somalapuram Amaranath:
Quoted 14 lines
List of register to be populated for dump collection during the GPU reset.
Signed-off-by Somalapuram Amaranath <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c| 60
+++++++++++++++++++++2 files changed, 63 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1101
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1097,6 +1097,9 @@ struct amdgpu_device { struct amdgpu_reset_control *reset_cntl; uint32_t ip_versions[HW_ID_MAX][HWIP_MAX_INSTANCE]; + + /* reset dump register */ + long reset_dump_reg_list[128];I don't have time for a full review, but using long here certainly makes no sense.
long is either 32bit or 64bit depending on the CPU architecture.
Regards,
Christian.will change
uint32_t.Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0}; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-0@@ -1609,6 +1609,64 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt,NULL , DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1619
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ char __user *buf, size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = (struct amdgpu_device *)file_inode (f)->i_private; + char *reg_offset; + int i, r, len; + + reg_offset = kmalloc(2048, GFP_KERNEL);We also want to understand how does the value 2048 came into picture, probably a macro which calculates the size preprocessing time will work better.
#define #define
N_REGS_DUMP_GPU_RESET10
#defineBUFFER_SZ(N_REGS_DUMP_GPU_RESET * (sizeof uint64_t) + 1)This first macro can be used later for the loop count for registers as well.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1621
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ memset(reg_offset, 0, 2048); + for (i = 0; adev->reset_dump_reg_list[i] != 0; i++)This loop termination condition is incorrect, why are we running the loop until adev->reset_dump_reg_list[i] != 0 ?
What if I have 10 registers to dump, but my 4th register value is 0 ? It will break the loop at 4 and we will not get all values.
agreed, i try to avoid one more variable in adev
Not by the cost of logic of course :).
Now you can run this loop here.
for (i = 0; i <
N_REGS...; i++) {
register_value_copy_here;
}Quoted 21 lines
Quoted 21 lines
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+ sprintf(reg_offset + strlen(reg_offset), "0x%lx ", adev->reset_dump_reg_list[i]); +Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1632
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9
-0+ sprintf(reg_offset + strlen(reg_offset), "\n"); + len = strlen(reg_offset); + + if (*pos >= len) + return 0; + + r = copy_to_user(buf, reg_offset, len); + *pos += len - r; + kfree(reg_offset);Also, why are we doing a dynamic memory allocation for
reg_offest? We can simply use adev->reset_dump_reg_list[i] isnt't it ?simply
for (i=0; i<num_of_regs;i++) {
copy_to_user(buf, adev->reg_list[i],sizeof(uint64_t)); }Quoted 7 lines
Quoted 4 lines
Or without even a loop, simply:
copy_to_user(buf, &adev->reg_list, num_regs * sizeof(uint64_t));- Shashank
it will not be in user readable format for debugfs, (if non readable is acceptable I will change this)
We are just adding 0x in front of the reg value, so honestly I don't see a huge improvement in the user readability, but if you still want to do the dynamic allocation of memory, add the register offset or name as well, I mean then it should read like:
0x1234=0xABCD0x1238=0xFFFF- Shashank
Quoted 61 lines
Quoted 21 lines
+
Quoted 17 lines
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +7
-0+ return len - r; +} + +static ssize_t amdgpu_reset_dump_register_list_write (struct file *f,const char __user *buf, + size_t size, loff_t *pos) +{ + struct amdgpu_device *adev = (struct amdgpu_device*)file_inode(f)->i_private;
+ char*reg_offset, *reg;
+ int ret, i = 0;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1647
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5
-0+ + reg_offset = kmalloc(size, GFP_KERNEL); + memset(reg_offset, 0, size); + ret = copy_from_user(reg_offset, buf, size); +We are not allowing user to write into the list, so this whole function can just be a NOOP.
Quoted 1 line
- Shashank
User only update the list of reg offsets on init, there is no predefined reg offset from kernel code.
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
+ if (ret)
+ return-EFAULT;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +14
-0+ + while ((reg = strsep(®_offset, " ")) != NULL) { + ret = kstrtol(reg, 16, &adev->reset_dump_reg_list[i]); + if (ret) + return -EINVAL; + i++; + } + + kfree(reg_offset); + + return size; +} + +static const struct file_operations
amdgpu_reset_dump_register_list= {
+ .owner =THIS_MODULE,
+ .read =amdgpu_reset_dump_register_list_read, + .write =amdgpu_reset_dump_register_list_write, + .llseek =default_llseekdrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0+}; +int
amdgpu_debugfs_init(struct amdgpu_device *adev)
{
struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1672,6 +1730,8 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev) &amdgpu_debugfs_test_ib_fops); debugfs_create_file("amdgpu_vm_info", 0444, root, adev, &amdgpu_debugfs_vm_info_fops); + debugfs_create_file("amdgpu_reset_dump_register_list", 0644, root, adev, + &amdgpu_reset_dump_register_list); adev->debugfs_vbios_blob.data = adev->bios;
adev->debugfs_vbios_blob.size=adev->bios_size;
I thought we spoke and agreed about:
- Not doing dynamic memory allocation during a reset call,
- Not doing string operations, but just dumping register values by index.
NACK !
- Shashank
-----Original Message-----
From: Somalapuram, Amaranath <[email protected]>
Sent: Tuesday, February 8, 2022 9:17 AM
To: [email protected]
Cc: Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Sharma, Shashank <[email protected]>; Somalapuram, Amaranath <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: add debugfs for reset registers list
List of register to be populated for dump collection during the GPU reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 60 +++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -1097,6 +1097,9 @@ struct amdgpu_device {struct amdgpu_reset_control *reset_cntl;uint32_t ip_versions[HW_ID_MAX ][HWIP_MAX_INSTANCE ]; + +/* reset dump register */ +long reset_dump_reg_list[128 ]; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 164d6a9e9fbb..dad268e8a81a 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +60 -0
70 lines not on this page · raw message
--
2.25.1