RE: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-26 Thread Quan, Evan
[AMD Official Use Only]

Hi Alex & Lijo,

For now, those code for updating OD table are in smu_cmn.c. And they can only 
be called from _ppt.c.
So, unless we split some code from smu_cmn.c and move them to upper 
layer(suggested by Lijo before), otherwise this cannot be performed.
So, definitely we need some follow up patches if we want this done in a more 
generic way.

BR
Evan
From: Deucher, Alexander 
Sent: Friday, July 23, 2021 9:36 PM
To: Lazar, Lijo ; Quan, Evan ; 
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x


[AMD Official Use Only]

I haven't had a chance to look at the patches too closely, but if it could be 
done in a generic may, that makes sense to me.  Maybe as a follow up patch?

Alex


From: Lazar, Lijo mailto:lijo.la...@amd.com>>
Sent: Friday, July 23, 2021 6:09 AM
To: Quan, Evan mailto:evan.q...@amd.com>>; 
amd-gfx@lists.freedesktop.org<mailto:amd-gfx@lists.freedesktop.org> 
mailto:amd-gfx@lists.freedesktop.org>>
Cc: Deucher, Alexander 
mailto:alexander.deuc...@amd.com>>
Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x

The series looks good to me, though I prefer to use a common logic to
restore od settings so that smuv12,smuv13 gets the restore feature by
default once they add the user table logic. Don't have strong argument
for it unless Alex, Kenneth or others have some comments.

Anyway, the series is
Reviewed-by: Lijo Lazar mailto:lijo.la...@amd.com>>

