drm/amdgpu: add support to SMU debug option
Subsystems (3)
PATCH 1/1 drm/amdgpu: add support to SMU debug option
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via amdgpu_smu_debug debugfs file. When enabled, it makes SMU errors fatal. It is disabled by default.
== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug
2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debug
v3:
- Use debugfs_create_bool().(Christian)
- Put variable into smu_context struct.
- Don't resend command when timeout.
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -0
@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -0
@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct smu_context *smu) out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +7 -1
@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +return res; }
Signature · 1 line
2.25.1
Christian König
maintainerAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 23 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal. It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.
Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>
Well the debugfs part looks really nice and clean now, but one more comment below.
Quoted 63 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct smu_context *smu) out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-1@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 )
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0+if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON() really crashes the kernel and is only allowed if we prevent further data corruption with that.
Most of the time WARN_ON() is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
Quoted 92 lines · Lang
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal. It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct smu_context *smu) out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 366
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +
Do we need to add BUG_ON on smu_cmn_send_msg_without_waiting() as well?
Thanks,
Ray
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0return res; }Signature · 1 line
2.25.1
Quoted 70 lines · Lang Yu
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal. It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct smu_context *smu) · line 1923
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct smu_context *smu) out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +
This hunk can be skipped while submitting. If this fails, GPU reset will fail and amdgpu won't continue.
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg);
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 358
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-1goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out;
Next step is reading smu parameter register which is harmless as reading response register and it's not clear on read. This goto also may be skipped.
Thanks,
Lijo
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +return res; }
[AMD Official Use Only]
Quoted 85 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 5:47 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optiondrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 40 lines · Lang Yu
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct smu_context *smu) · line 1923
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +This hunk can be skipped while submitting. If this fails, GPU reset will fail and amdgpu won't continue.
Ok, we don't handle such cases.
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 358
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out;Next step is reading smu parameter register which is harmless as reading response register and it's not clear on read. This goto also may be skipped.
I just think that does some extra work. We don’t want to read response register. This goto makes error handling more clear.
Regards,
Lang
Quoted 15 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +return res; }
[AMD Official Use Only]
Quoted 124 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 22 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 )drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0+if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.
This is what SMU FW guys want. They want "user-visible (potentially fatal) errors", then a hang. They want to keep system state since the error occurred.
Regards,
Lang
Quoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
Quoted 125 lines · Lang
[AMD Official Use Only]
Quoted 85 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 5:47 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optiondrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 40 lines · Lang Yu
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct smu_context *smu) · line 1923
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +This hunk can be skipped while submitting. If this fails, GPU reset will fail and amdgpu won't continue.
Ok, we don't handle such cases.
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 358
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out;Next step is reading smu parameter register which is harmless as reading response register and it's not clear on read. This goto also may be skipped.
Quoted 3 lines
I just think that does some extra work. We don’t want to read response register. This goto makes error handling more clear.
This change affects non-debug mode also. If things are normal, error handling is supposed to be done by the caller based on the FW response and/or return parameter value, if there is any. smu_debug_mode shouldn't change that.
Thanks,
Lijo
Quoted 18 lines
Regards,
LangQuoted 15 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +return res; }
Am 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 126 lines
[AMD Official Use Only]
Quoted 122 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 22 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 )drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0+if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.
Quoted 4 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal) errors", then a hang. They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the BUG_ON() before dropping the lock to make sure that this really gets the driver stuck in the current state.
Regards,
Christian.
Quoted 10 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
[AMD Official Use Only]
Quoted 137 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 6:46 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionQuoted 124 lines · Lang
[AMD Official Use Only]
Quoted 85 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 5:47 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optiondrivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 40 lines · Lang Yu
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct smu_context *smu) · line 1923
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +This hunk can be skipped while submitting. If this fails, GPU reset will fail and amdgpu won't continue.
Ok, we don't handle such cases.
Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 358
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out;Next step is reading smu parameter register which is harmless as reading response register and it's not clear on read. This goto also may be
skipped.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
I just think that does some extra work. We don’t want to read response register. This goto makes error handling more clear.
This change affects non-debug mode also. If things are normal, error handling is supposed to be done by the caller based on the FW response and/or return parameter value, if there is any.
smu_debug_modeshouldn't change that.
Thanks, I got it.
Quoted 21 lines
Thanks,
LijoQuoted 18 lines
Regards,
LangQuoted 15 lines
Thanks,
LijoQuoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res); +return res; }
[AMD Official Use Only]
Quoted 144 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 126 lines
[AMD Official Use Only]
Quoted 122 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 22 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 )drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0+if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 3 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
Quoted 8 lines
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.
Thanks. I got it. I just thought it is a kenel panic. Could we use a panic() here?
Regards,
Lang
Quoted 13 lines
Regards,
Christian.Quoted 10 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
Christian König
maintainerAm 01.12.21 um 12:20 schrieb Yu, Lang:
Quoted 148 lines
[AMD Official Use Only]
Quoted 146 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 126 lines
[AMD Official Use Only]
Quoted 122 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 22 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent =debugfs_create_file ("amdgpu_preempt_ib" ,0600 , root, adev, &fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-1__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 )drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0+if (res !=0 ) {__smu_cmn_reg_print_error (smu, reg, index, param, msg); + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 3 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Quoted 7 lines
Quoted 5 lines
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?
Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when a problem occurs?
When they connect external hardware a BUG_ON() while holding the SMU lock might work, but if they want to SSH into the system you should probably rather set a flag that the hardware shouldn't be touched any more by the driver and continue.
Otherwise the box is most likely really unstable after this.
Regards,
Christian.
Quoted 16 lines
Regards,
LangQuoted 12 lines
Regards,
Christian.Quoted 9 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
[AMD Official Use Only]
Quoted 168 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 7:29 PM
To: Yu, Lang <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 12:20 schrieb Yu, Lang:
Quoted 69 lines
[AMD Official Use Only]
Quoted 67 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 57 lines
[AMD Official Use Only]
Quoted 53 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 22 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option support.
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0if (!debugfs_initialized ())return 0 ; +debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root,adev,
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0&fops_ib_preempt);if (IS_ERR (ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };struct i2c_adapter ;drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ intsmu_cmn_send_smc_msg_with_param(struct
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
smu_context*smu,Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0__smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) { __smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 365
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 4 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.
Quoted 8 lines
Quoted 2 lines
Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when a problem occurs?
As far as I know, they usually use a HDT to collect information.
And they request a hang when error occurred in ticket.
"Suggested error responses include pop-up windows (by x86 driver, if this is possible) or simply hanging after logging the error. "
Regards,
Lang
Quoted 27 lines
When they connect external hardware a
BUG_ON()while holding the SMU lock might work, but if they want to SSH into the system you should probably rather set a flag that the hardware shouldn't be touched any more by the driver and continue.Otherwise the box is most likely really unstable after this.
Regards,
Christian.Quoted 16 lines
Regards,
LangQuoted 12 lines
Regards,
Christian.Quoted 9 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
Adding Andrey as well.
Am 01.12.21 um 12:37 schrieb Yu, Lang:
Quoted 23 lines
[SNIP]
Quoted 22 lines
Quoted 22 lines
Quoted 12 lines
Quoted 8 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ BUG_ON(unlikely(smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
Quoted 8 lines
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?
Quoted 8 lines
Quoted 5 lines
Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when a problem occurs?
As far as I know, they usually use a HDT to collect information.
And they request a hang when error occurred in ticket.
"Suggested error responses include pop-up windows (by x86 driver, if this is possible) or simply hanging after logging the error."
In that case I suggest to set the "don't_touch_the_hardware_any_more" procedure we also use in case of PCIe hotplug.
Andrey has the details but essentially it stops the driver from touching the hardware any more, signals all fences and unblocks everything.
It should then be trivial to inspect the hardware state and see what's going on, but the system will keep stable at least for SSH access.
Might be a good idea to have that mode for other fault cases like page faults and hardware crashes.
Regards,
Christian.
Quoted 4 lines
Regards,
Lang
Quoted 37 lines · Christian König
Adding Andrey as well.
Am 01.12.21 um 12:37 schrieb Yu, Lang:
Quoted 23 lines
[SNIP]
Quoted 22 lines
Quoted 22 lines
Quoted 12 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
+
BUG_ON(unlikely(smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
Quoted 8 lines
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Quoted 8 lines
Quoted 5 lines
Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when a problem occurs?
As far as I know, they usually use a HDT to collect information.
And they request a hang when error occurred in ticket.
"Suggested error responses include pop-up windows (by x86 driver, if this is possible) or simply hanging after logging the error."In that case I suggest to set the "don't_touch_the_hardware_any_more" procedure we also use in case of PCIe hotplug.
Quoted 8 lines
Andrey has the details but essentially it stops the driver from touching the hardware any more, signals all fences and unblocks everything.
It should then be trivial to inspect the hardware state and see what's going on, but the system will keep stable at least for SSH access.
Might be a good idea to have that mode for other fault cases like page faults and hardware crashes.
Regards,
Christian.
There is no one specific function that does all of that, what I think can be done is to bring the device to kind of halt state where no one touches it - as following -
1) Follow amdpgu_pci_remove -
drm_dev_unplug to make device inaccessible to user space (IOCTLs e.t.c.) and clears MMIO mappings to device and disallows remappings through page faults
No need to call all of amdgpu_driver_unload_kms but, within it call amdgpu_irq_disable_all and amdgpu_fence_driver_hw_fini toi disable interrupts and force signall all HW fences.
pci_disable_device and pci_wait_for_pending_transaction to flush any in flight DMA operations from device
2) set adev->no_hw_access so that most of places we access HW (all subsequent registers reads/writes and SMU/PSP message sending is skipped, but some race will be with those already in progress so maybe adding some wait)
Andrey
Quoted 6 lines
Quoted 5 lines
Regards,
Lang
[AMD Official Use Only]
Quoted 193 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu, Lang
Sent: Wednesday, December 1, 2021 7:37 PM
To: Koenig, Christian <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add support to SMU debug option[AMD Official Use Only]
Quoted 9 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 7:29 PM
To: Yu, Lang <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionQuoted 28 lines
Am 01.12.21 um 12:20 schrieb Yu, Lang:
Quoted 27 lines
[AMD Official Use Only]
Quoted 25 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 15 lines
[AMD Official Use Only]
Quoted 11 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 2 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option
support.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 20 lines
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 7 lines
if (!debugfs_initialized()) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent = debugfs_create_file("amdgpu_preempt_ib", 0600,root,
Quoted 19 lines
adev,
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
&fops_ib_preempt); if (IS_ERR(ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-0struct i2c_adapter ;diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cQuoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 5 lines
b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cindex6e781cee8bb6..d3797a2d6451100644drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ intsmu_cmn_send_smc_msg_with_param(struct
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
smu_context*smu,Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0__smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 37 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 357
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) { __smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 365
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 4 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially fatal)
errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the currentstate.
Quoted 6 lines
Quoted 2 lines
Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Potentially, but that might reboot the system automatically which is probably not what you want either.
Quoted 8 lines
Quoted 1 line
How does the SMU firmware team gather the necessary information when
a
Quoted 1 line
problem occurs?
As far as I know, they usually use a HDT to collect information. And they request a hang when error occurred in ticket. "Suggested error responses include pop-up windows (by x86 driver, if this is possible) or simply hanging after logging the error. "
[Quan, Evan] Maybe what they want is just a stable SMU state(like no more message issuing after failure).
If that's true, I think you can just bail out on __smu_cmn_poll_stat() failure(in smu_cmn_send_smc_msg_with_param() and smu_cmn_send_msg_without_waiting()). That will prevent further message issuing to SMU.
BR
Evan
Quoted 31 lines
Regards,
LangQuoted 27 lines
When they connect external hardware a
BUG_ON()while holding the SMU lock might work, but if they want to SSH into the system you should probably rather set a flag that the hardware shouldn't be touched any more by the driver and continue.Otherwise the box is most likely really unstable after this.
Regards,
Christian.Quoted 16 lines
Regards,
LangQuoted 12 lines
Regards,
Christian.Quoted 9 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
[AMD Official Use Only]
Quoted 218 lines
-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Thursday, December 2, 2021 10:48 AM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add support to SMU debug option[AMD Official Use Only]
Quoted 196 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu, Lang
Sent: Wednesday, December 1, 2021 7:37 PM
To: Koenig, Christian <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add support to SMU debug option[AMD Official Use Only]
Quoted 9 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 7:29 PM
To: Yu, Lang <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionQuoted 28 lines
Am 01.12.21 um 12:20 schrieb Yu, Lang:
Quoted 27 lines
[AMD Official Use Only]
Quoted 25 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 15 lines
[AMD Official Use Only]
Quoted 11 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 2 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option
support.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 20 lines
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 7 lines
if (!debugfs_initialized()) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent = debugfs_create_file("amdgpu_preempt_ib", 0600,root,
Quoted 19 lines
adev,
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
&fops_ib_preempt); if (IS_ERR(ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-0struct i2c_adapter ;diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cQuoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 5 lines
b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cindex6e781cee8bb6..d3797a2d6451100644drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ intsmu_cmn_send_smc_msg_with_param(struct
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
smu_context*smu,Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0__smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 357
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) { __smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 29 lines
Quoted 29 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 365
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 5 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially
fatal)errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the currentstate.
Quoted 7 lines
Quoted 2 lines
Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when
Quoted 8 lines
a
Quoted 1 line
problem occurs?
As far as I know, they usually use a HDT to collect information. And they request a hang when error occurred in ticket. "Suggested error responses include pop-up windows (by x86 driver, if this is
possible) or simply hanging after logging the error. "
Quoted 6 lines
[Quan, Evan] Maybe what they want is just a stable SMU state(like no more message issuing after failure).
If that's true, I think you can just bail out on__smu_cmn_poll_stat()failure(in smu_cmn_send_smc_msg_with_param() and smu_cmn_send_msg_without_waiting()).
That will prevent further message issuing to SMU.
But it's difficult to distinguish normal timeout cases(see aldebaran_mode2_reset()). Sometimes it's reasonable to return a timeout. The user wants to use a longer timeout.
Regards,
Lang
Quoted 34 lines
BR
EvanQuoted 31 lines
Regards,
LangQuoted 27 lines
When they connect external hardware a
BUG_ON()while holding the SMU lock might work, but if they want to SSH into the system you should probably rather set a flag that the hardware shouldn't be touched any more by the driver and continue.Otherwise the box is most likely really unstable after this.
Regards,
Christian.Quoted 16 lines
Regards,
LangQuoted 12 lines
Regards,
Christian.Quoted 9 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
Quoted 229 lines · Lang
[AMD Official Use Only]
Quoted 218 lines
-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Thursday, December 2, 2021 10:48 AM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add support to SMU debug option[AMD Official Use Only]
Quoted 196 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu, Lang
Sent: Wednesday, December 1, 2021 7:37 PM
To: Koenig, Christian <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add support to SMU debug option[AMD Official Use Only]
Quoted 9 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 7:29 PM
To: Yu, Lang <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionQuoted 28 lines
Am 01.12.21 um 12:20 schrieb Yu, Lang:
Quoted 27 lines
[AMD Official Use Only]
Quoted 25 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Wednesday, December 1, 2021 6:49 PM
To: Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 11:44 schrieb Yu, Lang:
Quoted 15 lines
[AMD Official Use Only]
Quoted 11 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, December 1, 2021 5:30 PM
To: Yu, Lang <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionAm 01.12.21 um 10:24 schrieb Lang Yu:
Quoted 2 lines
To maintain system error state when SMU errors occurred, which will aid in debugging SMU firmware issues, add SMU debug option
support.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 20 lines
It can be enabled or disabled via
amdgpu_smu_debugdebugfs file. When enabled, it makes SMU errors fatal.
It is disabled by default.== Command Guide ==
1, enable SMU debug option
# echo 1 > /sys/kernel/debug/dri/0/amdgpu_smu_debug2, disable SMU debug option
# echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_debugv3:
- Use debugfs_create_bool().(Christian)
- Put variable intosmu_contextstruct.
- Don't resend command when timeout.Quoted 5 lines
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.Signed-off-by Lang Yu <[email protected]>Well the debugfs part looks really nice and clean now, but one more comment below.
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 3 +++ drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h | 5 +++++ drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 ++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -1618,6 +1618,9 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 7 lines
if (!debugfs_initialized()) return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+debugfs_create_bool ("amdgpu_smu_debug" ,0600 , root, + &adev->smu.smu_debug_mode); + ent = debugfs_create_file("amdgpu_preempt_ib", 0600,root,
Quoted 19 lines
adev,
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
&fops_ib_preempt); if (IS_ERR(ent)) {drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5
-0@@ -569,6 +569,11 @@ struct smu_contextstruct smu_user_dpm_profile user_dpm_profile;struct stb_context stb_context; +/* +* When enabled, it makes SMU errors fatal. +* (0 = disabled (default), 1 = enabled) +*/ +bool smu_debug_mode; };Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0
-0struct i2c_adapter ;diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cQuoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c static int aldebaran_mode2_reset(struct
Quoted 5 lines
b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.cindex6e781cee8bb6..d3797a2d6451100644drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0
-0@@ -1919,6 +1919,8 @@ static int aldebaran_mode2_reset(struct
smu_context*smu)Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2
-0out:mutex_unlock (&smu->message_lock); +BUG_ON (unlikely (smu->smu_debug_mode) && ret); +return ret; }Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0@@ -349,15 +349,21 @@ intsmu_cmn_send_smc_msg_with_param(struct
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
smu_context*smu,Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0__smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 357
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +__smu_cmn_send_msg (smu, (uint16_t ) index, param); reg =__smu_cmn_poll_stat (smu); res =__smu_cmn_reg2errno (smu, reg); -if (res !=0 ) +if (res !=0 ) { __smu_cmn_reg_print_error(smu, reg, index, param,msg);
Quoted 29 lines
Quoted 29 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 365
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Quoted 5 lines
Quoted 2 lines
Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially
fatal)errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the currentstate.
Quoted 7 lines
Quoted 2 lines
Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Potentially, but that might reboot the system automatically which is probably not what you want either.
How does the SMU firmware team gather the necessary information when
Quoted 8 lines
a
Quoted 1 line
problem occurs?
As far as I know, they usually use a HDT to collect information. And they request a hang when error occurred in ticket. "Suggested error responses include pop-up windows (by x86 driver, if this is
possible) or simply hanging after logging the error. "Quoted 6 lines
[Quan, Evan] Maybe what they want is just a stable SMU state(like no more message issuing after failure).
If that's true, I think you can just bail out on__smu_cmn_poll_stat()failure(in smu_cmn_send_smc_msg_with_param() and smu_cmn_send_msg_without_waiting()).
That will prevent further message issuing to SMU.
Quoted 3 lines
But it's difficult to distinguish normal timeout
cases(see aldebaran_mode2_reset()). Sometimes it's reasonable to return a timeout. The user wants to use a longer timeout.
Other than driver, other FWs also will interact with PMFW and this itself may not take care of that. The ideal thing is to stop driver jobs and further execution to preserve the fail state. BUG() may be the easiest if the expectation is to use external hardware to check the fail state.
Thanks,
Lijo
Quoted 37 lines
Regards,
LangQuoted 34 lines
BR
EvanQuoted 31 lines
Regards,
LangQuoted 27 lines
When they connect external hardware a
BUG_ON()while holding the SMU lock might work, but if they want to SSH into the system you should probably rather set a flag that the hardware shouldn't be touched any more by the driver and continue.Otherwise the box is most likely really unstable after this.
Regards,
Christian.Quoted 16 lines
Regards,
LangQuoted 12 lines
Regards,
Christian.Quoted 9 lines
Regards,
LangQuoted 6 lines
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+return res; }
[AMD Official Use Only]
Quoted 80 lines
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Thursday, December 2, 2021 12:01 AM
To: Christian König <[email protected]>; Yu, Lang <[email protected]>; Koenig, Christian <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Huang, Ray <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: add support to SMU debug optionQuoted 45 lines · Christian König
Adding Andrey as well.
Am 01.12.21 um 12:37 schrieb Yu, Lang:
Quoted 28 lines
[SNIP]
Quoted 27 lines
Quoted 16 lines
Quoted 16 lines
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
+
BUG_ON(unlikely(smu->smu_debug_mode) && res);
BUG_ON()really crashes the kernel and is only allowed if we prevent further data corruption with that.Most of the time
WARN_ON()is more appropriate, but I can't fully judge here since I don't know the SMU code well enough.This is what SMU FW guys want. They want "user-visible (potentially
fatal)errors", then a hang.
Quoted 1 line
They want to keep system state since the error occurred.
Well that is rather problematic.
First of all we need to really justify that, crashing the kernel is not something easily done.
Quoted 8 lines
Quoted 6 lines
Then this isn't really effective here. What happens is that you crash the kernel thread of the currently executing process, but it is perfectly possible that another thread still tries to send messages to the SMU. You need to have the
BUG_ON()before dropping the lock to make sure that this really gets the driver stuck in the current state.Thanks. I got it. I just thought it is a kenel panic. Could we use a
panic()here?Potentially, but that might reboot the system automatically which is probably not what you want either.
Quoted 6 lines
Quoted 2 lines
How does the SMU firmware team gather the necessary information when a problem occurs?
As far as I know, they usually use a HDT to collect information. And they request a hang when error occurred in ticket. "Suggested error responses include pop-up windows (by x86 driver, if this is possible) or simply hanging after logging the error."
In that case I suggest to set the "don't_touch_the_hardware_any_more" procedure we also use in case of PCIe hotplug.
Andrey has the details but essentially it stops the driver from touching the hardware any more, signals all fences and unblocks everything.
Quoted 8 lines
It should then be trivial to inspect the hardware state and see what's going on, but the system will keep stable at least for SSH access.
Might be a good idea to have that mode for other fault cases like page faults and hardware crashes.
Regards,
Christian.There is no one specific function that does all of that, what I think can be done is to bring the device to kind of halt state where no one touches it - as following -
1) Follow
amdpgu_pci_remove-
drm_dev_unplugto make device inaccessible to user space (IOCTLse.t.c.) and clears MMIO mappings to device and disallows remappings through page faultsNo need to call all of
amdgpu_driver_unload_kmsbut, within it callamdgpu_irq_disable_allandamdgpu_fence_driver_hw_finitoi disable interrupts and force signall all HW fences.
Quoted 8 lines
pci_disable_deviceandpci_wait_for_pending_transactionto flush any in flight DMA operations from device2) set
adev->no_hw_accessso that most of places we access HW (all subsequent registers reads/writes and SMU/PSP message sending is skipped, but some race will be with those already in progress so maybe adding some wait)Andrey
Thanks for Christian's advice and Andrey's clarifications about that. It seems that we should also handle kfd related stuff.
Regards,
Lang
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Regards,
Lang