send message to pmfw when SMT changes
v3 cover send message to pmfw when SMT changes
When the CPU SMT changes on the fly, send the message to pmfw to notify the SMT status changed.
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):
cpu/smt: add a notifier to notify the SMT changes drm/amd/pm: vangogh: send the SMT enable message to pmfw
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43 +++++++++++++++++++ include/linux/cpu.h | 5 +++ kernel/cpu.c | 10 ++++- 7 files changed, 73 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
PATCH v3 1/2 cpu/smt: add a notifier to notify the SMT changes
Add the notifier chain to notify the cpu SMT status changes
--- include/linux/cpu.h | 5 +++++ kernel/cpu.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
include/linux/cpu.h +5 -0
@@ -213,6 +213,11 @@ enum cpuhp_smt_control { CPU_SMT_NOT_IMPLEMENTED, }; +enum cpuhp_smt_status { +SMT_ENABLED , +SMT_DISABLED , +}; +#if defined(CONFIG_SMP ) && defined(CONFIG_HOTPLUG_SMT )extern enum cpuhp_smt_control cpu_smt_control;extern void cpu_smt_disable (bool force);
kernel/cpu.c +9 -1
@@ -89,6 +89,9 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = {cpumask_t cpus_booted_once_mask;#endif +RAW_NOTIFIER_HEAD (smt_notifier_head); +EXPORT_SYMBOL (smt_notifier_head); +#if defined(CONFIG_LOCKDEP ) && defined(CONFIG_SMP )static struct lockdep_map cpuhp_state_up_map =STATIC_LOCKDEP_MAP_INIT ("cpuhp_state-up" , &cpuhp_state_up_map);
@@ -2281,8 +2284,10 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)*/ cpuhp_offline_cpu_device (cpu); } -if (!ret) +if (!ret) { cpu_smt_control = ctrlval; +raw_notifier_call_chain (&smt_notifier_head,SMT_DISABLED ,NULL ); + }cpu_maps_update_done ();return ret; }
@@ -2303,6 +2308,9 @@ int cpuhp_smt_enable(void)/* See comment in cpuhp_smt_disable() */ cpuhp_online_cpu_device (cpu); } +if (!ret) +raw_notifier_call_chain (&smt_notifier_head,SMT_ENABLED ,NULL ); +cpu_maps_update_done ();return ret; }
Signature · 1 line
2.39.2
Peter Zijlstra
maintainerRe: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
Quoted 2 lines · Wenyou Yang
Add the notifier chain to notify the cpu SMT status changes
Why!?!? What's the purpose of all this? IIRC this doesn't trigger if you manually disable all the siblings. And because you didn't tell us why you need this I can't tell you if that matters or not :/
RE: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
[AMD Official Use Only - General]
Hi Peter,
Thank you for your review.
The purpose of the patch set is to improve the performance when playing game for some AMD APUs with SMT enabled/disabled.
When change the SMT state on the fly through " echo on/off > /sys/devices/system/cpu/smt/control", the kernel needs to send a message to notify PMFW to adjust a variable's value, which impacts the performance.
Best Regards,
Wenyou
Quoted 25 lines
-----Original Message-----
From: Peter Zijlstra <[email protected]>
Sent: Wednesday, March 29, 2023 3:10 PM
To: Yang, WenYou <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]; Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changesCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 2 lines · Wenyou Yang
Add the notifier chain to notify the cpu SMT status changes
Why!?!? What's the purpose of all this? IIRC this doesn't trigger if you manually disable all the siblings. And because you didn't tell us why you need this I can't tell you if that matters or not :/
Peter Zijlstra
maintainerRe: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
Quoted 1 line · WenYou
[AMD Official Use Only - General]
^^^ that has no business being in a public email.
Quoted 7 lines
Hi Peter,
Thank you for your review.
The purpose of the patch set is to improve the performance when playing game for some AMD APUs with SMT enabled/disabled.
When change the SMT state on the fly through " echo on/off >
/sys/devices/system/cpu/smt/control", the kernel needs to send a message to notify PMFW to adjust a variable's value, which impacts the performance.
When top posting I normally ignore the email. When not wrapping email I typically get cranky. You 'win' *3* 'I cannot use email' trophies in a singly try. Surely AMD has a HOWTO somewhere you can read?
So what do you want to have happen when someone goes and manually offlines all the SMT siblings using /sys/devices/system/cpu/cpu*/online ?
I'm thinking that wants the same PMFW (whatever the heck that is) notification change done, right?
If the answer is "yes", then your patch does not meet the goals and is inadequate.
RE: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
[AMD Official Use Only - General]
Quoted 30 lines
-----Original Message-----
From: Peter Zijlstra <[email protected]>
Sent: Wednesday, March 29, 2023 4:50 PM
To: Yang, WenYou <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]; Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changesCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 1 line · WenYou
[AMD Official Use Only - General]
^^^ that has no business being in a public email.
Quoted 5 lines
Hi Peter,
Thank you for your review.
The purpose of the patch set is to improve the performance when playing
game for some AMD APUs with SMT enabled/disabled.
Quoted 1 line
Quoted 7 lines
Quoted 1 line
When change the SMT state on the fly through " echo on/off >
/sys/devices/system/cpu/smt/control", the kernel needs to send a message to notify PMFW to adjust a variable's value, which impacts the performance.When top posting I normally ignore the email. When not wrapping email I typically get cranky. You 'win' *3* 'I cannot use email' trophies in a singly try. Surely AMD has a HOWTO somewhere you can read?
Yes. It is my fault. Sorry.
Quoted 4 lines
So what do you want to have happen when someone goes and manually offlines all the SMT siblings using
/sys/devices/system/cpu/cpu*/online?
I don't consider this situation. Any suggestions will be deeply appreciated.
Quoted 6 lines
I'm thinking that wants the same PMFW (whatever the heck that is) notification change done, right?
If the answer is "yes", then your patch does not meet the goals and is inadequate.
Yes. Need to improve.
Thank you.
Wenyou
RE: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
[AMD Official Use Only - General]
Quoted 63 lines
-----Original Message-----
From: Yang, WenYou
Sent: Wednesday, March 29, 2023 5:43 PM
To: Peter Zijlstra <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]; Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes[AMD Official Use Only - General]
Quoted 29 lines
-----Original Message-----
From: Peter Zijlstra <[email protected]>
Sent: Wednesday, March 29, 2023 4:50 PM
To: Yang, WenYou <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]; Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changesCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 1 line · WenYou
[AMD Official Use Only - General]
^^^ that has no business being in a public email.
Quoted 4 lines
Hi Peter,
Thank you for your review.
Quoted 7 lines
Quoted 2 lines
The purpose of the patch set is to improve the performance when playing
game for some AMD APUs with SMT enabled/disabled.
Quoted 2 lines
When change the SMT state on the fly through " echo on/off >
/sys/devices/system/cpu/smt/control", the kernel needs to send a message to notify PMFW to adjust a variable's value, which impacts theperformance.
Quoted 4 lines
When top posting I normally ignore the email. When not wrapping email I typically get cranky. You 'win' *3* 'I cannot use email' trophies in a singly try. Surely AMD has a HOWTO somewhere you can read?
Yes. It is my fault. Sorry.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
So what do you want to have happen when someone goes and manually offlines all the SMT siblings using
/sys/devices/system/cpu/cpu*/online
?I don't consider this situation. Any suggestions will be deeply appreciated.
Hi Peter,
I don't find a good method to handle this situation.
Yes, manually offlining all the SMT sibling will get the same result of SMT disabling on the fly.
Actually, the normal way to enable/disable SMT on the fly is to echo on/off > /sys/device/system/cpu/smt/control
What are your opinions?
Best Regards,
Wenyou
Quoted 12 lines
Quoted 7 lines
I'm thinking that wants the same PMFW (whatever the heck that is) notification change done, right?
If the answer is "yes", then your patch does not meet the goals and is inadequate.
Yes. Need to improve.
Thank you.
Wenyou
RE: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
On Fri, Mar 31 2023 at 05:49, WenYou Yang wrote:
<SNIP>
Removing pointlessly copied mail headers. Please fix your email client
</SNIP>
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
So what do you want to have happen when someone goes and manually offlines all the SMT siblings using
/sys/devices/system/cpu/cpu*/online
?
Quoted 8 lines
Quoted 1 line
I don't consider this situation. Any suggestions will be deeply appreciated.
Hi Peter,
I don't find a good method to handle this situation.
Yes, manually offlining all the SMT sibling will get the same result of SMT disabling on the fly.Actually, the normal way to enable/disable SMT on the fly is to echo on/off >
/sys/device/system/cpu/smt/control
That's the most convenient way, right.
But why do we need a kernel notifier for this, if you can do the same with a sysfs knob for your driver?
Then user space can fiddle with SMT control in sysfs and afterwards tell the driver that it should reconfigure.
That makes a ton more sense than this random notifier.
Thanks,
tglx
PATCH v3 2/2 drm/amd/pm: vangogh: send the SMT enable message to pmfw
In reply to Wenyou YangWhen the CPU SMT status is changed in the fly, sent the SMT enable message to pmfw to notify it that the SMT status changed.
Add the support to send PPSMC_MSG_SetCClkSMTEnable(0x58) message to pmfw for vangogh.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43 +++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5 -0
@@ -69,6 +69,8 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state); +extern struct raw_notifier_head smt_notifier_head; +static int smu_sys_get_pp_feature_mask (void *handle,char *buf) {
@@ -1122,6 +1124,9 @@ static int smu_sw_fini(void *handle)smu_fini_microcode (smu); +if (smu->nb.notifier_call !=NULL ) +raw_notifier_chain_unregister (&smt_notifier_head, &smu->nb); +return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7 -0
@@ -566,6 +566,8 @@ struct smu_contextstruct firmware pptable_firmware; +struct notifier_block nb; +u32 param_reg;u32 msg_reg;u32 resp_reg;
@@ -1354,6 +1356,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/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 +43 -0
88 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfw
Quoted 181 lines · Wenyou Yang
When the CPU SMT status is changed in the fly, sent the SMT enable message to pmfw to notify it that the SMT status changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to pmfw for vangogh.Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43 +++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0@@ -69,6 +69,8 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state); +extern struct raw_notifier_head smt_notifier_head; +static int smu_sys_get_pp_feature_mask (void *handle,char *buf) {@@ -1122,6 +1124,9 @@ static int smu_sw_fini(void *handle)smu_fini_microcode (smu); +if (smu->nb.notifier_call !=NULL ) +raw_notifier_chain_unregister (&smt_notifier_head, &smu->nb); +return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7
-0@@ -566,6 +566,8 @@ struct smu_contextstruct firmware pptable_firmware; +struct notifier_block nb; +u32 param_reg;u32 msg_reg;u32 resp_reg;@@ -1354,6 +1356,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/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 +33
-0@@ -35,6 +35,7 @@#include "asic_reg/gc/gc_10_3_0_offset.h" #include "asic_reg/gc/gc_10_3_0_sh_mask.h" #include <asm/processor.h> +#include <linux/cpu.h> /* * DO NOT use these for err/warn/info/debug messages. @@ -70,6 +71,8 @@ FEATURE_MASK(FEATURE_DCFCLK_DPM_BIT)| \ FEATURE_MASK(FEATURE_GFX_DPM_BIT)) +extern struct raw_notifier_head smt_notifier_head; +static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT ] = {MSG_MAP (TestMessage, PPSMC_MSG_TestMessage,0 ),MSG_MAP (GetSmuVersion, PPSMC_MSG_GetSmuVersion,0 ),@@ -141,6 +144,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] = {@@ -221,6 +225,9 @@ static const uint8_t vangogh_throttler_map[] = { [THROTTLER_STATUS_BIT_TDC_CVIP] = (SMU_THROTTLER_TDC_CVIP_BIT), }; +static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data); +static int vangogh_tables_init (struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table;@@ -477,6 +484,9 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num =4 ;#endif + smu->nb.notifier_call = smt_notifier_callback; +raw_notifier_chain_register (&smt_notifier_head, &smu->nb); +return smu_v11_0_init_smc_tables (smu); }@@ -2428,6 +2438,12 @@ 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) +{ +return smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetCClkSMTEnable, + enable ?1 :0 ,NULL ); +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -2474,6 +2490,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)@@ -2486,3 +2503,29 @@ void vangogh_set_ppt_funcs(struct smu_context *smu) smu->is_apu = true;smu_v11_0_set_smu_mailbox_registers (smu); } + +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; +} + +static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data) +{ + struct smu_context *smu = container_of(nb, struct smu_context, nb); +int ret;
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu) · line 2531
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +10
-0+ + smu = container_of(nb, struct smu_context, nb); + + ret =smu_set_cpu_smt_enable (smu, action ==SMT_ENABLED ); + +dev_dbg (smu->adev->dev,"failed to set cclk_pd_limit for SMT %sabled: %d\n" , + action ==SMT_ENABLED ?"en" :"dis" , ret); + +return ret ?NOTIFY_BAD :NOTIFY_OK ; +}
Is there a particular PMFW version requirement for this message to work?
Perhaps you should only register/unregister for this notifier when that minimum PMFW is present.
Otherwise this is going to lead to smu_set_cpu_smt_enable always failing on older PMFW and the notifier callback will return NOTIFY_BAD every time.
RE: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfw
[AMD Official Use Only - General]
Quoted 234 lines
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Wednesday, March 29, 2023 12:18 PM
To: Yang, WenYou <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; [email protected]; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]
Cc: Yuan, Perry <[email protected]>; Liang, Richard qi <[email protected]>; Li, Ying <[email protected]>; Liu, Kun <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfwQuoted 6 lines · Wenyou Yang
When the CPU SMT status is changed in the fly, sent the SMT enable message to pmfw to notify it that the SMT status changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to pmfw for vangogh.Quoted 7 lines
Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43+++++++++++++++++++
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle,
Quoted 8 lines
5 files changed, 59 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -69,6 +69,8 @@ static int smu_set_fan_speed_rpm(void *handle,
uint32_tspeed);Quoted 34 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state); +extern struct raw_notifier_head smt_notifier_head; +static int smu_sys_get_pp_feature_mask (void *handle,char *buf){drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0@@ -1122,6 +1124,9 @@ static int smu_sw_fini(void *handle)smu_fini_microcode (smu); +if (smu->nb.notifier_call !=NULL ) +raw_notifier_chain_unregister (&smt_notifier_head, &smu->nb); +return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-0@@ -566,6 +566,8 @@ struct smu_contextstruct firmware pptable_firmware; +struct notifier_block nb; +u32 param_reg;u32 msg_reg;u32 resp_reg;drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h struct pptable_funcs { · line 1356
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0@@ -1354,6 +1356,11 @@ struct pptable_funcs {* @init_pptable_microcode: Prepare the pptable microcode to upload via PSP
Quoted 55 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); }; typedef enum {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 +1
-0@@ -35,6 +35,7 @@#include "asic_reg/gc/gc_10_3_0_offset.h" #include "asic_reg/gc/gc_10_3_0_sh_mask.h" #include <asm/processor.h> +#include <linux/cpu.h> /* * DO NOT use these for err/warn/info/debug messages. drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 76
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2
-0@@ -70,6 +71,8 @@ FEATURE_MASK(FEATURE_DCFCLK_DPM_BIT)| \ FEATURE_MASK(FEATURE_GFX_DPM_BIT)) +extern struct raw_notifier_head smt_notifier_head; + static struct cmn2asic_msg_mappingvangogh_message_map[SMU_MSG_MAX_COUNT] = {
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 77
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(TestMessage, PPSMC_MSG_TestMessage,0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 78
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion,0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0@@ -141,6 +144,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 144
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 145
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 146
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 147
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] = { @@ -221,6 +225,9
@@ static const
uint8_tvangogh_throttler_map[] = {Quoted 1 line
[
THROTTLER_STATUS_BIT_TDC_CVIP] =(
SMU_THROTTLER_TDC_CVIP_BIT),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct
Quoted 19 lines
};drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +7
-0+static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data); +static int vangogh_tables_init (struct smu_context *smu) { struct smu_table_context *smu_table = &smu->smu_table; @@ -477,6 +484,9 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num = 4;#endif + smu->nb.notifier_call = smt_notifier_callback; +raw_notifier_chain_register (&smt_notifier_head, &smu->nb); +return smu_v11_0_init_smc_tables (smu); }@@ -2428,6 +2438,12 @@ 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 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0return ret; } +static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool +enable) { + return 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
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ enable ? 1 : 0, NULL); +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, @@ -2474,6 +2490,7@@
Quoted 23 lines
static const struct
pptable_funcsvangogh_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,drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +13
-0+ .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, }; void vangogh_set_ppt_funcs(struct smu_context *smu) @@ -2486,3 +2503,29 @@ void vangogh_set_ppt_funcs(struct smu_context *smu) smu->is_apu = true;smu_v11_0_set_smu_mailbox_registers (smu); } + +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/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu)
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +10
-0+static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data) { + struct smu_context *smu = container_of(nb, struct smu_context, nb); +int ret; + + smu = container_of(nb, struct smu_context, nb); + + ret =smu_set_cpu_smt_enable (smu, action ==SMT_ENABLED ); + + dev_dbg(smu->adev->dev, "failed to set cclk_pd_limit forSMT %sabled: %d\n",
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu)
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ action == SMT_ENABLED ? "en" : "dis", ret); + +return ret ?NOTIFY_BAD :NOTIFY_OK ; }Is there a particular PMFW version requirement for this message to work?
Quoted 5 lines
Perhaps you should only register/unregister for this notifier when that minimum PMFW is present.
Otherwise this is going to lead to
smu_set_cpu_smt_enablealways failing on older PMFW and the notifier callback will returnNOTIFY_BADevery time.
Thank you for your suggestion, Will add it.
Best Regards,
Wenyou
Re: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfw
In reply to Wenyou YangQuoted 169 lines · Wenyou Yang
When the CPU SMT status is changed in the fly, sent the SMT enable message to pmfw to notify it that the SMT status changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to pmfw for vangogh.Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43 +++++++++++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +5
-0@@ -69,6 +69,8 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed);static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state); +extern struct raw_notifier_head smt_notifier_head; +static int smu_sys_get_pp_feature_mask (void *handle,char *buf) {@@ -1122,6 +1124,9 @@ static int smu_sw_fini(void *handle)smu_fini_microcode (smu); +if (smu->nb.notifier_call !=NULL ) +raw_notifier_chain_unregister (&smt_notifier_head, &smu->nb); +return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7
-0@@ -566,6 +566,8 @@ struct smu_contextstruct firmware pptable_firmware; +struct notifier_block nb; +u32 param_reg;u32 msg_reg;u32 resp_reg;@@ -1354,6 +1356,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/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 +21
-0@@ -35,6 +35,7 @@#include "asic_reg/gc/gc_10_3_0_offset.h" #include "asic_reg/gc/gc_10_3_0_sh_mask.h" #include <asm/processor.h> +#include <linux/cpu.h> /* * DO NOT use these for err/warn/info/debug messages. @@ -70,6 +71,8 @@ FEATURE_MASK(FEATURE_DCFCLK_DPM_BIT)| \ FEATURE_MASK(FEATURE_GFX_DPM_BIT)) +extern struct raw_notifier_head smt_notifier_head; +static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT ] = {MSG_MAP (TestMessage, PPSMC_MSG_TestMessage,0 ),MSG_MAP (GetSmuVersion, PPSMC_MSG_GetSmuVersion,0 ),@@ -141,6 +144,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] = {@@ -221,6 +225,9 @@ static const uint8_t vangogh_throttler_map[] = { [THROTTLER_STATUS_BIT_TDC_CVIP] = (SMU_THROTTLER_TDC_CVIP_BIT), }; +static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data); +static int vangogh_tables_init (struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table;@@ -477,6 +484,9 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num =4 ;#endif + smu->nb.notifier_call = smt_notifier_callback; +raw_notifier_chain_register (&smt_notifier_head, &smu->nb); +return smu_v11_0_init_smc_tables (smu); }@@ -2428,6 +2438,12 @@ 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) +{ +return smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetCClkSMTEnable, + enable ?1 :0 ,NULL ); +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status,@@ -2474,6 +2490,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)@@ -2486,3 +2503,29 @@ void vangogh_set_ppt_funcs(struct smu_context *smu) smu->is_apu = true;smu_v11_0_set_smu_mailbox_registers (smu); } + +static int smu_set_cpu_smt_enable (struct smu_context *smu,bool enable) +{ +int ret = -EINVAL ;
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu) · line 2519
Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +10
-0+ +if (smu->ppt_funcs && smu->ppt_funcs->set_cpu_smt_enable) + ret = smu->ppt_funcs->set_cpu_smt_enable (smu, enable); + +return ret; +} + +static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data) +{
This and the one above can be moved to smu_cmn.c as they are generic ones.
Thanks,
Lijo
Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +12
-0+ struct smu_context *smu = container_of(nb, struct smu_context, nb); +int ret; + + smu = container_of(nb, struct smu_context, nb); + + ret =smu_set_cpu_smt_enable (smu, action ==SMT_ENABLED ); + +dev_dbg (smu->adev->dev,"failed to set cclk_pd_limit for SMT %sabled: %d\n" , + action ==SMT_ENABLED ?"en" :"dis" , ret); + +return ret ?NOTIFY_BAD :NOTIFY_OK ; +}
RE: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfw
[AMD Official Use Only - General]
Quoted 214 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, March 29, 2023 2:15 PM
To: Yang, WenYou <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; [email protected]; Phillips, Kim <[email protected]>; [email protected]
Cc: Yuan, Perry <[email protected]>; Li, Ying <[email protected]>; linux- [email protected]; [email protected]; [email protected]; Liu, Kun <[email protected]>; Liang, Richard qi <[email protected]>
Subject: Re: [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfwQuoted 6 lines · Wenyou Yang
When the CPU SMT status is changed in the fly, sent the SMT enable message to pmfw to notify it that the SMT status changed.
Add the support to send
PPSMC_MSG_SetCClkSMTEnable(0x58)message to pmfw for vangogh.Quoted 7 lines
Signed-off-by Wenyou Yang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 5 +++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++ .../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 | 43+++++++++++++++++++
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_set_fan_speed_rpm(void *handle,
Quoted 8 lines
5 files changed, 59 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0@@ -69,6 +69,8 @@ static int smu_set_fan_speed_rpm(void *handle,
uint32_tspeed);Quoted 34 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-0static int smu_set_gfx_cgpg (struct smu_context *smu,bool enabled);static int smu_set_mp1_state (void *handle,enum pp_mp1_state mp1_state); +extern struct raw_notifier_head smt_notifier_head; +static int smu_sys_get_pp_feature_mask (void *handle,char *buf){drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0@@ -1122,6 +1124,9 @@ static int smu_sw_fini(void *handle)smu_fini_microcode (smu); +if (smu->nb.notifier_call !=NULL ) +raw_notifier_chain_unregister (&smt_notifier_head, &smu->nb); +return 0 ; }drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2
-0@@ -566,6 +566,8 @@ struct smu_contextstruct firmware pptable_firmware; +struct notifier_block nb; +u32 param_reg;u32 msg_reg;u32 resp_reg;drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h struct pptable_funcs { · line 1356
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0
-0@@ -1354,6 +1356,11 @@ struct pptable_funcs {* @init_pptable_microcode: Prepare the pptable microcode to upload via PSP
Quoted 55 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); }; typedef enum {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 +1
-0@@ -35,6 +35,7 @@#include "asic_reg/gc/gc_10_3_0_offset.h" #include "asic_reg/gc/gc_10_3_0_sh_mask.h" #include <asm/processor.h> +#include <linux/cpu.h> /* * DO NOT use these for err/warn/info/debug messages. drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 76
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +2
-0@@ -70,6 +71,8 @@ FEATURE_MASK(FEATURE_DCFCLK_DPM_BIT)| \ FEATURE_MASK(FEATURE_GFX_DPM_BIT)) +extern struct raw_notifier_head smt_notifier_head; + static struct cmn2asic_msg_mappingvangogh_message_map[SMU_MSG_MAX_COUNT] = {
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 77
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(TestMessage, PPSMC_MSG_TestMessage,0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c line 78
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion,0),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static struct cmn2asic_msg_mapping
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0
-0@@ -141,6 +144,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 144
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 145
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 146
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 147
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] = { @@ -221,6 +225,9
@@ static const
uint8_tvangogh_throttler_map[] = {Quoted 1 line
[
THROTTLER_STATUS_BIT_TDC_CVIP] =(
SMU_THROTTLER_TDC_CVIP_BIT),drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c static u32 vangogh_get_gfxoff_entrycount(struct
Quoted 19 lines
};drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +7
-0+static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data); +static int vangogh_tables_init (struct smu_context *smu) { struct smu_table_context *smu_table = &smu->smu_table; @@ -477,6 +484,9 @@ static int vangogh_init_smc_tables(struct smu_context *smu) smu->cpu_core_num = 4;#endif + smu->nb.notifier_call = smt_notifier_callback; +raw_notifier_chain_register (&smt_notifier_head, &smu->nb); +return smu_v11_0_init_smc_tables (smu); }@@ -2428,6 +2438,12 @@ 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 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0return ret; } +static int vangogh_set_cpu_smt_enable (struct smu_context *smu,bool +enable) { + return 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
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ enable ? 1 : 0, NULL); +} +static const struct pptable_funcs vangogh_ppt_funcs = { .check_fw_status = smu_v11_0_check_fw_status, @@ -2474,6 +2490,7@@
Quoted 19 lines
static const struct
pptable_funcsvangogh_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,drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +9
-0+ .set_cpu_smt_enable = vangogh_set_cpu_smt_enable, }; void vangogh_set_ppt_funcs(struct smu_context *smu) @@ -2486,3 +2503,29 @@ void vangogh_set_ppt_funcs(struct smu_context *smu) smu->is_apu = true;smu_v11_0_set_smu_mailbox_registers (smu); } + +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);
Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu)
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +6
-0+ +return ret; +} + +static int smt_notifier_callback (struct notifier_block *nb, +unsigned long action,void *data) {This and the one above can be moved to
smu_cmn.cas they are generic ones.
Thank you for your review. Will do.
Best Regards,
Wenyou
Quoted 15 lines
Thanks,
Lijodrivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c void vangogh_set_ppt_funcs(struct smu_context *smu)
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +8
-0+ struct smu_context *smu = container_of(nb, struct smu_context, nb); +int ret; + + smu = container_of(nb, struct smu_context, nb); + + ret =smu_set_cpu_smt_enable (smu, action ==SMT_ENABLED ); + + dev_dbg(smu->adev->dev, "failed to set cclk_pd_limit forSMT %sabled: %d\n",
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +3
-0+ action == SMT_ENABLED ? "en" : "dis", ret); + +return ret ?NOTIFY_BAD :NOTIFY_OK ; }