On 7/23/2021 2:39 PM, Evan Quan wrote:
> The customized OD settings can be divided into two parts: those
> committed ones and non-committed ones.
>- For those changes which had been fed to SMU before S3/S4/Runpm
>  suspend kicked, they are committed changes. They should be properly
>  restored and fed to SMU on S3/S4/Runpm resume.
>- For those non-committed changes, they are restored only without feeding
>  to SMU.
>
> Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
> Signed-off-by: Evan Quan mailto:evan.q...@amd.com>>
> --
> v1->v2
>- better naming and logic revised for checking OD setting update(Lijo)
> ---
>   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
>   drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
>   .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
>   .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
>   5 files changed, 82 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
> b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> index 3e89852e4820..c2c201b8e3cf 100644
> --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> @@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
>uint32_t power_limit;
>uint32_t fan_speed_percent;
>uint32_t flags;
> + uint32_t user_od;
>
>/* user clock state information */
>uint32_t clk_mask[SMU_CLK_COUNT];
> @@ -352,6 +353,7 @@ struct smu_table_context
>
>void*overdrive_table;
>void*boot_overdrive_table;
> + void*user_overdrive_table;
>
>uint32_tgpu_metrics_table_size;
>void*gpu_metrics_table;
> @@ -623,6 +625,12 @@ struct pptable_funcs {
> enum PP_OD_DPM_TABLE_COMMAND type,
> long *input, uint32_t size);
>
> + /**
> +  * @restore_user_od_settings: Restore the user customized
> +  *OD settings on S3/S4/Runpm resume.
> +  */
> + int (*restore_user_od_settings)(struct smu_context *smu);
> +
>/**
> * @get_clock_by_type_with_latency: Get the speed and latency of a 
> clock
> *  domain.
> diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
> b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> index 385b2ea5379c..1e42aafbb9fd 100644
> --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> @@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context *smu);
>
>   int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
>
> +int smu_v11_0_restore_user_od_settings(struct smu_context *smu);
> +
>   #endif
>   #endif
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index ebe672142808..8ca7337ea5fc 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/s

RE: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-26 Thread Quan, Evan
[Public]

Hi Guchun,

Currently, the smu->user_dpm_profile.flags seems only used to flag whether we 
are in a process restoring the user customized settings(power limit/fan 
settings/od settings etc). We could either drop it or expand its usage. Let me 
consider more and make a follow-up patch for this.

BR
Evan
> -Original Message-
> From: Chen, Guchun 
> Sent: Friday, July 23, 2021 9:45 PM
> To: Lazar, Lijo ; Quan, Evan ;
> amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander 
> Subject: RE: [PATCH V2 1/2] drm/amd/pm: restore user customized OD
> settings properly for NV1x
> 
> [Public]
> 
> Just curious that in the patch, it adds a variable *user_od* serving the check
> of applying user customized OD setting. Instead of this, does it make sense
> to use the *flag* in struct smu_user_dpm_profile for this? As we have below
> bit in pm/inc/amdgpu_smu.h, can we add another bit for OD restore? This
> will help unify the usage of *flag* in SMU.
> 
> #define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)
> 
> Regards,
> Guchun
> 
> -Original Message-
> From: amd-gfx  On Behalf Of
> Lazar, Lijo
> Sent: Friday, July 23, 2021 6:09 PM
> To: Quan, Evan ; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander 
> Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD
> settings properly for NV1x
> 
> The series looks good to me, though I prefer to use a common logic to
> restore od settings so that smuv12,smuv13 gets the restore feature by
> default once they add the user table logic. Don't have strong argument for it
> unless Alex, Kenneth or others have some comments.
> 
> Anyway, the series is
>   Reviewed-by: Lijo Lazar 
> 
> On 7/23/2021 2:39 PM, Evan Quan wrote:
> > The customized OD settings can be divided into two parts: those
> > committed ones and non-committed ones.
> >- For those changes which had been fed to SMU before S3/S4/Runpm
> >  suspend kicked, they are committed changes. They should be properly
> >  restored and fed to SMU on S3/S4/Runpm resume.
> >- For those non-committed changes, they are restored only without
> feeding
> >  to SMU.
> >
> > Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
> > Signed-off-by: Evan Quan 
> > --
> > v1->v2
> >- better naming and logic revised for checking OD setting
> > update(Lijo)
> > ---
> >   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
> >   drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
> >   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
> >   .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55
> +--
> >   .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
> >   5 files changed, 82 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> > b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> > index 3e89852e4820..c2c201b8e3cf 100644
> > --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> > +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> > @@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
> > uint32_t power_limit;
> > uint32_t fan_speed_percent;
> > uint32_t flags;
> > +   uint32_t user_od;
> >
> > /* user clock state information */
> > uint32_t clk_mask[SMU_CLK_COUNT];
> > @@ -352,6 +353,7 @@ struct smu_table_context
> >
> > void*overdrive_table;
> > void*boot_overdrive_table;
> > +   void*user_overdrive_table;
> >
> > uint32_tgpu_metrics_table_size;
> > void*gpu_metrics_table;
> > @@ -623,6 +625,12 @@ struct pptable_funcs {
> >  enum PP_OD_DPM_TABLE_COMMAND
> type,
> >  long *input, uint32_t size);
> >
> > +   /**
> > +* @restore_user_od_settings: Restore the user customized
> > +*OD settings on S3/S4/Runpm resume.
> > +*/
> > +   int (*restore_user_od_settings)(struct smu_context *smu);
> > +
> > /**
> >  * @get_clock_by_type_with_latency: Get the speed and latency of
> a clock
> >  *  domain.
> > diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> > b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> > index 385b2ea5379c..1e42aafbb9fd 100644
> > --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> > +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> > @@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct
> smu_context
&g

Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-23 Thread Lazar, Lijo
Good one, that makes better use of flags.

Thanks,
Lijo

From: Chen, Guchun 
Sent: Friday, July 23, 2021 7:14:58 PM
To: Lazar, Lijo ; Quan, Evan ; 
amd-gfx@lists.freedesktop.org 
Cc: Deucher, Alexander 
Subject: RE: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x

[Public]

Just curious that in the patch, it adds a variable *user_od* serving the check 
of applying user customized OD setting. Instead of this, does it make sense to 
use the *flag* in struct smu_user_dpm_profile for this? As we have below bit in 
pm/inc/amdgpu_smu.h, can we add another bit for OD restore? This will help 
unify the usage of *flag* in SMU.

#define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)

Regards,
Guchun

-Original Message-
From: amd-gfx  On Behalf Of Lazar, Lijo
Sent: Friday, July 23, 2021 6:09 PM
To: Quan, Evan ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x

The series looks good to me, though I prefer to use a common logic to restore 
od settings so that smuv12,smuv13 gets the restore feature by default once they 
add the user table logic. Don't have strong argument for it unless Alex, 
Kenneth or others have some comments.

Anyway, the series is
Reviewed-by: Lijo Lazar 

On 7/23/2021 2:39 PM, Evan Quan wrote:
> The customized OD settings can be divided into two parts: those
> committed ones and non-committed ones.
>- For those changes which had been fed to SMU before S3/S4/Runpm
>  suspend kicked, they are committed changes. They should be properly
>  restored and fed to SMU on S3/S4/Runpm resume.
>- For those non-committed changes, they are restored only without feeding
>  to SMU.
>
> Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
> Signed-off-by: Evan Quan 
> --
> v1->v2
>- better naming and logic revised for checking OD setting
> update(Lijo)
> ---
>   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
>   drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
>   .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
>   .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
>   5 files changed, 82 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> index 3e89852e4820..c2c201b8e3cf 100644
> --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> @@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
>uint32_t power_limit;
>uint32_t fan_speed_percent;
>uint32_t flags;
> + uint32_t user_od;
>
>/* user clock state information */
>uint32_t clk_mask[SMU_CLK_COUNT];
> @@ -352,6 +353,7 @@ struct smu_table_context
>
>void*overdrive_table;
>void*boot_overdrive_table;
> + void*user_overdrive_table;
>
>uint32_tgpu_metrics_table_size;
>void*gpu_metrics_table;
> @@ -623,6 +625,12 @@ struct pptable_funcs {
> enum PP_OD_DPM_TABLE_COMMAND type,
> long *input, uint32_t size);
>
> + /**
> +  * @restore_user_od_settings: Restore the user customized
> +  *OD settings on S3/S4/Runpm resume.
> +  */
> + int (*restore_user_od_settings)(struct smu_context *smu);
> +
>/**
> * @get_clock_by_type_with_latency: Get the speed and latency of a 
> clock
> *  domain.
> diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> index 385b2ea5379c..1e42aafbb9fd 100644
> --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> @@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context
> *smu);
>
>   int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
>
> +int smu_v11_0_restore_user_od_settings(struct smu_context *smu);
> +
>   #endif
>   #endif
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index ebe672142808..8ca7337ea5fc 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -416,6 +416,15 @@ static void smu_restore_dpm_user_profile(struct 
> smu_context *smu)
>}
>}
>
> + /* Restore user customized OD settings */
> + if (smu->user_dpm_profile.user_od) {
> +

RE: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-23 Thread Chen, Guchun
[Public]

Just curious that in the patch, it adds a variable *user_od* serving the check 
of applying user customized OD setting. Instead of this, does it make sense to 
use the *flag* in struct smu_user_dpm_profile for this? As we have below bit in 
pm/inc/amdgpu_smu.h, can we add another bit for OD restore? This will help 
unify the usage of *flag* in SMU.

#define SMU_DPM_USER_PROFILE_RESTORE (1 << 0)

Regards,
Guchun

-Original Message-
From: amd-gfx  On Behalf Of Lazar, Lijo
Sent: Friday, July 23, 2021 6:09 PM
To: Quan, Evan ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x

The series looks good to me, though I prefer to use a common logic to restore 
od settings so that smuv12,smuv13 gets the restore feature by default once they 
add the user table logic. Don't have strong argument for it unless Alex, 
Kenneth or others have some comments.

Anyway, the series is
Reviewed-by: Lijo Lazar 

On 7/23/2021 2:39 PM, Evan Quan wrote:
> The customized OD settings can be divided into two parts: those 
> committed ones and non-committed ones.
>- For those changes which had been fed to SMU before S3/S4/Runpm
>  suspend kicked, they are committed changes. They should be properly
>  restored and fed to SMU on S3/S4/Runpm resume.
>- For those non-committed changes, they are restored only without feeding
>  to SMU.
> 
> Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
> Signed-off-by: Evan Quan 
> --
> v1->v2
>- better naming and logic revised for checking OD setting 
> update(Lijo)
> ---
>   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
>   drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
>   .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
>   .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
>   5 files changed, 82 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
> b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> index 3e89852e4820..c2c201b8e3cf 100644
> --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> @@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
>   uint32_t power_limit;
>   uint32_t fan_speed_percent;
>   uint32_t flags;
> + uint32_t user_od;
>   
>   /* user clock state information */
>   uint32_t clk_mask[SMU_CLK_COUNT];
> @@ -352,6 +353,7 @@ struct smu_table_context
>   
>   void*overdrive_table;
>   void*boot_overdrive_table;
> + void*user_overdrive_table;
>   
>   uint32_tgpu_metrics_table_size;
>   void*gpu_metrics_table;
> @@ -623,6 +625,12 @@ struct pptable_funcs {
>enum PP_OD_DPM_TABLE_COMMAND type,
>long *input, uint32_t size);
>   
> + /**
> +  * @restore_user_od_settings: Restore the user customized
> +  *OD settings on S3/S4/Runpm resume.
> +  */
> + int (*restore_user_od_settings)(struct smu_context *smu);
> +
>   /**
>* @get_clock_by_type_with_latency: Get the speed and latency of a clock
>*  domain.
> diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
> b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> index 385b2ea5379c..1e42aafbb9fd 100644
> --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> @@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context 
> *smu);
>   
>   int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
>   
> +int smu_v11_0_restore_user_od_settings(struct smu_context *smu);
> +
>   #endif
>   #endif
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index ebe672142808..8ca7337ea5fc 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -416,6 +416,15 @@ static void smu_restore_dpm_user_profile(struct 
> smu_context *smu)
>   }
>   }
>   
> + /* Restore user customized OD settings */
> + if (smu->user_dpm_profile.user_od) {
> + if (smu->ppt_funcs->restore_user_od_settings) {
> + ret = smu->ppt_funcs->restore_user_od_settings(smu);
> + if (ret)
> + dev_err(smu->adev->dev, "Failed to upload 
> customized OD settings\n");
> + 

Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-23 Thread Deucher, Alexander
[AMD Official Use Only]

I haven't had a chance to look at the patches too closely, but if it could be 
done in a generic may, that makes sense to me.  Maybe as a follow up patch?

Alex


From: Lazar, Lijo 
Sent: Friday, July 23, 2021 6:09 AM
To: Quan, Evan ; amd-gfx@lists.freedesktop.org 

Cc: Deucher, Alexander 
Subject: Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings 
properly for NV1x

The series looks good to me, though I prefer to use a common logic to
restore od settings so that smuv12,smuv13 gets the restore feature by
default once they add the user table logic. Don't have strong argument
for it unless Alex, Kenneth or others have some comments.

Anyway, the series is
Reviewed-by: Lijo Lazar 

On 7/23/2021 2:39 PM, Evan Quan wrote:
> The customized OD settings can be divided into two parts: those
> committed ones and non-committed ones.
>- For those changes which had been fed to SMU before S3/S4/Runpm
>  suspend kicked, they are committed changes. They should be properly
>  restored and fed to SMU on S3/S4/Runpm resume.
>- For those non-committed changes, they are restored only without feeding
>  to SMU.
>
> Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
> Signed-off-by: Evan Quan 
> --
> v1->v2
>- better naming and logic revised for checking OD setting update(Lijo)
> ---
>   drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
>   drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
>   .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
>   .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
>   5 files changed, 82 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
> b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> index 3e89852e4820..c2c201b8e3cf 100644
> --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
> @@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
>uint32_t power_limit;
>uint32_t fan_speed_percent;
>uint32_t flags;
> + uint32_t user_od;
>
>/* user clock state information */
>uint32_t clk_mask[SMU_CLK_COUNT];
> @@ -352,6 +353,7 @@ struct smu_table_context
>
>void*overdrive_table;
>void*boot_overdrive_table;
> + void*user_overdrive_table;
>
>uint32_tgpu_metrics_table_size;
>void*gpu_metrics_table;
> @@ -623,6 +625,12 @@ struct pptable_funcs {
> enum PP_OD_DPM_TABLE_COMMAND type,
> long *input, uint32_t size);
>
> + /**
> +  * @restore_user_od_settings: Restore the user customized
> +  *OD settings on S3/S4/Runpm resume.
> +  */
> + int (*restore_user_od_settings)(struct smu_context *smu);
> +
>/**
> * @get_clock_by_type_with_latency: Get the speed and latency of a 
> clock
> *  domain.
> diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
> b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> index 385b2ea5379c..1e42aafbb9fd 100644
> --- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> +++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
> @@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context *smu);
>
>   int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
>
> +int smu_v11_0_restore_user_od_settings(struct smu_context *smu);
> +
>   #endif
>   #endif
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
> b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index ebe672142808..8ca7337ea5fc 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -416,6 +416,15 @@ static void smu_restore_dpm_user_profile(struct 
> smu_context *smu)
>}
>}
>
> + /* Restore user customized OD settings */
> + if (smu->user_dpm_profile.user_od) {
> + if (smu->ppt_funcs->restore_user_od_settings) {
> + ret = smu->ppt_funcs->restore_user_od_settings(smu);
> + if (ret)
> + dev_err(smu->adev->dev, "Failed to upload 
> customized OD settings\n");
> + }
> + }
> +
>/* Disable restore flag */
>smu->user_dpm_profile.flags &= ~SMU_DPM_USER_PROFILE_RESTORE;
>   }
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_

Re: [PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-23 Thread Lazar, Lijo
The series looks good to me, though I prefer to use a common logic to 
restore od settings so that smuv12,smuv13 gets the restore feature by 
default once they add the user table logic. Don't have strong argument 
for it unless Alex, Kenneth or others have some comments.


Anyway, the series is
Reviewed-by: Lijo Lazar 

On 7/23/2021 2:39 PM, Evan Quan wrote:

The customized OD settings can be divided into two parts: those
committed ones and non-committed ones.
   - For those changes which had been fed to SMU before S3/S4/Runpm
 suspend kicked, they are committed changes. They should be properly
 restored and fed to SMU on S3/S4/Runpm resume.
   - For those non-committed changes, they are restored only without feeding
 to SMU.

Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
Signed-off-by: Evan Quan 
--
v1->v2
   - better naming and logic revised for checking OD setting update(Lijo)
---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
  drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
  .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
  .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
  5 files changed, 82 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index 3e89852e4820..c2c201b8e3cf 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
@@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
uint32_t power_limit;
uint32_t fan_speed_percent;
uint32_t flags;
+   uint32_t user_od;
  
  	/* user clock state information */

uint32_t clk_mask[SMU_CLK_COUNT];
@@ -352,6 +353,7 @@ struct smu_table_context
  
  	void*overdrive_table;

void*boot_overdrive_table;
+   void*user_overdrive_table;
  
  	uint32_t			gpu_metrics_table_size;

void*gpu_metrics_table;
@@ -623,6 +625,12 @@ struct pptable_funcs {
 enum PP_OD_DPM_TABLE_COMMAND type,
 long *input, uint32_t size);
  
+	/**

+* @restore_user_od_settings: Restore the user customized
+*OD settings on S3/S4/Runpm resume.
+*/
+   int (*restore_user_od_settings)(struct smu_context *smu);
+
/**
 * @get_clock_by_type_with_latency: Get the speed and latency of a clock
 *  domain.
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 385b2ea5379c..1e42aafbb9fd 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context *smu);
  
  int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
  
+int smu_v11_0_restore_user_od_settings(struct smu_context *smu);

+
  #endif
  #endif
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index ebe672142808..8ca7337ea5fc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -416,6 +416,15 @@ static void smu_restore_dpm_user_profile(struct 
smu_context *smu)
}
}
  
+	/* Restore user customized OD settings */

+   if (smu->user_dpm_profile.user_od) {
+   if (smu->ppt_funcs->restore_user_od_settings) {
+   ret = smu->ppt_funcs->restore_user_od_settings(smu);
+   if (ret)
+   dev_err(smu->adev->dev, "Failed to upload customized 
OD settings\n");
+   }
+   }
+
/* Disable restore flag */
smu->user_dpm_profile.flags &= ~SMU_DPM_USER_PROFILE_RESTORE;
  }
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index 59ea59acfb00..d7722c229ddd 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -2294,41 +2294,52 @@ static int navi10_set_default_od_settings(struct 
smu_context *smu)
(OverDriveTable_t *)smu->smu_table.overdrive_table;
OverDriveTable_t *boot_od_table =
(OverDriveTable_t *)smu->smu_table.boot_overdrive_table;
+   OverDriveTable_t *user_od_table =
+   (OverDriveTable_t *)smu->smu_table.user_overdrive_table;
int ret = 0;
  
-	ret = smu_cmn_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void *)od_table, false);

+   /*
+* For S3/S4/Runpm resume, no need to setup those overdrive tables 
again as
+*   - either they already have the default OD settings got during cold 
bootup
+*   - or they have some user customized OD settings which cannot be 
overwritten
+*/
+   if 

[PATCH V2 1/2] drm/amd/pm: restore user customized OD settings properly for NV1x

2021-07-23 Thread Evan Quan
The customized OD settings can be divided into two parts: those
committed ones and non-committed ones.
  - For those changes which had been fed to SMU before S3/S4/Runpm
suspend kicked, they are committed changes. They should be properly
restored and fed to SMU on S3/S4/Runpm resume.
  - For those non-committed changes, they are restored only without feeding
to SMU.

Change-Id: Iea7cf7908dfcd919a4d0205e10bff91b1149a440
Signed-off-by: Evan Quan 
--
v1->v2
  - better naming and logic revised for checking OD setting update(Lijo)
---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  8 +++
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c |  9 +++
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 55 +--
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 25 +
 5 files changed, 82 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index 3e89852e4820..c2c201b8e3cf 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
@@ -231,6 +231,7 @@ struct smu_user_dpm_profile {
uint32_t power_limit;
uint32_t fan_speed_percent;
uint32_t flags;
+   uint32_t user_od;
 
/* user clock state information */
uint32_t clk_mask[SMU_CLK_COUNT];
@@ -352,6 +353,7 @@ struct smu_table_context
 
void*overdrive_table;
void*boot_overdrive_table;
+   void*user_overdrive_table;
 
uint32_tgpu_metrics_table_size;
void*gpu_metrics_table;
@@ -623,6 +625,12 @@ struct pptable_funcs {
 enum PP_OD_DPM_TABLE_COMMAND type,
 long *input, uint32_t size);
 
+   /**
+* @restore_user_od_settings: Restore the user customized
+*OD settings on S3/S4/Runpm resume.
+*/
+   int (*restore_user_od_settings)(struct smu_context *smu);
+
/**
 * @get_clock_by_type_with_latency: Get the speed and latency of a clock
 *  domain.
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 385b2ea5379c..1e42aafbb9fd 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -302,5 +302,7 @@ void smu_v11_0_interrupt_work(struct smu_context *smu);
 
 int smu_v11_0_set_light_sbr(struct smu_context *smu, bool enable);
 
+int smu_v11_0_restore_user_od_settings(struct smu_context *smu);
+
 #endif
 #endif
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index ebe672142808..8ca7337ea5fc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -416,6 +416,15 @@ static void smu_restore_dpm_user_profile(struct 
smu_context *smu)
}
}
 
+   /* Restore user customized OD settings */
+   if (smu->user_dpm_profile.user_od) {
+   if (smu->ppt_funcs->restore_user_od_settings) {
+   ret = smu->ppt_funcs->restore_user_od_settings(smu);
+   if (ret)
+   dev_err(smu->adev->dev, "Failed to upload 
customized OD settings\n");
+   }
+   }
+
/* Disable restore flag */
smu->user_dpm_profile.flags &= ~SMU_DPM_USER_PROFILE_RESTORE;
 }
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index 59ea59acfb00..d7722c229ddd 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -2294,41 +2294,52 @@ static int navi10_set_default_od_settings(struct 
smu_context *smu)
(OverDriveTable_t *)smu->smu_table.overdrive_table;
OverDriveTable_t *boot_od_table =
(OverDriveTable_t *)smu->smu_table.boot_overdrive_table;
+   OverDriveTable_t *user_od_table =
+   (OverDriveTable_t *)smu->smu_table.user_overdrive_table;
int ret = 0;
 
-   ret = smu_cmn_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void 
*)od_table, false);
+   /*
+* For S3/S4/Runpm resume, no need to setup those overdrive tables 
again as
+*   - either they already have the default OD settings got during cold 
bootup
+*   - or they have some user customized OD settings which cannot be 
overwritten
+*/
+   if (smu->adev->in_suspend)
+   return 0;
+
+   ret = smu_cmn_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void 
*)boot_od_table, false);
if (ret) {
dev_err(smu->adev->dev, "Failed to get overdrive table!\n");
return ret;
}
 
-   if (!od_table->GfxclkVolt1) {
+