Re: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable message to pmfw

2023-03-23 Thread Lazar, Lijo




On 3/23/2023 3:04 PM, Yang, WenYou wrote:

[AMD Official Use Only - General]




-Original Message-
From: Lazar, Lijo 
Sent: Thursday, March 23, 2023 4:29 PM
To: Yang, WenYou ; Deucher, Alexander
; Koenig, Christian
; Pan, Xinhui 
Cc: Yuan, Perry ; Li, Ying ; amd-
g...@lists.freedesktop.org; Liu, Kun ; Liang, Richard qi

Subject: Re: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable
message to pmfw



On 3/22/2023 2:46 PM, Wenyou Yang wrote:

When the CPU SMT status change in the fly, sent the SMT-enable message
to pmfw to notify it that the SMT status changed.

Signed-off-by: Wenyou Yang 
---
   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41

+++

   drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  5 +++
   2 files changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index b5d64749990e..5cd85a9d149d 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -22,6 +22,7 @@

   #define SWSMU_CODE_LAYER_L1

+#include 
   #include 
   #include 

@@ -69,6 +70,14 @@ 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);

+static int smt_notifier_callback(struct notifier_block *nb, unsigned
+long action, void *data);
+
+extern struct raw_notifier_head smt_notifier_head;
+
+static struct notifier_block smt_notifier = {
+   .notifier_call = smt_notifier_callback, };
+
   static int smu_sys_get_pp_feature_mask(void *handle,
   char *buf)
   {
@@ -625,6 +634,8 @@ static int smu_set_funcs(struct amdgpu_device

*adev)

return 0;
   }

+static struct smu_context *current_smu;
+
   static int smu_early_init(void *handle)
   {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

@@

-645,6 +656,7 @@ static int smu_early_init(void *handle)
mutex_init(>message_lock);

adev->powerplay.pp_handle = smu;
+   current_smu = smu;
adev->powerplay.pp_funcs = _pm_funcs;

r = smu_set_funcs(adev);
@@ -1105,6 +1117,8 @@ static int smu_sw_init(void *handle)
if (!smu->ppt_funcs->get_fan_control_mode)
smu->adev->pm.no_fan = true;

+   raw_notifier_chain_register(_notifier_head, _notifier);
+


It is not required for every dGPU smu to register for and process this
notification regardless of the system they are in. It is only applicable for
vangogh and hence this and below should be moved to some ppt funcs used
in sw_init/sw_fini of amdgpu_smu for vangogh alone.


The fixed issue is common, it is possible to keep this interface for others. So 
I think it is better to put the common code here.



No, this is not common at all. A Navi10 card sitting on an Intel system 
or a Renoir platform is not bothered about an smt change and doesn't 
need to register any notification callback.


All you have to do is to register for this notifier inside, say 
vangogh_set_ppt_funcs or some other callback which happen during sw_init 
of amdgpu_smu.


For unregister, you may keep it in smu_sw_fini call like below.

if (smu->nb.notifier != NULL)
unregister

Also, other/future APUs may be able handle the change internally (by 
propagating through HW itself) without driver needing to notify the FW.


Thanks,
Lijo



Thanks,
Lijo


return 0;
   }

@@ -1122,6 +1136,8 @@ static int smu_sw_fini(void *handle)

smu_fini_microcode(smu);

+   raw_notifier_chain_unregister(_notifier_head, _notifier);
+
return 0;
   }

@@ -3241,3 +3257,28 @@ int smu_send_hbm_bad_channel_flag(struct
smu_context *smu, uint32_t size)

return ret;
   }
