AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Coffin <mcoffin13@gmail.com>
To: Alex Deucher <alexdeucher@gmail.com>, amd-gfx@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>
Subject: Re: [PATCH 3/3] drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2)
Date: Thu, 30 Jan 2020 13:50:14 -0700	[thread overview]
Message-ID: <0dadb477-f12a-4b84-c856-240a89690901@gmail.com> (raw)
In-Reply-To: <20200129181752.609344-3-alexander.deucher@amd.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 5298 bytes --]

It's worth noting here that I don't have a vega20 card to test with, so
it might be prudent to get a Tested-by from someone that has access to one.

It *should* work since it's so similar to the navi10 code, but it is
moderately un-tested.

On 1/29/20 11:17 AM, Alex Deucher wrote:
> From: Matt Coffin <mcoffin13@gmail.com>
> 
> Previously, the syfs functionality for restoring the default powerplay
> table was sourcing it's information from the currently-staged powerplay
> table.
> 
> This patch adds a step to cache the first overdrive table that we see on
> boot, so that it can be used later to "restore" the powerplay table
> 
> v2: sqaush my original with Matt's fix
> 
> Bug: https://gitlab.freedesktop.org/drm/amd/issues/1020
> Signed-off-by: Matt Coffin <mcoffin13@gmail.com>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  1 +
>  drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  7 +++++
>  drivers/gpu/drm/amd/powerplay/smu_v11_0.c     |  6 ++++
>  drivers/gpu/drm/amd/powerplay/vega20_ppt.c    | 28 ++++++-------------
>  4 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> index b0591a8dda41..1e33c3e9b98d 100644
> --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> @@ -273,6 +273,7 @@ struct smu_table_context
>  	uint8_t                         thermal_controller_type;
>  
>  	void				*overdrive_table;
> +	void                            *boot_overdrive_table;
>  };
>  
>  struct smu_dpm_context {
> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index d2d45181ae23..26cfccc57331 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -2063,6 +2063,13 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
>  			return ret;
>  		od_table->UclkFmax = input[1];
>  		break;
> +	case PP_OD_RESTORE_DEFAULT_TABLE:
> +		if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) {
> +			pr_err("Overdrive table was not initialized!\n");
> +			return -EINVAL;
> +		}
> +		memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t));
> +		break;
>  	case PP_OD_COMMIT_DPM_TABLE:
>  		navi10_dump_od_table(od_table);
>  		ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void *)od_table, true);
> diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> index 02f8c9cb89d9..0dc49479a7eb 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -1882,6 +1882,12 @@ int smu_v11_0_set_default_od_settings(struct smu_context *smu, bool initialize,
>  			pr_err("Failed to export overdrive table!\n");
>  			return ret;
>  		}
> +		if (!table_context->boot_overdrive_table) {
> +			table_context->boot_overdrive_table = kmemdup(table_context->overdrive_table, overdrive_table_size, GFP_KERNEL);
> +			if (!table_context->boot_overdrive_table) {
> +				return -ENOMEM;
> +			}
> +		}
>  	}
>  	ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, true);
>  	if (ret) {
> diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> index 38febd5ca4da..4ad8d6c14ee5 100644
> --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> @@ -1706,22 +1706,11 @@ static int vega20_set_default_od_settings(struct smu_context *smu,
>  	struct smu_table_context *table_context = &smu->smu_table;
>  	int ret;
>  
> -	if (initialize) {
> -		if (table_context->overdrive_table)
> -			return -EINVAL;
> -
> -		table_context->overdrive_table = kzalloc(sizeof(OverDriveTable_t), GFP_KERNEL);
> -
> -		if (!table_context->overdrive_table)
> -			return -ENOMEM;
> -
> -		ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
> -				       table_context->overdrive_table, false);
> -		if (ret) {
> -			pr_err("Failed to export over drive table!\n");
> -			return ret;
> -		}
> +	ret = smu_v11_0_set_default_od_settings(smu, initialize, sizeof(OverDriveTable_t));
> +	if (ret)
> +		return ret;
>  
> +	if (initialize) {
>  		ret = vega20_set_default_od8_setttings(smu);
>  		if (ret)
>  			return ret;
> @@ -2778,12 +2767,11 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu,
>  		break;
>  
>  	case PP_OD_RESTORE_DEFAULT_TABLE:
> -		ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
> -		if (ret) {
> -			pr_err("Failed to export over drive table!\n");
> -			return ret;
> +		if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) {
> +			pr_err("Overdrive table was not initialized!\n");
> +			return -EINVAL;
>  		}
> -
> +		memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t));
>  		break;
>  
>  	case PP_OD_COMMIT_DPM_TABLE:
> 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2020-01-30 20:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 18:17 [PATCH 1/3] drm/amdgpu/navi: fix index for OD MCLK Alex Deucher
2020-01-29 18:17 ` [PATCH 2/3] drm/amdgpu/navi10: add OD_RANGE for navi overclocking Alex Deucher
2020-02-03  3:18   ` Quan, Evan
2020-01-29 18:17 ` [PATCH 3/3] drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2) Alex Deucher
2020-01-30 20:50   ` Matt Coffin [this message]
2020-02-03  3:18 ` [PATCH 1/3] drm/amdgpu/navi: fix index for OD MCLK Quan, Evan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0dadb477-f12a-4b84-c856-240a89690901@gmail.com \
    --to=mcoffin13@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox