Send message to PMFW when SMT changes
Subsystems (3)
v5 cover Send message to PMFW when SMT changes
When the SMT changes on the fly, send the message to the PMFW to notify the SMT status changed.
Changes in v5
1./ Add a new vangogh_fini_smc_tables() to accommodate the timer fini and smu_v11_0_fini_smc_tables().
2./ Move the version check of SMU version before initializing the timer.
Changes in v4
1./ Since we didn't find a good solution to handle the case that manually offlining all the SMT siblings using /sys/devices/system/cpu/cpu*/online to disable or enable SMT. Come up with a new solution, add a timer to poll the SMT state periodically, if finding that the SMT state is changed, it invokes the interface to notify the PMFW.
2./ Move the generic code to smu_cmn.c.
3./ Add PMFW version check for this feature.
Changes in v3
1./ Because it is only required for Vangogh, move registering notifier to vangogh_ppt.c, then remove the patch 2, and the number of patches decreased to 2.
Changes in v2:
1/. Embed the smt notifer callback into "struct smu_context" structure. 2/. Correct the PPSMC_Message_Count value.
3/. Improve several code styles and others.
Wenyou Yang (2):
drm/amd/pm: Add support to check SMT state periodically drm/amd/pm/vangogh: Send SMT enable message to PMFW
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 8 ++++ .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 32 +++++++++++++- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 44 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 5 +++ 6 files changed, 92 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
PATCH v5 1/2 drm/amd/pm: Add support to check SMT state periodically
Add a timer to poll the SMT state periodically, if the SMT state is changed, invoke the interface to notify the PMFW.
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 8 ++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 44 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 5 +++ 3 files changed, 57 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +8 -0
@@ -566,6 +566,9 @@ struct smu_contextstruct firmware pptable_firmware; +bool last_smt_active; +struct timer_list smt_timer; +u32 param_reg;u32 msg_reg;u32 resp_reg;
@@ -1354,6 +1357,11 @@ struct pptable_funcs {* @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + +/** +* @set_cpu_smt_enable: Set the CPU SMT status. +*/ +int (*set_cpu_smt_enable)(struct smu_context *smu,bool smt_enable); }; typedef enum {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +44 -0
53 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +5 -0
@@ -127,5 +127,10 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)bool smu_cmn_is_audio_func_enabled (struct amdgpu_device *adev); +void smu_smt_timer_init (struct smu_context *smu); +#endif + +void smu_smt_timer_fini (struct smu_context *smu); +#endif
Signature · 1 line
2.39.2
Re: [PATCH v5 1/2] drm/amd/pm: Add support to check SMT state periodically
Quoted 65 lines · Wenyou Yang
Add a timer to poll the SMT state periodically, if the SMT state is changed, invoke the interface to notify the PMFW.
Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 8 ++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 44 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 5 +++ 3 files changed, 57 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +8
-0@@ -566,6 +566,9 @@ struct smu_contextstruct firmware pptable_firmware; +bool last_smt_active; +struct timer_list smt_timer; +u32 param_reg;u32 msg_reg;u32 resp_reg;@@ -1354,6 +1357,11 @@ struct pptable_funcs {* @init_pptable_microcode: Prepare the pptable microcode to upload via PSP */ int (*init_pptable_microcode)(struct smu_context *smu); + +/** +* @set_cpu_smt_enable: Set the CPU SMT status. +*/ +int (*set_cpu_smt_enable)(struct smu_context *smu,bool smt_enable); }; typedef enum {drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +14
-0@@ -26,6 +26,7 @@#include "amdgpu_smu.h" #include "smu_cmn.h" #include "soc15_common.h" +#include <linux/sched/smt.h> /* * DO NOT use these for err/warn/info/debug messages. @@ -1058,3 +1059,46 @@ bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev)return snd_driver_loaded; } + +#define TIME_INTERVAL 200 + +static int smu_set_cpu_smt_enable (struct smu_context *smu,bool enable) +{ +int ret = -EINVAL ; + +if (smu->ppt_funcs && smu->ppt_funcs->set_cpu_smt_enable) + ret = smu->ppt_funcs->set_cpu_smt_enable (smu, enable); + +return ret; +} +
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev) · line 1084
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10
-0+static void smu_smt_timer_callback (struct timer_list *timer) +{ +struct smu_context *smu =container_of (timer, + struct smu_context, smt_timer); +bool smt_active; + + smt_active =sched_smt_active (); +if (smt_active != smu->last_smt_active) { + smu->last_smt_active = smt_active; +smu_set_cpu_smt_enable (smu, smt_active);
You're ignoring the return value for smu_set_cpu_smt_enable. If the message failed to send that means smu->last_smt_active will have the wrong value and the message will never attempt to send again while in this SMT state even though the timer triggered again.
I think you should do it like this:
if (!smu_set_cpu_smt_enable(smu, smt_active))
smu->last_smt_active = smt_active;
Quoted 35 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +20
-0+ } + +mod_timer (timer, jiffies +msecs_to_jiffies (TIME_INTERVAL )); +} + +void smu_smt_timer_init (struct smu_context *smu) +{ +struct timer_list *timer = &smu->smt_timer; + + smu->last_smt_active =sched_smt_active (); + +timer_setup (timer, smu_smt_timer_callback,0 ); + +mod_timer (timer, jiffies +msecs_to_jiffies (TIME_INTERVAL )); +} + +void smu_smt_timer_fini (struct smu_context *smu) +{ +del_timer (&smu->smt_timer); +}drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +5
-0@@ -127,5 +127,10 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)bool smu_cmn_is_audio_func_enabled (struct amdgpu_device *adev); +void smu_smt_timer_init (struct smu_context *smu); +#endif + +void smu_smt_timer_fini (struct smu_context *smu); +#endif
RE: [PATCH v5 1/2] drm/amd/pm: Add support to check SMT state periodically
[AMD Official Use Only - General]
Hi Mario,
Thank you for your review.
Quoted 100 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Thursday, April 6, 2023 10:09 PM
To: Yang, WenYou <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>
Cc: Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]
Subject: Re: [PATCH v5 1/2] drm/amd/pm: Add support to check SMT state periodicallyQuoted 7 lines · Wenyou Yang
Add a timer to poll the SMT state periodically, if the SMT state is changed, invoke the interface to notify the PMFW.
Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 8 ++++ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 44+++++++++++++++++++
Quoted 19 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 5 +++ 3 files changed, 57 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +3
-0@@ -566,6 +566,9 @@ struct smu_contextstruct firmware pptable_firmware; +bool last_smt_active; +struct timer_list smt_timer; +u32 param_reg;u32 msg_reg;u32 resp_reg;drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h struct pptable_funcs { · line 1357
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0@@ -1354,6 +1357,11 @@ struct pptable_funcs {* @init_pptable_microcode: Prepare the pptable microcode to upload via PSP
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h struct pptable_funcs {
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +5
-0*/ int (*init_pptable_microcode)(struct smu_context *smu); + +/** +* @set_cpu_smt_enable: Set the CPU SMT status. +*/ + int (*set_cpu_smt_enable)(struct smu_context *smu, bool
smt_enable);Quoted 33 lines
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0}; typedef enum {drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +13
-0@@ -26,6 +26,7 @@#include "amdgpu_smu.h" #include "smu_cmn.h" #include "soc15_common.h" +#include <linux/sched/smt.h> /* * DO NOT use these for err/warn/info/debug messages. @@ -1058,3 +1059,46 @@ bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev)return snd_driver_loaded; } + +#define TIME_INTERVAL 200 + +static int smu_set_cpu_smt_enable (struct smu_context *smu,bool +enable) { +int ret = -EINVAL ; + +if (smu->ppt_funcs && smu->ppt_funcs->set_cpu_smt_enable) + ret = smu->ppt_funcs->set_cpu_smt_enable (smu, enable); + +return ret; +}drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c bool smu_cmn_is_audio_func_enabled(struct · line 1084
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +10
-0+ +static void smu_smt_timer_callback (struct timer_list *timer) { +struct smu_context *smu =container_of (timer, + struct smu_context, smt_timer); +bool smt_active; + + smt_active =sched_smt_active (); +if (smt_active != smu->last_smt_active) { + smu->last_smt_active = smt_active; +smu_set_cpu_smt_enable (smu, smt_active);You're ignoring the return value for
smu_set_cpu_smt_enable. If the message failed to send that meanssmu->last_smt_activewill have the wrong value and the message will never attempt to send again while in this SMT state even though the timer triggered again.
Quoted 5 lines
I think you should do it like this:
if (!smu_set_cpu_smt_enable(smu,
smt_active))smu->last_smt_active = smt_active;
Yes. Will change in next version.
Quoted 33 lines
Quoted 33 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +16
-0+ } + +mod_timer (timer, jiffies +msecs_to_jiffies (TIME_INTERVAL )); } + +void smu_smt_timer_init (struct smu_context *smu) { +struct timer_list *timer = &smu->smt_timer; + + smu->last_smt_active =sched_smt_active (); + +timer_setup (timer, smu_smt_timer_callback,0 ); + +mod_timer (timer, jiffies +msecs_to_jiffies (TIME_INTERVAL )); } + +void smu_smt_timer_fini (struct smu_context *smu) { +del_timer (&smu->smt_timer); +}drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +5
-0@@ -127,5 +127,10 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)bool smu_cmn_is_audio_func_enabled (struct amdgpu_device *adev); +void smu_smt_timer_init (struct smu_context *smu); +#endif + +void smu_smt_timer_fini (struct smu_context *smu); +#endif
PATCH v5 2/2 drm/amd/pm/vangogh: Send SMT enable message to PMFW
In reply to Wenyou YangWhen the SMT state is changed on the fly, sent the SMT enable message to the PMFW to notify it that the SMT state changed.
Add the support to send PPSMC_MSG_SetCClkSMTEnable(0x58) message to the PMFW for Vangogh.
--- .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 32 ++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h +2 -1
@@ -111,7 +111,8 @@#define PPSMC_MSG_GetGfxOffStatus 0x50#define PPSMC_MSG_GetGfxOffEntryCount 0x51#define PPSMC_MSG_LogGfxOffResidency 0x52 -#define PPSMC_Message_Count 0x53 +#define PPSMC_MSG_SetCClkSMTEnable 0x58 +#define PPSMC_Message_Count 0x59//Argument for PPSMC_MSG_GfxDeviceDriverReset enum {
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -1
@@ -245,7 +245,8 @@__SMU_DUMMY_MAP (AllowGpo), \__SMU_DUMMY_MAP (Mode2Reset), \__SMU_DUMMY_MAP (RequestI2cTransaction), \ -__SMU_DUMMY_MAP (GetMetricsTable), +__SMU_DUMMY_MAP (GetMetricsTable), \ +__SMU_DUMMY_MAP (SetCClkSMTEnable), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +31 -1
@@ -141,6 +141,7 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {MSG_MAP (GetGfxOffStatus, PPSMC_MSG_GetGfxOffStatus,0 ),MSG_MAP (GetGfxOffEntryCount, PPSMC_MSG_GetGfxOffEntryCount,0 ),MSG_MAP (LogGfxOffResidency, PPSMC_MSG_LogGfxOffResidency,0 ), + MSG_MAP(SetCClkSMTEnable, PPSMC_MSG_SetCClkSMTEnable, 0), }; static struct cmn2asic_mapping vangogh_feature_mask_map[SMU_FEATURE_COUNT] = {
@@ -460,6 +461,7 @@ static int vangogh_allocate_dpm_context(struct smu_context *smu)static int vangogh_init_smc_tables (struct smu_context *smu) { +uint32_t smu_version;int ret =0 ; ret =vangogh_tables_init (smu);
@@ -477,9 +479,24 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num =4 ;#endif + ret =smu_cmn_get_smc_version (smu,NULL , &smu_version); +if (ret) +return ret; + +if (smu_version >=0x063F0600 ) +smu_smt_timer_init (smu); +return smu_v11_0_init_smc_tables (smu); } +static int vangogh_fini_smc_tables (struct smu_context *smu) +{ +smu_smt_timer_fini (smu); +smu_v11_0_fini_smc_tables (smu); + +return 0 ; +} +static int vangogh_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {int ret =0 ;
@@ -2428,12 +2445,24 @@ static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entrreturn ret; } +static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool enable) +{ +int ret; + + ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetCClkSMTEnable, + enable ?1 :0 ,NULL ); +if (ret) +dev_err (smu->adev->dev,"Set CPU SMT state failed!\n" ); + +return ret; +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, .check_fw_version = smu_v11_0_check_fw_version, .init_smc_tables = vangogh_init_smc_tables, - .fini_smc_tables = smu_v11_0_fini_smc_tables, + .fini_smc_tables = vangogh_fini_smc_tables, .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .register_irq_handler = smu_v11_0_register_irq_handler,
@@ -2474,6 +2503,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = { .get_power_limit = vangogh_get_power_limit, .set_power_limit = vangogh_set_power_limit, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, + .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, };void vangogh_set_ppt_funcs (struct smu_context *smu)
Signature · 1 line
2.39.2
Re: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFW
Quoted 62 lines · Wenyou Yang
When the SMT state is changed on the fly, sent the SMT enable message to the PMFW to notify it that the SMT state changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to the PMFW for Vangogh.Signed-off-by Wenyou Yang <[email protected]>--- .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 32 ++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h +2
-1@@ -111,7 +111,8 @@#define PPSMC_MSG_GetGfxOffStatus 0x50#define PPSMC_MSG_GetGfxOffEntryCount 0x51#define PPSMC_MSG_LogGfxOffResidency 0x52 -#define PPSMC_Message_Count 0x53 +#define PPSMC_MSG_SetCClkSMTEnable 0x58 +#define PPSMC_Message_Count 0x59//Argument for PPSMC_MSG_GfxDeviceDriverReset enum {drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2
-1@@ -245,7 +245,8 @@__SMU_DUMMY_MAP (AllowGpo), \__SMU_DUMMY_MAP (Mode2Reset), \__SMU_DUMMY_MAP (RequestI2cTransaction), \ -__SMU_DUMMY_MAP (GetMetricsTable), +__SMU_DUMMY_MAP (GetMetricsTable), \ +__SMU_DUMMY_MAP (SetCClkSMTEnable), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##typedrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2
-0@@ -141,6 +141,7 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {MSG_MAP (GetGfxOffStatus, PPSMC_MSG_GetGfxOffStatus,0 ),MSG_MAP (GetGfxOffEntryCount, PPSMC_MSG_GetGfxOffEntryCount,0 ),MSG_MAP (LogGfxOffResidency, PPSMC_MSG_LogGfxOffResidency,0 ), + MSG_MAP(SetCClkSMTEnable, PPSMC_MSG_SetCClkSMTEnable, 0), }; static struct cmn2asic_mapping vangogh_feature_mask_map[SMU_FEATURE_COUNT] = {@@ -460,6 +461,7 @@ static int vangogh_allocate_dpm_context(struct smu_context *smu)static int vangogh_init_smc_tables (struct smu_context *smu) { +uint32_t smu_version;int ret =0 ; ret =vangogh_tables_init (smu);
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu) · line 486
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0@@ -477,9 +479,24 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num =4 ;#endif + ret =smu_cmn_get_smc_version (smu,NULL , &smu_version); +if (ret) +return ret; + +if (smu_version >=0x063F0600 )
AFAICT the value has already been looked up and you can instead use:
smu->adev->pm.fw_version >= 0x063F0600
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu) · line 494
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0+smu_smt_timer_init (smu); +return smu_v11_0_init_smc_tables (smu); } +static int vangogh_fini_smc_tables (struct smu_context *smu) +{ +smu_smt_timer_fini (smu);
Shouldn't this timer only be deleted if
smu->adev->pm.fw_version >= 0x063F0600
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0+smu_v11_0_fini_smc_tables (smu); + +return 0 ; +} +static int vangogh_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {int ret =0 ;@@ -2428,12 +2445,24 @@ static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entrreturn ret;
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr · line 2455
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +8
-0} +static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool enable) +{ +int ret; + + ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetCClkSMTEnable, + enable ?1 :0 ,NULL ); +if (ret) +dev_err (smu->adev->dev,"Set CPU SMT state failed!\n" );
Given this is goign to be triggered by a timer, this might be best to be a rate limited message to avoid flooding the logs.
Quoted 22 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +6
-1+ +return ret; +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, .check_fw_version = smu_v11_0_check_fw_version, .init_smc_tables = vangogh_init_smc_tables, - .fini_smc_tables = smu_v11_0_fini_smc_tables, + .fini_smc_tables = vangogh_fini_smc_tables, .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .register_irq_handler = smu_v11_0_register_irq_handler,@@ -2474,6 +2503,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = { .get_power_limit = vangogh_get_power_limit, .set_power_limit = vangogh_set_power_limit, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, + .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, };void vangogh_set_ppt_funcs (struct smu_context *smu)
RE: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFW
[AMD Official Use Only - General]
Hi Mario,
Thank you for your review.
Quoted 101 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Thursday, April 6, 2023 10:05 PM
To: Yang, WenYou <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>
Cc: Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]
Subject: Re: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFWQuoted 11 lines · Wenyou Yang
When the SMT state is changed on the fly, sent the SMT enable message to the PMFW to notify it that the SMT state changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to the PMFW for Vangogh.Signed-off-by Wenyou Yang <[email protected]>--- .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 32++++++++++++++++++-
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping
Quoted 39 lines
3 files changed, 35 insertions(+), 3 deletions(-)diff --git
a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hb/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hindex7471e2df2828..a6bfa1912c42100644drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h +2
-1@@ -111,7 +111,8 @@#define PPSMC_MSG_GetGfxOffStatus 0x50#define PPSMC_MSG_GetGfxOffEntryCount 0x51#define PPSMC_MSG_LogGfxOffResidency 0x52 -#define PPSMC_Message_Count 0x53 +#define PPSMC_MSG_SetCClkSMTEnable 0x58 +#define PPSMC_Message_Count 0x59//Argument for PPSMC_MSG_GfxDeviceDriverReset enum {drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2
-1@@ -245,7 +245,8 @@__SMU_DUMMY_MAP (AllowGpo), \__SMU_DUMMY_MAP (Mode2Reset), \__SMU_DUMMY_MAP (RequestI2cTransaction), \ -__SMU_DUMMY_MAP (GetMetricsTable), +__SMU_DUMMY_MAP (GetMetricsTable), \ +__SMU_DUMMY_MAP (SetCClkSMTEnable), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##typedrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0@@ -141,6 +141,7 @@ static struct cmn2asic_msg_mappingvangogh_message_map[SMU_MSG_MAX_COUNT] = {
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 141
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetGfxOffStatus,
PPSMC_MSG_GetGfxOffStatus, 0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 142
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetGfxOffEntryCount,
PPSMC_MSG_GetGfxOffEntryCount, 0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 143
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(LogGfxOffResidency,
PPSMC_MSG_LogGfxOffResidency, 0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 144
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +1
-0+ MSG_MAP(SetCClkSMTEnable,
PPSMC_MSG_SetCClkSMTEnable,0),Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0}; static struct cmn2asic_mappingvangogh_feature_mask_map[SMU_FEATURE_COUNT] = { @@ -460,6 +461,7
@@
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct
Quoted 9 lines
static int
vangogh_allocate_dpm_context(struct smu_context *smu)static int vangogh_init_smc_tables(struct smu_context *smu) {drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +1
-0+uint32_t smu_version;int ret =0 ; ret =vangogh_tables_init (smu);@@ -477,9 +479,24 @@ static int vangogh_init_smc_tables(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu) · line 486
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0smu->cpu_core_num =4 ;#endif + ret =smu_cmn_get_smc_version (smu,NULL , &smu_version); +if (ret) +return ret; + +if (smu_version >=0x063F0600 )AFAICT the value has already been looked up and you can instead use:
Quoted 1 line
smu->adev->pm.fw_version>=0x063F0600
smu->adev->pm.fw_version is assigned in smu_v11_0_init_microcode(),
Vangogh doesn't initialize .init_microcode interface.
So, smu->adev->pm.fw_version value is 0.
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2
-0+smu_smt_timer_init (smu); +return smu_v11_0_init_smc_tables (smu); }
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct · line 493
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2
-0+static int vangogh_fini_smc_tables (struct smu_context *smu) { +smu_smt_timer_fini (smu);Shouldn't this timer only be deleted if
smu->adev->pm.fw_version>=0x063F0600
Yes, will add version check before delete the timer.
Need to call the smu_cmn_get_smc_version() again, not good. Look forward to your opinions.
Quoted 20 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu)
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0+smu_v11_0_fini_smc_tables (smu); + +return 0 ; +} + static int vangogh_dpm_set_vcn_enable(struct smu_context *smu, boolenable)
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0{int ret =0 ;@@ -2428,12 +2445,24 @@ static u32 vangogh_get_gfxoff_entrycount(struct
smu_context*smu,uint64_t*entrdrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0return ret; } +static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool +enable) { +int ret; + + ret = smu_cmn_send_smc_msg_with_param(smu,
SMU_MSG_SetCClkSMTEnable,
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr · line 2455
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ enable ? 1 : 0, NULL); +if (ret) +dev_err (smu->adev->dev,"Set CPU SMT state failed!\n" );Given this is goign to be triggered by a timer, this might be best to be a rate limited message to avoid flooding the logs.
Yes, will add, before call dev_err(...)
if (printk_ratelimit())
Best Regards,
Wenyou
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +7
-1+ +return ret; +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, .check_fw_version = smu_v11_0_check_fw_version, .init_smc_tables = vangogh_init_smc_tables, - .fini_smc_tables = smu_v11_0_fini_smc_tables, + .fini_smc_tables = vangogh_fini_smc_tables, .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .register_irq_handler = smu_v11_0_register_irq_handler, @@ -2474,6 +2503,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = { .get_power_limit = vangogh_get_power_limit, .set_power_limit = vangogh_set_power_limit, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, + .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, };void vangogh_set_ppt_funcs (struct smu_context *smu)
RE: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFW
[AMD Official Use Only - General]
Hi Mario,
Quoted 145 lines
-----Original Message-----
From: Yang, WenYou
Sent: Friday, April 7, 2023 10:47 AM
To: Limonciello, Mario <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>
Cc: Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]
Subject: RE: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFW[AMD Official Use Only - General]
Hi Mario,
Thank you for your review.
Quoted 13 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Thursday, April 6, 2023 10:05 PM
To: Yang, WenYou <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>
Cc: Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]
Subject: Re: [PATCH v5 2/2] drm/amd/pm/vangogh: Send SMT enable message to PMFWQuoted 5 lines
Quoted 4 lines · Wenyou Yang
When the SMT state is changed on the fly, sent the SMT enable message to the PMFW to notify it that the SMT state changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to
Quoted 15 lines
Quoted 7 lines
the PMFW for Vangogh.
Signed-off-by Wenyou Yang <[email protected]>--- .../pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h | 3 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 3 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 32++++++++++++++++++-
Quoted 7 lines
3 files changed, 35 insertions(+), 3 deletions(-)diff --git
a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hb/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hindex7471e2df2828..a6bfa1912c42100644
---
a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hQuoted 1 line
Quoted 1 line
+++
b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.hQuoted 32 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping
Quoted 31 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v11_5_ppsmc.h +2
-1@@ -111,7 +111,8 @@#define PPSMC_MSG_GetGfxOffStatus 0x50#define PPSMC_MSG_GetGfxOffEntryCount 0x51#define PPSMC_MSG_LogGfxOffResidency 0x52 -#define PPSMC_Message_Count 0x53 +#define PPSMC_MSG_SetCClkSMTEnable 0x58 +#define PPSMC_Message_Count 0x59//Argument for PPSMC_MSG_GfxDeviceDriverReset enum {drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2
-1@@ -245,7 +245,8 @@__SMU_DUMMY_MAP (AllowGpo), \__SMU_DUMMY_MAP (Mode2Reset), \__SMU_DUMMY_MAP (RequestI2cTransaction), \ -__SMU_DUMMY_MAP (GetMetricsTable), +__SMU_DUMMY_MAP (GetMetricsTable), \ +__SMU_DUMMY_MAP (SetCClkSMTEnable), #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##typedrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0@@ -141,6 +141,7 @@ static struct cmn2asic_msg_mappingvangogh_message_map[SMU_MSG_MAX_COUNT] = {
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 141
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetGfxOffStatus,
PPSMC_MSG_GetGfxOffStatus,0),Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 142
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetGfxOffEntryCount,
PPSMC_MSG_GetGfxOffEntryCount,0),Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 143
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(LogGfxOffResidency,
PPSMC_MSG_LogGfxOffResidency, 0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping · line 144
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +1
-0+ MSG_MAP(SetCClkSMTEnable,
PPSMC_MSG_SetCClkSMTEnable,0),Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0}; static struct cmn2asic_mappingvangogh_feature_mask_map[SMU_FEATURE_COUNT] = { @@ -460,6
+461,7
Quoted 22 lines
@@
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct
Quoted 9 lines
static int
vangogh_allocate_dpm_context(struct smu_context *smu)static int vangogh_init_smc_tables(struct smu_context *smu) {drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +1
-0+uint32_t smu_version;int ret =0 ; ret =vangogh_tables_init (smu);@@ -477,9 +479,24 @@ static int vangogh_init_smc_tables(struct
smu_context*smu)drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu) · line 486
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0smu->cpu_core_num =4 ;#endif + ret =smu_cmn_get_smc_version (smu,NULL , &smu_version); +if (ret) +return ret; + +if (smu_version >=0x063F0600 )AFAICT the value has already been looked up and you can instead use:
Quoted 1 line
smu->adev->pm.fw_version>=0x063F0600
smu->adev->pm.fw_versionis assigned insmu_v11_0_init_microcode(),Vangogh doesn't initialize .init_microcode interface.
So,
smu->adev->pm.fw_versionvalue is 0.Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static int vangogh_init_smc_tables(struct smu_context *smu) · line 494
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +4
-0+smu_smt_timer_init (smu); +return smu_v11_0_init_smc_tables (smu); } +static int vangogh_fini_smc_tables (struct smu_context *smu) { +smu_smt_timer_fini (smu);Shouldn't this timer only be deleted if
Quoted 36 lines
Quoted 2 lines
smu->adev->pm.fw_version>=0x063F0600Yes, will add version check before delete the timer.
Need to call the
smu_cmn_get_smc_version()again, not good. Look forward to your opinions.Quoted 28 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0+smu_v11_0_fini_smc_tables (smu); + +return 0 ; +} + static int vangogh_dpm_set_vcn_enable(struct smu_context *smu,bool
enable)
Quoted 4 lines
{ int ret = 0;drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0@@ -2428,12 +2445,24 @@ static u32vangogh_get_gfxoff_entrycount(struct
smu_context*smu,uint64_t*entrdrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
Quoted 8 lines
return ret; }drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +5
-0+static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool +enable) { +int ret; + + ret = smu_cmn_send_smc_msg_with_param(smu,
SMU_MSG_SetCClkSMTEnable,drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr · line 2455
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ enable ? 1 : 0, NULL); +if (ret) +dev_err (smu->adev->dev,"Set CPU SMT state failed!\n" );Given this is goign to be triggered by a timer, this might be best to be a rate limited message to avoid flooding the logs
I prefer removing this message statement. The low-level api has a message print if failing to send.
Quoted 31 lines
Yes, will add, before call
dev_err(...)if (
printk_ratelimit())Best Regards,
WenyouQuoted 24 lines
Quoted 24 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +7
-2+ +return ret; +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, .check_fw_version = smu_v11_0_check_fw_version, .init_smc_tables = vangogh_init_smc_tables, - .fini_smc_tables = smu_v11_0_fini_smc_tables, + .fini_smc_tables = vangogh_fini_smc_tables, .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .register_irq_handler = smu_v11_0_register_irq_handler, @@ -2474 ,6 +2503,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = { .get_power_limit = vangogh_get_power_limit, .set_power_limit = vangogh_set_power_limit, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, + .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, };void vangogh_set_ppt_funcs (struct smu_context *smu)