+
+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 = current_smu;
+   int ret = NOTIFY_OK;
+
+   ret = (action == SMT_ENABLED) ?
+   smu_set_cpu_smt_enable(smu, true) :
+   smu_set_cpu_smt_enable(smu, false);
+   if (ret)
+   ret = NOTIFY_BAD;
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index 09469c750a96..7c6594bba796 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
@@ -1354,6 +1354,11 @@ struct pptable_funcs {
 * @init_pptable_microcode: Prepare the pptable microcode to

upload via PSP

 */
i

RE: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable message to pmfw

2023-03-23 Thread Yang, WenYou
[AMD Official Use Only - General]



> -Original Message-
> From: Lazar, Lijo 
> Sent: Thursday, March 23, 2023 4:29 PM
> To: Yang, WenYou ; Deucher, Alexander
> ; Koenig, Christian
> ; Pan, Xinhui 
> Cc: Yuan, Perry ; Li, Ying ; amd-
> g...@lists.freedesktop.org; Liu, Kun ; Liang, Richard qi
> 
> Subject: Re: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable
> message to pmfw
> 
> 
> 
> On 3/22/2023 2:46 PM, Wenyou Yang wrote:
> > When the CPU SMT status change in the fly, sent the SMT-enable message
> > to pmfw to notify it that the SMT status changed.
> >
> > Signed-off-by: Wenyou Yang 
> > ---
> >   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41
> +++
> >   drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  5 +++
> >   2 files changed, 46 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > index b5d64749990e..5cd85a9d149d 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > @@ -22,6 +22,7 @@
> >
> >   #define SWSMU_CODE_LAYER_L1
> >
> > +#include 
> >   #include 
> >   #include 
> >
> > @@ -69,6 +70,14 @@ 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);
> >
> > +static int smt_notifier_callback(struct notifier_block *nb, unsigned
> > +long action, void *data);
> > +
> > +extern struct raw_notifier_head smt_notifier_head;
> > +
> > +static struct notifier_block smt_notifier = {
> > +   .notifier_call = smt_notifier_callback, };
> > +
> >   static int smu_sys_get_pp_feature_mask(void *handle,
> >char *buf)
> >   {
> > @@ -625,6 +634,8 @@ static int smu_set_funcs(struct amdgpu_device
> *adev)
> > return 0;
> >   }
> >
> > +static struct smu_context *current_smu;
> > +
> >   static int smu_early_init(void *handle)
> >   {
> > struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> @@
> > -645,6 +656,7 @@ static int smu_early_init(void *handle)
> > mutex_init(>message_lock);
> >
> > adev->powerplay.pp_handle = smu;
> > +   current_smu = smu;
> > adev->powerplay.pp_funcs = _pm_funcs;
> >
> > r = smu_set_funcs(adev);
> > @@ -1105,6 +1117,8 @@ static int smu_sw_init(void *handle)
> > if (!smu->ppt_funcs->get_fan_control_mode)
> > smu->adev->pm.no_fan = true;
> >
> > +   raw_notifier_chain_register(_notifier_head, _notifier);
> > +
> 
> It is not required for every dGPU smu to register for and process this
> notification regardless of the system they are in. It is only applicable for
> vangogh and hence this and below should be moved to some ppt funcs used
> in sw_init/sw_fini of amdgpu_smu for vangogh alone.

The fixed issue is common, it is possible to keep this interface for others. So 
I think it is better to put the common code here.

> 
> Thanks,
> Lijo
> 
> > return 0;
> >   }
> >
> > @@ -1122,6 +1136,8 @@ static int smu_sw_fini(void *handle)
> >
> > smu_fini_microcode(smu);
> >
> > +   raw_notifier_chain_unregister(_notifier_head, _notifier);
> > +
> > return 0;
> >   }
> >
> > @@ -3241,3 +3257,28 @@ int smu_send_hbm_bad_channel_flag(struct
> > smu_context *smu, uint32_t size)
> >
> > return ret;
> >   }
> > +
> > +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 = current_smu;
> > +   int ret = NOTIFY_OK;
> > +
> > +   ret = (action == SMT_ENABLED) ?
> > +   smu_set_cpu_smt_enable(smu, true) :
> > +   smu_set_cpu_smt_enable(smu, false);
> > +   if (ret)
> > +   ret = NOTIFY_BAD;
> > +
> > +   return ret;
> > +}
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> > b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> > index 09469c750a96..7c6594bba796 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> > @@ -1354,6 +1354,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 enable);
> >   };
> >
> >   typedef enum {


Re: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable message to pmfw

2023-03-23 Thread Lazar, Lijo




On 3/22/2023 2:46 PM, Wenyou Yang wrote:

When the CPU SMT status change in the fly, sent the SMT-enable
message to pmfw to notify it that the SMT status changed.

Signed-off-by: Wenyou Yang 
---
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41 +++
  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  5 +++
  2 files changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index b5d64749990e..5cd85a9d149d 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -22,6 +22,7 @@
  
  #define SWSMU_CODE_LAYER_L1
  
+#include 

  #include 
  #include 
  
@@ -69,6 +70,14 @@ 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);
  
+static int smt_notifier_callback(struct notifier_block *nb, unsigned long action, void *data);

+
+extern struct raw_notifier_head smt_notifier_head;
+
+static struct notifier_block smt_notifier = {
+   .notifier_call = smt_notifier_callback,
+};
+
  static int smu_sys_get_pp_feature_mask(void *handle,
   char *buf)
  {
@@ -625,6 +634,8 @@ static int smu_set_funcs(struct amdgpu_device *adev)
return 0;
  }
  
+static struct smu_context *current_smu;

