drm/amdgpu: add SMU debug option support
Subsystems (3)
PATCH 1/1 drm/amdgpu: add SMU debug option support
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
v2:
- Resend command when timeout.(Lijo)
- Use debugfs file instead of module parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +32 -0
@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes *
@@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,return result; } + +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl,
@@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); +static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) +{ + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) +{ +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;
@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { +DRM_ERROR ("unable to create amdgpu_smu_debug debugsfs file\n" ); +return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +37 -2
@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal. +* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) +*/ +int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };
@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }
@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/**
@@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;
@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); +dev_err (smu->adev->dev, +"SMU: resend command: index:%d param:0x%08X message:%s" , + index, param,smu_get_message_name (smu, msg)); + goto retry; + } + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Signature · 1 line
2.25.1
Christian König
maintainerAm 30.11.21 um 06:17 schrieb Lang Yu:
Quoted 42 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_debugv2:
- 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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes *
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf, · line 1158
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,return result; } + +
Unrelated change.
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl,@@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); +static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) +{ + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) +{ +if (val !=0 && val !=1 ) +return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1635
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +10
-0+ + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +
That can be done much simpler. Take a look at the debugfs_create_bool() function.
Quoted 23 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +8
-0int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { +DRM_ERROR ("unable to create amdgpu_smu_debug debugsfs file\n" ); +return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 64
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +7
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal. +* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) +*/ +int amdgpu_smu_debug;
Probably better to put that into amdgpu_device or similar structure.
Regards,
Christian.
Quoted 73 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +30
-2+static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); +dev_err (smu->adev->dev, +"SMU: resend command: index:%d param:0x%08X message:%s" , + index, param,smu_get_message_name (smu, msg)); + goto retry; + } + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Quoted 39 lines · Christian KKKnig
Am 30.11.21 um 06:17 schrieb Lang Yu:
Quoted 38 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_debugv2:
- 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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf, · line 1157
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0* @@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,return result; } + +Unrelated change.
Will remove it.
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +15
-0static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl,@@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); +static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) +{ + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) +{ +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} +
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, · line 1635
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5
-0+DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +That can be done much simpler. Take a look at the
debugfs_create_bool()function.
Thanks for your advice. Will modify that.
Quoted 25 lines
Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +8
-0int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { +DRM_ERROR ("unable to create amdgpu_smu_debug debugsfs file\n" ); +return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type +
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 64
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6
-0+/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal. +* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) +*/ +int amdgpu_smu_debug;Probably better to put that into
amdgpu_deviceor similar structure.
Ok. Thanks for your advice.
Regards,
Lang
Quoted 72 lines
Regards,
Christian.Quoted 68 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +30
-2+static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); +dev_err (smu->adev->dev, +"SMU: resend command: index:%d param:0x%08X message:%s" , + index, param,smu_get_message_name (smu, msg)); + goto retry; + } + goto Out; + }if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Quoted 160 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_debugv2:
- 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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +32
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,return result; } + +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl,@@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,DEFINE_DEBUGFS_ATTRIBUTE (fops_sclk_set,NULL , amdgpu_debugfs_sclk_set,"%llu\n" ); +static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) +{ + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) +{ +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { +DRM_ERROR ("unable to create amdgpu_smu_debug debugsfs file\n" ); +return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +25
-2@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal. +* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) +*/ +int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:__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 388
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); +dev_err (smu->adev->dev, +"SMU: resend command: index:%d param:0x%08X message:%s" , + index, param,smu_get_message_name (smu, msg)); + goto retry; + } + goto Out; + }
Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
+#define MAX_DBG_WAIT_CNT 3
+
/**
* __smu_cmn_poll_stat -- poll for a status from the SMU
* smu: a pointer to SMU context
@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu,
static u32 __smu_cmn_poll_stat(struct smu_context *smu)
{
struct amdgpu_device *adev = smu->adev;
- int timeout = adev->usec_timeout * 20;
+ int timeout;
u32 reg;+ int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0;
- for ( ; timeout > 0; timeout--) {
- reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
- if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0)
- break;
+ do {
+ timeout = adev->usec_timeout * 20;
+ for (; timeout > 0; timeout--) {
+ reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
+ if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0)
+ break;
- udelay(1);
- }
+ udelay(1);
+ }
+ } while (extended_wait-- >= 0);
+ if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE)
+ dev_err(adev->dev,
+ "SMU: Unexpected extended wait for response");
return reg;
}
Thanks,
Lijo
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Just realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >= 0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option support
Quoted 157 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_debugv2:
- 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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,return result; } + +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26@@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL,
amdgpu_debugfs_sclk_set, "%llu\n");drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +26
-0+static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) { + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) { +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { +DRM_ERROR ("unable to create amdgpu_smu_debug debugsfs file\n" ); +return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +23
-2@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal. +* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:__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 388
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); +dev_err (smu->adev->dev, +"SMU: resend command: index:%d param:0x%08X message:%s" , + index, param,smu_get_message_name (smu, msg)); + goto retry; + } + goto Out; + }
Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
+#define MAX_DBG_WAIT_CNT 3
+
/**
* __smu_cmn_poll_stat -- poll for a status from the SMU
* smu: a pointer to SMU context
@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu,
static u32 __smu_cmn_poll_stat(struct smu_context *smu)
{
struct amdgpu_device *adev = smu->adev;
- int timeout = adev->usec_timeout * 20;
+ int timeout;
u32 reg;+ int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0;
- for ( ; timeout > 0; timeout--) {
- reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
- if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0)
- break;
+ do {
+ timeout = adev->usec_timeout * 20;
+ for (; timeout > 0; timeout--) {
+ reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
+ if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0)
+ break;
- udelay(1);
- }
+ udelay(1);
+ }
+ } while (extended_wait-- >= 0);
+ if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE)
+ dev_err(adev->dev,
+ "SMU: Unexpected extended wait for response");
return reg;
}
Thanks,
Lijo
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold and could hide some potential issues which should be exposed and solved.
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?
I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
Regards,
Lang
Quoted 267 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 17 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_debugQuoted 8 lines
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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gfxoff_read(struct
Quoted 17 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(structfile *f, char
__user*buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0return result; } + +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26@@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL,
amdgpu_debugfs_sclk_set, "%llu\n");drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +18
-0+static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) { + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) { +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
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 +4
-0return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debug debugsfsfile\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 60
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ 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
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-1__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param, smu_get_message_name(smu,msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +16
-7+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu, static u32 __smu_cmn_poll_stat(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev; - int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break; - udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE) + dev_err(adev->dev, + "SMU: Unexpected extended wait for response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Quoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold and
could hide some potential issues which should be exposed and solved.
Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is sent.
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
Thanks,
Lijo
Quoted 271 lines
Regards,
LangQuoted 267 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 17 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_debugQuoted 8 lines
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 | 32 +++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39 +++++++++++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c static ssize_t amdgpu_debugfs_gfxoff_read(struct
Quoted 17 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_t amdgpu_debugfs_gfxoff_read(structfile *f, char
__user*buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0return result; } + +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26@@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL,
amdgpu_debugfs_sclk_set, "%llu\n");drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +18
-0+static int amdgpu_debugfs_smu_debug_get (void *data,u64 *val) { + *val = amdgpu_smu_debug; +return 0 ; +} + +static int amdgpu_debugfs_smu_debug_set (void *data,u64 val) { +if (val !=0 && val !=1 ) +return -EINVAL ; + + amdgpu_smu_debug = val; +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, +"%llu\n" ); +int amdgpu_debugfs_init (struct amdgpu_device *adev) {struct dentry *root =adev_to_drm (adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
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 +4
-0return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debug debugsfsfile\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 60
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ 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
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-1__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param, smu_get_message_name(smu,msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +16
-7+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu, static u32 __smu_cmn_poll_stat(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev; - int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break; - udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE) + dev_err(adev->dev, + "SMU: Unexpected extended wait for response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
[AMD Official Use Only]
Quoted 27 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 2:56 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 SMU debug option supportQuoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold and
could hide some potential issues which should be exposed and solved.Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
Quoted 8 lines
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is sent.
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
If these issues still exists, could we just blacklist the tests that triggered them before solve them? Or we just increase the threshold to cover all the cases?
Regards,
Lang
Quoted 280 lines
Thanks,
LijoQuoted 60 lines
Regards,
LangQuoted 56 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 24 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_debugv2:
- 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 | 32+++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39+++++++++++++++++++-
Quoted 213 lines
Quoted 213 lines
-
Quoted 17 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_tQuoted 1 line
amdgpu_debugfs_gfxoff_read(struct
file *f, char
__user*buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 34 lines
return result; }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +21
-0+ +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static int amdgpu_debugfs_smu_debug_get(void *data, u64 *val) { + *val = amdgpu_smu_debug; + return 0; +} + +static int amdgpu_debugfs_smu_debug_set(void *data, u64 val) { + if (val != 0 && val != 1) + return -EINVAL; + + amdgpu_smu_debug = val; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, + "%llu\n"); + int amdgpu_debugfs_init(struct amdgpu_device *adev) { struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
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 +4
-0return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debug debugsfsfile\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 61
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU +errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ 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
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-1__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param, smu_get_message_name(smu,msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +17
-7+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu, static u32 __smu_cmn_poll_stat(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev; - int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break; - udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE) + dev_err(adev->dev, + "SMU: Unexpected extended wait for + response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Quoted 37 lines · Lang
[AMD Official Use Only]
Quoted 33 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 2:56 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 SMU debug option supportQuoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold and
could hide some potential issues which should be exposed and solved.Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is sent.
Quoted 6 lines
Quoted 2 lines
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
If these issues still exists, could we just blacklist the tests that triggered them before solve them? Or we just increase the threshold to cover all the cases?
Actually, the timeout is message specific - like i2c transfer from EEPROM could take longer time.
I am not sure if we should have more than 2s as timeout. Whenever this kind of issue happens, FW team check registers (then it will have a proper value) and say they don't see anything abnormal :) Usually, those are just signs of crack and it eventually breaks.
Option is just fail immediately (then again not sure useful it will be if the issue is this sort of thing) or wait to see how far it goes with an added timeout before it fails eventually.
Thanks,
Lijo
Quoted 283 lines
Regards,
LangQuoted 280 lines
Thanks,
LijoQuoted 60 lines
Regards,
LangQuoted 56 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 24 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_debugv2:
- 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 | 32+++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39+++++++++++++++++++-
Quoted 213 lines
Quoted 213 lines
-
Quoted 17 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0@@ -39,6 +39,8 @@#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes * @@ -1152,6 +1154,8 @@ static ssize_tQuoted 1 line
amdgpu_debugfs_gfxoff_read(struct
file *f, char
__user*buf,drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device
Quoted 34 lines
return result; }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +21
-0+ +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static int amdgpu_debugfs_smu_debug_get(void *data, u64 *val) { + *val = amdgpu_smu_debug; + return 0; +} + +static int amdgpu_debugfs_smu_debug_set(void *data, u64 val) { + if (val != 0 && val != 1) + return -EINVAL; + + amdgpu_smu_debug = val; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, + "%llu\n"); + int amdgpu_debugfs_init(struct amdgpu_device *adev) { struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(struct amdgpu_device*adev)
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 +4
-0return PTR_ERR (ent); } + ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debug debugsfsfile\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev);amdgpu_debugfs_pm_init (adev);drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 61
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU +errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ 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
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0__smu_cmn_reg_print_error (smu, reg, index, param, msg); goto Out; } +retry:drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-1__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); +if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param, smu_get_message_name(smu,msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +17
-7+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context@@ -115,17 +117,24 @@ static void smu_cmn_read_arg(struct smu_context *smu, static u32 __smu_cmn_poll_stat(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev; - int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break; - udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg != SMU_RESP_NONE) + dev_err(adev->dev, + "SMU: Unexpected extended wait for + response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
[AMD Official Use Only]
Quoted 59 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 3:28 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 SMU debug option supportQuoted 37 lines · Lang
[AMD Official Use Only]
Quoted 33 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 2:56 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 SMU debug option supportQuoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold
and could hide some potential issues which should be exposed and solved.Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is sent.
Quoted 5 lines
Quoted 2 lines
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
If these issues still exists, could we just blacklist the tests that triggered them before solve them? Or we just increase the threshold to cover
all the cases?
Quoted 1 line
Actually, the timeout is message specific - like i2c transfer from EEPROM could take longer time.
Quoted 8 lines
I am not sure if we should have more than 2s as timeout. Whenever this kind of issue happens, FW team check registers (then it will have a proper value) and say they don't see anything abnormal :) Usually, those are just signs of crack and it eventually breaks.
Option is just fail immediately (then again not sure useful it will be if the issue is this sort of thing) or wait to see how far it goes with an added timeout before it fails eventually.
Does smu_cmn_wait_for_response()/smu_cmn_send_msg_without_waiting() are designed for long timeout cases? Is it fine that we don't fail here in the event of timeout?
Thanks,
Lang
Quoted 294 lines
Thanks,
LijoQuoted 80 lines
Regards,
LangQuoted 77 lines
Thanks,
LijoQuoted 60 lines
Regards,
LangQuoted 56 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 24 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_debugv2:
- 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 | 32+++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39+++++++++++++++++++-
Quoted 10 lines
Quoted 10 lines
-
Quoted 9 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -39,6 +39,8 @@Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c line 45
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes
Quoted 112 lines
Quoted 112 lines
Quoted 112 lines
Quoted 112 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0* @@ -1152,6 +1154,8 @@ static ssize_tamdgpu_debugfs_gfxoff_read(struct
file *f, char
__user*buf,Quoted 35 lines
return result; }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +21
-0+ +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static int amdgpu_debugfs_smu_debug_get(void *data, u64 *val) { + *val = amdgpu_smu_debug; + return 0; +} + +static int amdgpu_debugfs_smu_debug_set(void *data, u64 val) { + if (val != 0 && val != 1) + return -EINVAL; + + amdgpu_smu_debug = val; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, + "%llu\n"); + 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 +0
-0@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 7 lines
return PTR_ERR(ent); }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+ ent =debugfs_create_file ("amdgpu_smu_debug" ,0600 , root, adev, + &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debug debugsfsfile\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev); amdgpu_debugfs_pm_init(adev); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.cb/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index048ca1673863..b3969d7933d3100644drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 61
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU +errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int + amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ 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 · line 379
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +retry:__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 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 383
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param, smu_get_message_name(smu,msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +2
-0+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context @@ -115,17 +117,24 @@ staticvoid smu_cmn_read_arg(struct
smu_context*smu,
static u32__smu_cmn_poll_stat(struct smu_context *smu){ struct amdgpu_device *adev = smu->adev;(quoted diff) +8
-5- int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +4
-2- udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg !=
SMU_RESP_NONE)Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
(quoted diff) +3
-0+ dev_err(adev->dev, + "SMU: Unexpected extended wait for + response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
[AMD Official Use Only]
Quoted 78 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu, Lang
Sent: Wednesday, December 1, 2021 3:58 PM
To: Lazar, Lijo <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option support[AMD Official Use Only]
Quoted 10 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 3:28 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 SMU debug option supportQuoted 37 lines
Quoted 36 lines · Lang
[AMD Official Use Only]
Quoted 32 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 2:56 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 SMU debug option supportQuoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold
and could hide some potential issues which should be exposed and solved.Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is
sent.
Quoted 18 lines
Quoted 7 lines
Quoted 3 lines
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
If these issues still exists, could we just blacklist the tests that triggered them before solve them? Or we just increase the threshold to cover
all the cases?
Quoted 1 line
Actually, the timeout is message specific - like i2c transfer from EEPROM could take longer time.
I am not sure if we should have more than 2s as timeout. Whenever this kind of issue happens, FW team check registers (then it will have a proper value) and say they don't see anything abnormal :) Usually, those are just signs of crack and it eventually breaks.
Quoted 7 lines
Quoted 3 lines
Option is just fail immediately (then again not sure useful it will be if the issue is this sort of thing) or wait to see how far it goes with an added timeout before it fails eventually.
Are smu_cmn_wait_for_response()/smu_cmn_send_msg_without_waiting() designed for long timeout cases? Is it fine that we don't fail here in the event of timeout?
Or we can add a timeout parameter into smu_cmn_send_smc_msg_with_param() to specify the timeout you want for specific message.
I think this may be another story. Thanks!
Thanks,
Lang
Quoted 299 lines
Quoted 50 lines
Thanks,
LijoQuoted 45 lines
Regards,
LangQuoted 42 lines
Thanks,
LijoQuoted 38 lines
Regards,
LangQuoted 34 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 2 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.
Quoted 83 lines
Quoted 35 lines
Quoted 35 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 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_debugQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
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 | 32+++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39+++++++++++++++++++-
Quoted 10 lines
Quoted 10 lines
-
Quoted 9 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -39,6 +39,8 @@Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c line 45
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0* @@ -1152,6 +1154,8 @@ static ssize_tamdgpu_debugfs_gfxoff_read(struct
file *f, char
__user*buf,Quoted 35 lines
return result; }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +21
-0+ +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static int amdgpu_debugfs_smu_debug_get(void *data, u64 *val) { + *val = amdgpu_smu_debug; + return 0; +} + +static int amdgpu_debugfs_smu_debug_set(void *data, u64 val) { + if (val != 0 && val != 1) + return -EINVAL; + + amdgpu_smu_debug = val; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, + "%llu\n"); + 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 +0
-0@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 4 lines
return PTR_ERR(ent); }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-0+ ent = debugfs_create_file("amdgpu_smu_debug", 0600, root,adev,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+ &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debugdebugsfs
Quoted 86 lines
Quoted 64 lines
Quoted 64 lines
Quoted 64 lines
Quoted 64 lines
file\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev); amdgpu_debugfs_pm_init(adev); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.cb/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index048ca1673863..b3969d7933d3100644drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 61
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU +errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int + amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ 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 · line 379
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +retry:__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 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 383
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param,smu_get_message_name(smu,
Quoted 63 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +2
-0+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context @@ -115,17 +117,24 @@ staticvoid smu_cmn_read_arg(struct
smu_context*smu,
static u32__smu_cmn_poll_stat(struct smu_context *smu){ struct amdgpu_device *adev = smu->adev;(quoted diff) +8
-5- int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +4
-2- udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg !=
SMU_RESP_NONE)Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
(quoted diff) +3
-0+ dev_err(adev->dev, + "SMU: Unexpected extended wait for + response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }
Quoted 86 lines · Lang
[AMD Official Use Only]
Quoted 82 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yu, Lang
Sent: Wednesday, December 1, 2021 3:58 PM
To: Lazar, Lijo <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option support[AMD Official Use Only]
Quoted 10 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 3:28 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 SMU debug option supportQuoted 37 lines
Quoted 36 lines · Lang
[AMD Official Use Only]
Quoted 32 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 2:56 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 SMU debug option supportQuoted 9 lines · Lang
[AMD Official Use Only]
Hi Lijo,
Thanks for your comments.
From my understanding, that just increases the timeout threshold
and could hide some potential issues which should be exposed and solved.Quoted 6 lines
If current timeout threshold is not enough for some corner cases,
(1) Do we consider to increase the threshold to cover these cases?
(2) Or do we just expose them and request SMU FW to optimize them?I think it doesn't make much sense to increase the threshold in debug mode. How do you think? Thanks!
In normal cases, 2secs would be more than enough. If we hang immediately, then check the FW registers later, the response would have come. I thought we just need to note those cases and not to fail everytime. Just to mark as a red flag in the log to tell us that FW is unexpectedly busy processing something else when the message is
sent.
Quoted 21 lines
Quoted 7 lines
Quoted 3 lines
There are some issues related to S0ix where we see the FW comes back with a response with an increased timeout under certain conditions.
If these issues still exists, could we just blacklist the tests that triggered them before solve them? Or we just increase the threshold to cover
all the cases?
Quoted 1 line
Actually, the timeout is message specific - like i2c transfer from EEPROM could take longer time.
I am not sure if we should have more than 2s as timeout. Whenever this kind of issue happens, FW team check registers (then it will have a proper value) and say they don't see anything abnormal :) Usually, those are just signs of crack and it eventually breaks.
Option is just fail immediately (then again not sure useful it will be if the issue is this sort of thing) or wait to see how far it goes with an added timeout before it fails eventually.
Quoted 8 lines
Quoted 3 lines
Are smu_cmn_wait_for_response()/smu_cmn_send_msg_without_waiting() designed for long timeout cases? Is it fine that we don't fail here in the event of timeout?
Or we can add a timeout parameter into
smu_cmn_send_smc_msg_with_param()to specify the timeout you want for specific message.
I think this may be another story. Thanks!
Yes, that will be a different patch. For now, skip the extended timeout. Every timeout will trigger a debug alarm and let it be that way for debug mode. I think you can skip the retry also (originally I meant this by that comment - retry again for response reg check).
Thanks,
Lijo
Quoted 301 lines
Thanks,
LangQuoted 299 lines
Quoted 50 lines
Thanks,
LijoQuoted 45 lines
Regards,
LangQuoted 42 lines
Thanks,
LijoQuoted 38 lines
Regards,
LangQuoted 34 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, December 1, 2021 1:44 PM
To: Lazar, Lijo <[email protected]>; Yu, Lang <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: add SMU debug option supportJust realized that the patch I pasted won't work. Outer loop exit needs to be like this.
(reg & MP1_C2PMSG_90__CONTENT_MASK) != 0 && extended_wait-- >=0
Anyway, that patch is only there to communicate what I really meant in the earlier comment.
Thanks,
Lijo-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Wednesday, December 1, 2021 10:44 AM
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 SMU debug option supportQuoted 2 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.
Quoted 83 lines
Quoted 35 lines
Quoted 35 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 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_debugQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
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 | 32+++++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 39+++++++++++++++++++-
Quoted 10 lines
Quoted 10 lines
-
Quoted 9 lines
2 files changed, 69 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0@@ -39,6 +39,8 @@Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c line 45
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-0#if defined(CONFIG_DEBUG_FS ) +extern int amdgpu_smu_debug; +/** * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0
-0* @@ -1152,6 +1154,8 @@ static ssize_tamdgpu_debugfs_gfxoff_read(struct
file *f, char
__user*buf,Quoted 35 lines
return result; }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +21
-0+ +static const struct file_operations amdgpu_debugfs_regs2_fops = { .owner =THIS_MODULE , .unlocked_ioctl = amdgpu_debugfs_regs2_ioctl, @@ -1609,6 +1613,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL, amdgpu_debugfs_sclk_set, "%llu\n"); +static int amdgpu_debugfs_smu_debug_get(void *data, u64 *val) { + *val = amdgpu_smu_debug; + return 0; +} + +static int amdgpu_debugfs_smu_debug_set(void *data, u64 val) { + if (val != 0 && val != 1) + return -EINVAL; + + amdgpu_smu_debug = val; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_smu_debug, + amdgpu_debugfs_smu_debug_get, + amdgpu_debugfs_smu_debug_set, + "%llu\n"); + 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 +0
-0@@ -1632,6 +1656,14 @@ int amdgpu_debugfs_init(structQuoted 1 line
amdgpu_device*adev)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 4 lines
return PTR_ERR(ent); }drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1
-0+ ent = debugfs_create_file("amdgpu_smu_debug", 0600, root,adev,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3
-0+ &fops_smu_debug); +if (IS_ERR (ent)) { + DRM_ERROR("unable to create amdgpu_smu_debugdebugsfs
Quoted 86 lines
Quoted 64 lines
Quoted 64 lines
Quoted 64 lines
Quoted 64 lines
file\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +4
-0+return PTR_ERR (ent); + } + +/* Register debugfs entries for amdgpu_ttm */ amdgpu_ttm_debugfs_init (adev); amdgpu_debugfs_pm_init(adev); diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.cb/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
index048ca1673863..b3969d7933d3100644drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c line 61
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0@@ -55,6 +55,14 @@#undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) #type + +/* +* Used to enable SMU debug option. When enabled, it makes SMU +errors fatal.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+* This will aid in debugging SMU firmware issues. +* (0 = disabled (default), 1 = enabled) */ int + amdgpu_smu_debug; +static const char *const __smu_message_names[] = {SMU_MESSAGE_TYPES };@@ -272,6 +280,11 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5
-0__smu_cmn_send_msg (smu, msg_index, param); res =0 ; Out: +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } +return res; }@@ -288,9 +301,17 @@ int smu_cmn_send_msg_without_waiting(struct
smu_context*smu,drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9
-1int smu_cmn_wait_for_response (struct smu_context *smu) {u32 reg; +int res; reg =__smu_cmn_poll_stat (smu); -return __smu_cmn_reg2errno (smu, reg); + res =__smu_cmn_reg2errno (smu, reg); + +if (unlikely (amdgpu_smu_debug ==1 ) && res) { +mutex_unlock (&smu->message_lock); +BUG (); + } + +return res; }/** @@ -328,6 +349,7 @@ int smu_cmn_send_smc_msg_with_param(struct
smu_context*smu,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0uint32_t param, uint32_t *read_arg) { + int retry_count = 0;int res, index;u32 reg;@@ -349,15 +371,28 @@ 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 · line 379
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2
-1goto Out; } +retry:__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 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 383
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+if ((res == -ETIME ) && (retry_count++ <1 )) { +usleep_range (500 ,1000 ); + dev_err(smu->adev->dev, + "SMU: resend command: index:%dparam:0x%08X message:%s",
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 384
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1
-0+ index, param,smu_get_message_name(smu,
Quoted 63 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
msg));
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 388
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4
-0+ goto retry; + } + goto Out; + }Sorry, what I meant is to have an extended wait time in debug mode. Something like below, not a 'full retry' as in sending the message again.
(quoted diff) +2
-0+#define MAX_DBG_WAIT_CNT 3 + /** * __smu_cmn_poll_stat -- poll for a status from the SMU * smu: a pointer to SMU context @@ -115,17 +117,24 @@ staticvoid smu_cmn_read_arg(struct
smu_context*smu,static u32 __smu_cmn_poll_stat(struct smu_context *smu) { struct amdgpu_device *adev = smu->adev;(quoted diff) +8
-5- int timeout = adev->usec_timeout * 20; + int timeout; u32 reg; + int extended_wait = smu_debug_mode ? MAX_DBG_WAIT_CNT : 0; - for ( ; timeout > 0; timeout--) { - reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; + do { + timeout = adev->usec_timeout * 20; + for (; timeout > 0; timeout--) { + reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90); + if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) + break;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +4
-2- udelay(1); - } + udelay(1); + } + } while (extended_wait-- >= 0); + if (extended_wait != MAX_DBG_WAIT_CNT && reg !=
SMU_RESP_NONE)Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
(quoted diff) +3
-0+ dev_err(adev->dev, + "SMU: Unexpected extended wait for + response"); return reg; }Thanks,
LijoQuoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3
-0if (read_arg)smu_cmn_read_arg (smu, read_arg); Out:mutex_unlock (&smu->message_lock); + +BUG_ON (unlikely (amdgpu_smu_debug ==1 ) && res); +return res; }