+
  static int smu_early_init(void *handle)
  {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -645,6 +656,7 @@ static int smu_early_init(void *handle)
mutex_init(>message_lock);
  
  	adev->powerplay.pp_handle = smu;

+   current_smu = smu;
adev->powerplay.pp_funcs = _pm_funcs;
  
  	r = smu_set_funcs(adev);

@@ -1105,6 +1117,8 @@ static int smu_sw_init(void *handle)
if (!smu->ppt_funcs->get_fan_control_mode)
smu->adev->pm.no_fan = true;
  
+	raw_notifier_chain_register(_notifier_head, _notifier);

+


It is not required for every dGPU smu to register for and process this 
notification regardless of the system they are in. It is only applicable 
for vangogh and hence this and below should be moved to some ppt funcs 
used in sw_init/sw_fini of amdgpu_smu for vangogh alone.


Thanks,
Lijo


return 0;
  }
  
@@ -1122,6 +1136,8 @@ static int smu_sw_fini(void *handle)
  
  	smu_fini_microcode(smu);
  
+	raw_notifier_chain_unregister(_notifier_head, _notifier);

+
return 0;
  }
  
@@ -3241,3 +3257,28 @@ int smu_send_hbm_bad_channel_flag(struct smu_context *smu, uint32_t size)
  
  	return ret;

  }
+
+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 = current_smu;
+   int ret = NOTIFY_OK;
+
+   ret = (action == SMT_ENABLED) ?
+   smu_set_cpu_smt_enable(smu, true) :
+   smu_set_cpu_smt_enable(smu, false);
+   if (ret)
+   ret = NOTIFY_BAD;
+
+   return ret;
+}
diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
index 09469c750a96..7c6594bba796 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
@@ -1354,6 +1354,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 enable);
  };
  
  typedef enum {


RE: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable message to pmfw

2023-03-23 Thread Yang, WenYou
[AMD Official Use Only - General]



> -Original Message-
> From: Quan, Evan 
> Sent: Thursday, March 23, 2023 3:17 PM
> To: Yang, WenYou ; Deucher, Alexander
> ; Koenig, Christian
> ; Pan, Xinhui 
> Cc: Yuan, Perry ; Li, Ying ; amd-
> g...@lists.freedesktop.org; Yang, WenYou ; Liu,
> Kun ; Liang, Richard qi 
> Subject: RE: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable
> message to pmfw
> 
> [AMD Official Use Only - General]
> 
> 
> 
> > -Original Message-
> > From: amd-gfx  On Behalf Of
> > Wenyou Yang
> > Sent: Wednesday, March 22, 2023 5:16 PM
> > To: Deucher, Alexander ; Koenig,
> Christian
> > ; Pan, Xinhui 
> > Cc: Yuan, Perry ; Li, Ying ;
> amd-
> > g...@lists.freedesktop.org; Yang, WenYou ; Liu,
> > Kun ; Liang, Richard qi 
> > Subject: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable
> message
> > to pmfw
> >
> > When the CPU SMT status change in the fly, sent the SMT-enable message
> > to pmfw to notify it that the SMT status changed.
> >
> > Signed-off-by: Wenyou Yang 
> > ---
> >  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41
> > +++
> >  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  5 +++
> >  2 files changed, 46 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > index b5d64749990e..5cd85a9d149d 100644
> > --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> > @@ -22,6 +22,7 @@
> >
> >  #define SWSMU_CODE_LAYER_L1
> >
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -69,6 +70,14 @@ 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);
> >
> > +static int smt_notifier_callback(struct notifier_block *nb, unsigned
> > +long
> > action, void *data);
> > +
> > +extern struct raw_notifier_head smt_notifier_head;
> > +
> > +static struct notifier_block smt_notifier = {
> > +   .notifier_call = smt_notifier_callback, };
> By embedding smt_notifier into "struct smu_context" structure, you do not
> need this smt_notifer and current_smu below.
> You can refer to omap_dma_busy_notifier().
Accept. Thanks.

> 
> BR
> Evan
> > +
> >  static int smu_sys_get_pp_feature_mask(void *handle,
> >char *buf)
> >  {
> > @@ -625,6 +634,8 @@ static int smu_set_funcs(struct amdgpu_device
> > *adev)
> > return 0;
> >  }
> >
> > +static struct smu_context *current_smu;
> > +
> >  static int smu_early_init(void *handle)  {
> > struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> @@
> > -645,6 +656,7 @@ static int smu_early_init(void *handle)
> > mutex_init(>message_lock);
> >
> > adev->powerplay.pp_handle = smu;
> > +   current_smu = smu;
> > adev->powerplay.pp_funcs = _pm_funcs;
> >
> > r = smu_set_funcs(adev);
> > @@ -1105,6 +1117,8 @@ static int smu_sw_init(void *handle)
> > if (!smu->ppt_funcs->get_fan_control_mode)
> > smu->adev->pm.no_fan = true;
> >
> > +   raw_notifier_chain_register(_notifier_head, _notifier);
> > +
> > return 0;
> >  }
> >
> > @@ -1122,6 +1136,8 @@ static int smu_sw_fini(void *handle)
> >
> > smu_fini_microcode(smu);
> >
> > +   raw_notifier_chain_unregister(_notifier_head, _notifier);
> > +
> > return 0;
> >  }
> >
> > @@ -3241,3 +3257,28 @@ int smu_send_hbm_bad_channel_flag(struct
> > smu_context *smu, uint32_t size)
> >
> > return ret;
> >  }
> > +
> > +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 = current_smu;
> > +   int ret = NOTIFY_OK;
> > +
> > +   ret = (action == SMT_ENABLED) ?
> > +   smu_set_cpu_smt_enable(smu, true) :
&g

RE: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable message to pmfw

2023-03-23 Thread Quan, Evan
[AMD Official Use Only - General]



> -Original Message-
> From: amd-gfx  On Behalf Of
> Wenyou Yang
> Sent: Wednesday, March 22, 2023 5:16 PM
> To: Deucher, Alexander ; Koenig, Christian
> ; Pan, Xinhui 
> Cc: Yuan, Perry ; Li, Ying ; amd-
> g...@lists.freedesktop.org; Yang, WenYou ; Liu,
> Kun ; Liang, Richard qi 
> Subject: [Resend PATCH v1 2/3] drm/amd/pm: send the SMT-enable
> message to pmfw
> 
> When the CPU SMT status change in the fly, sent the SMT-enable
> message to pmfw to notify it that the SMT status changed.
> 
> Signed-off-by: Wenyou Yang 
> ---
>  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41
> +++
>  drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  5 +++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index b5d64749990e..5cd85a9d149d 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -22,6 +22,7 @@
> 
>  #define SWSMU_CODE_LAYER_L1
> 
> +#include 
>  #include 
>  #include 
> 
> @@ -69,6 +70,14 @@ 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);
> 
> +static int smt_notifier_callback(struct notifier_block *nb, unsigned long
> action, void *data);
> +
> +extern struct raw_notifier_head smt_notifier_head;
> +
> +static struct notifier_block smt_notifier = {
> + .notifier_call = smt_notifier_callback,
> +};
By embedding smt_notifier into "struct smu_context" structure, you do not need 
this smt_notifer and current_smu below.
You can refer to omap_dma_busy_notifier().

BR
Evan
> +
>  static int smu_sys_get_pp_feature_mask(void *handle,
>  char *buf)
>  {
> @@ -625,6 +634,8 @@ static int smu_set_funcs(struct amdgpu_device
> *adev)
>   return 0;
>  }
> 
> +static struct smu_context *current_smu;
> +
>  static int smu_early_init(void *handle)
>  {
>   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
> @@ -645,6 +656,7 @@ static int smu_early_init(void *handle)
>   mutex_init(>message_lock);
> 
>   adev->powerplay.pp_handle = smu;
> + current_smu = smu;
>   adev->powerplay.pp_funcs = _pm_funcs;
> 
>   r = smu_set_funcs(adev);
> @@ -1105,6 +1117,8 @@ static int smu_sw_init(void *handle)
>   if (!smu->ppt_funcs->get_fan_control_mode)
>   smu->adev->pm.no_fan = true;
> 
> + raw_notifier_chain_register(_notifier_head, _notifier);
> +
>   return 0;
>  }
> 
> @@ -1122,6 +1136,8 @@ static int smu_sw_fini(void *handle)
> 
>   smu_fini_microcode(smu);
> 
> + raw_notifier_chain_unregister(_notifier_head, _notifier);
> +
>   return 0;
>  }
> 
> @@ -3241,3 +3257,28 @@ int smu_send_hbm_bad_channel_flag(struct
> smu_context *smu, uint32_t size)
> 
>   return ret;
>  }
> +
> +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 = current_smu;
> + int ret = NOTIFY_OK;
> +
> + ret = (action == SMT_ENABLED) ?
> + smu_set_cpu_smt_enable(smu, true) :
> + smu_set_cpu_smt_enable(smu, false);
> + if (ret)
> + ret = NOTIFY_BAD;
> +
> + return ret;
> +}
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> index 09469c750a96..7c6594bba796 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h
> @@ -1354,6 +1354,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 enable);
>  };
> 
>  typedef enum {
> --
> 2.39.2