drm/amd/powerplay: bypass dpm_context null pointer check guard for some smu series
Subsystems (2)
PATCH 1/5 drm/amd/powerplay: bypass dpm_context null pointer check guard for some smu series
For now APU has no smu_dpm_context structure for containing default/current related dpm table, thus will not initialize smu_dpm_context and aviod null pointer check guard for APU.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +7 -3
@@ -1554,7 +1554,9 @@ static int smu_enable_umd_pstate(void *handle,struct smu_context *smu = (struct smu_context *)(handle);struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -if (!smu->pm_enabled || !smu_dpm_ctx->dpm_context) +struct amdgpu_device *adev = smu->adev; + +if (!(adev->flags &AMD_IS_APU ) && (!smu->pm_enabled || !smu_dpm_ctx->dpm_context))return -EINVAL ;if (!(smu_dpm_ctx->dpm_level & profile_mode_mask)) {
@@ -1751,8 +1753,9 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu) {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);enum amd_dpm_forced_level level; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ;mutex_lock (&(smu->mutex));
@@ -1766,8 +1769,9 @@ int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_lev {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);int ret =0 ; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ; ret =smu_enable_umd_pstate (smu, &level);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1569228167-3120-1-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org
PATCH 2/5 drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
That's base function for forcing and unforcing dpm limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +62 -0
@@ -304,6 +304,66 @@ static int renoir_dpm_set_uvd_enable(struct smu_context *smu, bool enable)return ret; } +static int renoir_force_dpm_limit_value (struct smu_context *smu,bool highest) +{ +int ret =0 , i =0 ; +uint32_t min_freq, max_freq, force_freq; +enum smu_clk_type clk_type; + +enum smu_clk_type clks[] = { +SMU_GFXCLK , +SMU_MCLK , +SMU_SOCCLK , + }; + +for (i =0 ; i <ARRAY_SIZE (clks); i++) { + clk_type = clks[i]; + ret =smu_get_dpm_freq_range (smu, clk_type, &min_freq, &max_freq); +if (ret) +return ret; + + force_freq = highest ? max_freq : min_freq; + ret =smu_set_soft_freq_range (smu, clk_type, force_freq, force_freq); +if (ret) +return ret; + } + +return ret; +} + +static int renoir_unforce_dpm_levels (struct smu_context *smu) { + +int ret =0 , i =0 ; +uint32_t min_freq, max_freq; +enum smu_clk_type clk_type; + +struct clk_feature_map { +enum smu_clk_type clk_type; +uint32_t feature; + } clk_feature_map[] = { + {SMU_GFXCLK ,SMU_FEATURE_DPM_GFXCLK_BIT }, + {SMU_MCLK ,SMU_FEATURE_DPM_UCLK_BIT }, + {SMU_SOCCLK ,SMU_FEATURE_DPM_SOCCLK_BIT }, + }; + +for (i =0 ; i <ARRAY_SIZE (clk_feature_map); i++) { +if (!smu_feature_is_enabled (smu, clk_feature_map[i].feature)) +continue ; + + clk_type = clk_feature_map[i].clk_type; + + ret =smu_get_dpm_freq_range (smu, clk_type, &min_freq, &max_freq); +if (ret) +return ret; + + ret =smu_set_soft_freq_range (smu, clk_type, min_freq, max_freq); +if (ret) +return ret; + } + +return ret; +} +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -313,6 +373,8 @@ static const struct pptable_funcs renoir_ppt_funcs = { .print_clk_levels = renoir_print_clk_levels, .get_current_power_state = renoir_get_current_power_state, .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable, + .force_dpm_limit_value = renoir_force_dpm_limit_value, + .unforce_dpm_levels = renoir_unforce_dpm_levels, };void renoir_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1569228167-3120-2-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Huang, Ray <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
That's base function for forcing and unforcing dpm limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +20 -0
@@ -304,6 +304,66 @@ static int renoir_dpm_set_uvd_enable(struct smu_context *smu, bool enable)return ret; } +static int renoir_force_dpm_limit_value (struct smu_context *smu,bool highest) +{ +int ret =0 , i =0 ; +uint32_t min_freq, max_freq, force_freq; +enum smu_clk_type clk_type; + +enum smu_clk_type clks[] = { +SMU_GFXCLK , +SMU_MCLK , +SMU_SOCCLK , + }; + +for (i =0 ; i <ARRAY_SIZE (clks); i++) { + clk_type = clks[i]; + ret =smu_get_dpm_freq_range (smu, clk_type, &min_freq, &max_freq); +if (ret) +return ret; + + force_freq = highest ? max_freq : min_freq; + ret =smu_set_soft_freq_range (smu, clk_type, force_freq, force_freq);
[kevin]:
this api is depend on message "SetSoftMaxByFreq" and "SetSoftMinByFreq". the apu has this message? and have you verify it?
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
+static int renoir_unforce_dpm_levels(struct smu_context *smu) { +
+ int ret = 0, i = 0; + uint32_t min_freq, max_freq; + enum smu_clk_type clk_type;
+
+ struct clk_feature_map {
+ enum smu_clk_type clk_type;
+ uint32_t feature;
+ } clk_feature_map[] = {
+ {SMU_GFXCLK, SMU_FEATURE_DPM_GFXCLK_BIT},
+ {SMU_MCLK, SMU_FEATURE_DPM_UCLK_BIT},
+ {SMU_SOCCLK, SMU_FEATURE_DPM_SOCCLK_BIT},+ };
+
+ for (i = 0; i < ARRAY_SIZE(clk_feature_map); i++) {
+ if (!smu_feature_is_enabled(smu, clk_feature_map[i].feature))
+ continue;
+
+ clk_type = clk_feature_map[i].clk_type;
+
+ ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq);
+ if (ret)
+ return ret;
+
+ ret = smu_set_soft_freq_range(smu, clk_type, min_freq, max_freq);
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -313,6 +373,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.print_clk_levels = renoir_print_clk_levels, .get_current_power_state = renoir_get_current_power_state, .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable,
+ .force_dpm_limit_value = renoir_force_dpm_limit_value,
+ .unforce_dpm_levels = renoir_unforce_dpm_levels,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3296B07D1B1FD00D1817E2B7A2850-rweVpJHSKTqAm9ToKNQgFgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
From: Wang, Kevin(Yang) <[email protected]>
Sent: Monday, September 23, 2019 5:25 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: [email protected]; Huang, Ray <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Huang, Ray <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>; Quan, Evan <[email protected]<mailto:[email protected]>>; Feng, Kenneth <[email protected]<mailto:[email protected]>>
Subject: [PATCH 2/5] drm/amd/powerplay: add interface for forcing and unforcing dpm limit value
That's base function for forcing and unforcing dpm limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +20 -0
@@ -304,6 +304,66 @@ static int renoir_dpm_set_uvd_enable(struct smu_context *smu, bool enable)return ret; } +static int renoir_force_dpm_limit_value (struct smu_context *smu,bool highest) +{ +int ret =0 , i =0 ; +uint32_t min_freq, max_freq, force_freq; +enum smu_clk_type clk_type; + +enum smu_clk_type clks[] = { +SMU_GFXCLK , +SMU_MCLK , +SMU_SOCCLK , + }; + +for (i =0 ; i <ARRAY_SIZE (clks); i++) { + clk_type = clks[i]; + ret =smu_get_dpm_freq_range (smu, clk_type, &min_freq, &max_freq); +if (ret) +return ret; + + force_freq = highest ? max_freq : min_freq; + ret =smu_set_soft_freq_range (smu, clk_type, force_freq, force_freq);
[kevin]:
this api is depend on message "SetSoftMaxByFreq" and "SetSoftMinByFreq".
the apu has this message? and have you verify it?
[Prike]:
Seems APU hasn't export the message and need send the related clock such as PPSMC_MSG_SetSoftMaxGfxClk for this case.
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
+static int renoir_unforce_dpm_levels(struct smu_context *smu) {
+
+ int ret = 0, i = 0; + uint32_t min_freq, max_freq; + enum smu_clk_type clk_type;
+
+ struct clk_feature_map {
+ enum smu_clk_type clk_type;
+ uint32_t feature;
+ } clk_feature_map[] = {
+ {SMU_GFXCLK, SMU_FEATURE_DPM_GFXCLK_BIT},
+ {SMU_MCLK, SMU_FEATURE_DPM_UCLK_BIT},
+ {SMU_SOCCLK, SMU_FEATURE_DPM_SOCCLK_BIT},+ };
+
+ for (i = 0; i < ARRAY_SIZE(clk_feature_map); i++) {
+ if (!smu_feature_is_enabled(smu, clk_feature_map[i].feature))
+ continue;
+
+ clk_type = clk_feature_map[i].clk_type;
+
+ ret = smu_get_dpm_freq_range(smu, clk_type, &min_freq, &max_freq);
+ if (ret)
+ return ret;
+
+ ret = smu_set_soft_freq_range(smu, clk_type, min_freq, max_freq);
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -313,6 +373,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.print_clk_levels = renoir_print_clk_levels, .get_current_power_state = renoir_get_current_power_state, .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable,
+ .force_dpm_limit_value = renoir_force_dpm_limit_value,
+ .unforce_dpm_levels = renoir_unforce_dpm_levels,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/5 drm/amd/powerplay: add interface for getting workload type
In reply to a message not in the archiveThe workload type was got from the input of power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +29 -0
@@ -364,6 +364,34 @@ static int renoir_unforce_dpm_levels(struct smu_context *smu) {return ret; } +static int renoir_get_workload_type (struct smu_context *smu,uint32_t profile) +{ + +uint32_t pplib_workload =0 ; + +switch (profile) { +case PP_SMC_POWER_PROFILE_FULLSCREEN3D : + pplib_workload =WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT ; +break ; +case PP_SMC_POWER_PROFILE_CUSTOM : + pplib_workload =WORKLOAD_PPLIB_COUNT ; +break ; +case PP_SMC_POWER_PROFILE_VIDEO : + pplib_workload =WORKLOAD_PPLIB_VIDEO_BIT ; +break ; +case PP_SMC_POWER_PROFILE_VR : + pplib_workload =WORKLOAD_PPLIB_VR_BIT ; +break ; +case PP_SMC_POWER_PROFILE_COMPUTE : + pplib_workload =WORKLOAD_PPLIB_COMPUTE_BIT ; +break ; +default : +return -EINVAL ; + } + +return pplib_workload; +} +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -375,6 +403,7 @@ static const struct pptable_funcs renoir_ppt_funcs = { .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable, .force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels, + .get_workload_type = renoir_get_workload_type, };void renoir_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1569228167-3120-3-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org
Wang, Kevin(Yang)
Reviewed-byRe: [PATCH 3/5] drm/amd/powerplay: add interface for getting workload type
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Huang, Ray <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 3/5] drm/amd/powerplay: add interface for getting workload type
The workload type was got from the input of power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +29 -0
@@ -364,6 +364,34 @@ static int renoir_unforce_dpm_levels(struct smu_context *smu) {return ret; } +static int renoir_get_workload_type (struct smu_context *smu,uint32_t profile) +{ + +uint32_t pplib_workload =0 ; + +switch (profile) { +case PP_SMC_POWER_PROFILE_FULLSCREEN3D : + pplib_workload =WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT ; +break ; +case PP_SMC_POWER_PROFILE_CUSTOM : + pplib_workload =WORKLOAD_PPLIB_COUNT ; +break ; +case PP_SMC_POWER_PROFILE_VIDEO : + pplib_workload =WORKLOAD_PPLIB_VIDEO_BIT ; +break ; +case PP_SMC_POWER_PROFILE_VR : + pplib_workload =WORKLOAD_PPLIB_VR_BIT ; +break ; +case PP_SMC_POWER_PROFILE_COMPUTE : + pplib_workload =WORKLOAD_PPLIB_COMPUTE_BIT ; +break ; +default : +return -EINVAL ; + } + +return pplib_workload; +} +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -375,6 +403,7 @@ static const struct pptable_funcs renoir_ppt_funcs = { .dpm_set_uvd_enable = renoir_dpm_set_uvd_enable, .force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels, + .get_workload_type = renoir_get_workload_type, };void renoir_set_ppt_funcs (struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 3/5] drm/amd/powerplay: add interface for getting workload type
In reply to a message not in the archivePatch 1- 3 are reviewed-by: Evan Quan <[email protected]>
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Huang, Ray <[email protected]>; [email protected]; Liang, Prike <[email protected]>
Subject: [PATCH 3/5] drm/amd/powerplay: add interface for getting workload type
The workload type was got from the input of power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +28 -0
@@ -364,6 +364,34 @@ static int renoir_unforce_dpm_levels(struct smu_context *smu) {return ret; } +static int renoir_get_workload_type (struct smu_context *smu,uint32_t +profile) { + +uint32_t pplib_workload =0 ; + +switch (profile) { +case PP_SMC_POWER_PROFILE_FULLSCREEN3D : + pplib_workload =WORKLOAD_PPLIB_FULL_SCREEN_3D_BIT ; +break ; +case PP_SMC_POWER_PROFILE_CUSTOM : + pplib_workload =WORKLOAD_PPLIB_COUNT ; +break ; +case PP_SMC_POWER_PROFILE_VIDEO : + pplib_workload =WORKLOAD_PPLIB_VIDEO_BIT ; +break ; +case PP_SMC_POWER_PROFILE_VR : + pplib_workload =WORKLOAD_PPLIB_VR_BIT ; +break ; +case PP_SMC_POWER_PROFILE_COMPUTE : + pplib_workload =WORKLOAD_PPLIB_COMPUTE_BIT ; +break ; +default : +return -EINVAL ; + } + +return pplib_workload; +} + static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index, @@ -375,6 +403,7 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.dpm_set_uvd_enable = renoir_dpm_set_uvd_enable, .force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels,
+ .get_workload_type = renoir_get_workload_type,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/5 drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
In reply to a message not in the archiveimplement get_profiling_clk_mask and force_clk_levels for forcing dpm clk to limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +83 -0
@@ -392,6 +392,87 @@ static int renoir_get_workload_type(struct smu_context *smu, uint32_t profile)return pplib_workload; } +static int renoir_get_profiling_clk_mask (struct smu_context *smu, +enum amd_dpm_forced_level level, +uint32_t *sclk_mask, +uint32_t *mclk_mask, +uint32_t *soc_mask) +{ + +if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { +if (sclk_mask) + *sclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { +if (mclk_mask) + *mclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { +if (sclk_mask) +/* The sclk as gfxclk and has three level about max/min/current */ + *sclk_mask =3 -1 ; + +if (mclk_mask) + *mclk_mask =NUM_MEMCLK_DPM_LEVELS -1 ; + +if (soc_mask) + *soc_mask =NUM_SOCCLK_DPM_LEVELS -1 ; + } + +return 0 ; +} + +static int renoir_force_clk_levels (struct smu_context *smu, +enum smu_clk_type clk_type,uint32_t mask) +{ + +int ret =0 ; +uint32_t soft_min_level =0 , soft_max_level =0 , min_freq =0 , max_freq =0 ; +DpmClocks_t *clk_table = smu->smu_table.clocks_table; + + soft_min_level = mask ? (ffs (mask) -1 ) :0 ; + soft_max_level = mask ? (fls (mask) -1 ) :0 ; + +switch (clk_type) { +case SMU_GFXCLK : +case SMU_SCLK : + ret =smu_get_dpm_freq_range (smu,SMU_GFXCLK , &min_freq, &max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxGfxClk, max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinGfxClk, min_freq); +if (ret) +return ret; +break ; +case SMU_SOCCLK : +GET_DPM_CUR_FREQ (clk_table, clk_type, soft_min_level, min_freq); +GET_DPM_CUR_FREQ (clk_table, clk_type, soft_max_level, max_freq); + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxSocclkByFreq, max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinSocclkByFreq, min_freq); +if (ret) +return ret; +break ; +case SMU_MCLK : +case SMU_FCLK : +GET_DPM_CUR_FREQ (clk_table, clk_type, soft_min_level, min_freq); +GET_DPM_CUR_FREQ (clk_table, clk_type, soft_max_level, max_freq); + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxFclkByFreq, max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinFclkByFreq, min_freq); +if (ret) +return ret; + +break ; +default : +break ; + } + +return ret; +} +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -404,6 +485,8 @@ static const struct pptable_funcs renoir_ppt_funcs = { .force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels, .get_workload_type = renoir_get_workload_type, + .get_profiling_clk_mask = renoir_get_profiling_clk_mask, + .force_clk_levels = renoir_force_clk_levels, };void renoir_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1569228167-3120-4-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org
Wang, Kevin(Yang)
Reviewed-byRe: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Huang, Ray <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
implement get_profiling_clk_mask and force_clk_levels for forcing dpm clk to limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +17 -0
@@ -392,6 +392,87 @@ static int renoir_get_workload_type(struct smu_context *smu, uint32_t profile)return pplib_workload; } +static int renoir_get_profiling_clk_mask (struct smu_context *smu, +enum amd_dpm_forced_level level, +uint32_t *sclk_mask, +uint32_t *mclk_mask, +uint32_t *soc_mask) +{ + +if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { +if (sclk_mask) + *sclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { +if (mclk_mask) + *mclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { +if (sclk_mask) +/* The sclk as gfxclk and has three level about max/min/current */ + *sclk_mask =3 -1 ;
[kevin]:
you should return the max level not current level. +
+ if(mclk_mask)
+ *mclk_mask = NUM_MEMCLK_DPM_LEVELS - 1;
+
+ if(soc_mask)
+ *soc_mask = NUM_SOCCLK_DPM_LEVELS - 1;
+ }
+
+ return 0;
+}
+
+static int renoir_force_clk_levels(struct smu_context *smu,
+ enum smu_clk_type clk_type, uint32_t mask)
+{
+
+ int ret = 0 ; + uint32_t soft_min_level = 0, soft_max_level = 0, min_freq = 0, max_freq = 0; + DpmClocks_t *clk_table = smu->smu_table.clocks_table;
+
+ soft_min_level = mask ? (ffs(mask) - 1) : 0;
+ soft_max_level = mask ? (fls(mask) - 1) : 0;
+
+ switch (clk_type) {
+ case SMU_GFXCLK:
+ case SMU_SCLK:+ ret = smu_get_dpm_freq_range(smu, SMU_GFXCLK, &min_freq, &max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk, max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk, min_freq);
+ if (ret)
+ return ret;
+ break;
+ case SMU_SOCCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq); + GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq); + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxSocclkByFreq, max_freq); + if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinSocclkByFreq, min_freq);
+ if (ret)
+ return ret;
+ break;
+ case SMU_MCLK:
+ case SMU_FCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq); + GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq); + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxFclkByFreq, max_freq); + if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinFclkByFreq, min_freq);
+ if (ret)
+ return ret;
+
[kevin]:
after remove this blank line,
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -404,6 +485,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels, .get_workload_type = renoir_get_workload_type,
+ .get_profiling_clk_mask = renoir_get_profiling_clk_mask,
+ .force_clk_levels = renoir_force_clk_levels,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3296355152137CECE6334B2FA2850-rweVpJHSKTqAm9ToKNQgFgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Liang, Prike
Reviewed-by Kevin WangRE: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
From: Wang, Kevin(Yang) <[email protected]>
Sent: Monday, September 23, 2019 5:29 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: [email protected]; Huang, Ray <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Huang, Ray <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>; Quan, Evan <[email protected]<mailto:[email protected]>>; Feng, Kenneth <[email protected]<mailto:[email protected]>>
Subject: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
implement get_profiling_clk_mask and force_clk_levels for forcing dpm clk to limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +17 -0
@@ -392,6 +392,87 @@ static int renoir_get_workload_type(struct smu_context *smu, uint32_t profile)return pplib_workload; } +static int renoir_get_profiling_clk_mask (struct smu_context *smu, +enum amd_dpm_forced_level level, +uint32_t *sclk_mask, +uint32_t *mclk_mask, +uint32_t *soc_mask) +{ + +if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { +if (sclk_mask) + *sclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { +if (mclk_mask) + *mclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { +if (sclk_mask) +/* The sclk as gfxclk and has three level about max/min/current */ + *sclk_mask =3 -1 ;
[kevin]:
you should return the max level not current level. [Prike] Yeah, the clause will return max dpm level index. +
+ if(mclk_mask)
+ *mclk_mask = NUM_MEMCLK_DPM_LEVELS - 1;
+
+ if(soc_mask)
+ *soc_mask = NUM_SOCCLK_DPM_LEVELS - 1;
+ }
+
+ return 0;
+}
+
+static int renoir_force_clk_levels(struct smu_context *smu,
+ enum smu_clk_type clk_type, uint32_t mask)
+{
+
+ int ret = 0 ; + uint32_t soft_min_level = 0, soft_max_level = 0, min_freq = 0, max_freq = 0; + DpmClocks_t *clk_table = smu->smu_table.clocks_table;
+
+ soft_min_level = mask ? (ffs(mask) - 1) : 0;
+ soft_max_level = mask ? (fls(mask) - 1) : 0;
+
+ switch (clk_type) {
+ case SMU_GFXCLK:
+ case SMU_SCLK:+ ret = smu_get_dpm_freq_range(smu, SMU_GFXCLK, &min_freq, &max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk, max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk, min_freq);
+ if (ret)
+ return ret;
+ break;
+ case SMU_SOCCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq); + GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq); + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxSocclkByFreq, max_freq); + if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinSocclkByFreq, min_freq);
+ if (ret)
+ return ret;
+ break;
+ case SMU_MCLK:
+ case SMU_FCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq); + GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq); + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxFclkByFreq, max_freq); + if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinFclkByFreq, min_freq);
+ if (ret)
+ return ret;
+
[kevin]:
after remove this blank line,
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -404,6 +485,8 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.force_dpm_limit_value = renoir_force_dpm_limit_value, .unforce_dpm_levels = renoir_unforce_dpm_levels, .get_workload_type = renoir_get_workload_type,
+ .get_profiling_clk_mask = renoir_get_profiling_clk_mask,
+ .force_clk_levels = renoir_force_clk_levels,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
In reply to a message not in the archive-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Huang, Ray <[email protected]>; [email protected]; Liang, Prike <[email protected]>
Subject: [PATCH 4/5] drm/amd/powerplay: add the interfaces for getting and setting profiling dpm clock level
implement get_profiling_clk_mask and force_clk_levels for forcing dpm clk to limit value.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +50 -0
@@ -392,6 +392,87 @@ static int renoir_get_workload_type(struct smu_context *smu, uint32_t profile)return pplib_workload; } +static int renoir_get_profiling_clk_mask (struct smu_context *smu, +enum amd_dpm_forced_level level, +uint32_t *sclk_mask, +uint32_t *mclk_mask, +uint32_t *soc_mask) +{ + +if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { +if (sclk_mask) + *sclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { +if (mclk_mask) + *mclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { +if (sclk_mask) +/* The sclk as gfxclk and has three level about max/min/current */ + *sclk_mask =3 -1 ; + +if (mclk_mask) + *mclk_mask =NUM_MEMCLK_DPM_LEVELS -1 ; + +if (soc_mask) + *soc_mask =NUM_SOCCLK_DPM_LEVELS -1 ; + } + +return 0 ; +} + +static int renoir_force_clk_levels (struct smu_context *smu, +enum smu_clk_type clk_type,uint32_t mask) { + +int ret =0 ; +uint32_t soft_min_level =0 , soft_max_level =0 , min_freq =0 , max_freq =0 ; +DpmClocks_t *clk_table = smu->smu_table.clocks_table; + + soft_min_level = mask ? (ffs (mask) -1 ) :0 ; + soft_max_level = mask ? (fls (mask) -1 ) :0 ; + +switch (clk_type) { +case SMU_GFXCLK : +case SMU_SCLK : + ret =smu_get_dpm_freq_range (smu,SMU_GFXCLK , &min_freq, &max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetSoftMaxGfxClk, max_freq); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetHardMinGfxClk, min_freq); +if (ret) +return ret;
[Quan, Evan] It seems user requested soft_min_level and soft_max_level are actually not applied.
Please verify this by setting " pp_dpm_sclk" sysfs interface.
+ break;
+ case SMU_SOCCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq);
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq);
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxSocclkByFreq, max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinSocclkByFreq, min_freq);
+ if (ret)
+ return ret;
+ break;
+ case SMU_MCLK:
+ case SMU_FCLK:
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_min_level, min_freq);
+ GET_DPM_CUR_FREQ(clk_table, clk_type, soft_max_level, max_freq);
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxFclkByFreq, max_freq);
+ if (ret)
+ return ret;
+ ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinFclkByFreq, min_freq);
+ if (ret)
+ return ret;
+
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index,
.get_smu_table_index = renoir_get_smu_table_index, @@ -404,6 +485,8 @@ static const struct pptable_funcs renoir_ppt_funcs = { .force_dpm_limit_value = renoir_force_dpm_limit_value,
.unforce_dpm_levels = renoir_unforce_dpm_levels,
.get_workload_type = renoir_get_workload_type,
+ .get_profiling_clk_mask = renoir_get_profiling_clk_mask,
+ .force_clk_levels = renoir_force_clk_levels,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/5 drm/amd/powerplay: implement interface set_power_profile_mode()
In reply to a message not in the archiveAdd set_power_profile_mode() for none manual dpm level case setting power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +25 -0
@@ -473,6 +473,30 @@ static int renoir_force_clk_levels(struct smu_context *smu,return ret; } +static int renoir_set_power_profile_mode (struct smu_context *smu,long *input,uint32_t size) +{ +int workload_type; + + smu->power_profile_mode = input[size]; + +if (smu->power_profile_mode >PP_SMC_POWER_PROFILE_CUSTOM ) { +pr_err ("Invalid power profile mode %d\n" , smu->power_profile_mode); +return -EINVAL ; + } + +if (smu->power_profile_mode ==PP_SMC_POWER_PROFILE_CUSTOM ) { +if (size <0 ) +return -EINVAL ; + +/* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ + workload_type =smu_workload_get_type (smu, smu->power_profile_mode); +smu_send_smc_msg_with_param (smu, SMU_MSG_SetWorkloadMask, +1 << workload_type); + } +return 0 ; +} + +static const struct pptable_funcs renoir_ppt_funcs = { .get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -487,6 +511,7 @@ static const struct pptable_funcs renoir_ppt_funcs = { .get_workload_type = renoir_get_workload_type, .get_profiling_clk_mask = renoir_get_profiling_clk_mask, .force_clk_levels = renoir_force_clk_levels, + .set_power_profile_mode = renoir_set_power_profile_mode, };void renoir_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1569228167-3120-5-git-send-email-Prike.Liang-5C7GfCeVMHo@public.gmane.org
Wang, Kevin(Yang)
Reviewed-byRe: [PATCH 5/5] drm/amd/powerplay: implement interface set_power_profile_mode()
comment inline.
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Huang, Ray <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 5/5] drm/amd/powerplay: implement interface set_power_profile_mode()
Add set_power_profile_mode() for none manual dpm level case setting power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +17 -0
@@ -473,6 +473,30 @@ static int renoir_force_clk_levels(struct smu_context *smu,return ret; } +static int renoir_set_power_profile_mode (struct smu_context *smu,long *input,uint32_t size) +{ +int workload_type; + + smu->power_profile_mode = input[size]; + +if (smu->power_profile_mode >PP_SMC_POWER_PROFILE_CUSTOM ) { +pr_err ("Invalid power profile mode %d\n" , smu->power_profile_mode); +return -EINVAL ; + } + +if (smu->power_profile_mode ==PP_SMC_POWER_PROFILE_CUSTOM ) { +if (size <0 ) +return -EINVAL ; + +/* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ + workload_type =smu_workload_get_type (smu, smu->power_profile_mode);
[kevin]:
you'd better check the return value, when this workload is unmapped, it will return -EINVAL.
+ smu_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask,
+ 1 << workload_type);
[kevin]:
please check return value in smu driver every time.
after fixed:
+ }
+ return 0;
+}
+
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index, .get_smu_table_index = renoir_get_smu_table_index,
@@ -487,6 +511,7 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.get_workload_type = renoir_get_workload_type, .get_profiling_clk_mask = renoir_get_profiling_clk_mask, .force_clk_levels = renoir_force_clk_levels,
+ .set_power_profile_mode = renoir_set_power_profile_mode,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 5/5] drm/amd/powerplay: implement interface set_power_profile_mode()
In reply to a message not in the archive-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]
Cc: Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>; Huang, Ray <[email protected]>; [email protected]; Liang, Prike <[email protected]>
Subject: [PATCH 5/5] drm/amd/powerplay: implement interface set_power_profile_mode()
Add set_power_profile_mode() for none manual dpm level case setting power profile mode.
--- drivers/gpu/drm/amd/powerplay/renoir_ppt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/powerplay/renoir_ppt.c +6 -0
@@ -473,6 +473,30 @@ static int renoir_force_clk_levels(struct smu_context *smu,return ret; } +static int renoir_set_power_profile_mode (struct smu_context *smu,long +*input,uint32_t size) { +int workload_type; + + smu->power_profile_mode = input[size]; +
[Quan, Evan] update current power profile mode only when settings is triggered successfully. That is to move this end of this function call.
+ if (smu->power_profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
+ pr_err("Invalid power profile mode %d\n", smu->power_profile_mode);
+ return -EINVAL;
+ }
+
+ if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
+ if (size < 0)
+ return -EINVAL;
[Quan, Evan] This should not be for " PP_SMC_POWER_PROFILE_CUSTOM" only. And "size" check seems unnecessary.
+
+ /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
+ workload_type = smu_workload_get_type(smu, smu->power_profile_mode);
+ smu_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask,
+ 1 << workload_type);
+ }
+ return 0;
+}
+
+
static const struct pptable_funcs renoir_ppt_funcs = {
.get_smu_msg_index = renoir_get_smu_msg_index,
.get_smu_table_index = renoir_get_smu_table_index, @@ -487,6 +511,7 @@ static const struct pptable_funcs renoir_ppt_funcs = { .get_workload_type = renoir_get_workload_type,
.get_profiling_clk_mask = renoir_get_profiling_clk_mask,
.force_clk_levels = renoir_force_clk_levels,
+ .set_power_profile_mode = renoir_set_power_profile_mode,
};
void renoir_set_ppt_funcs(struct smu_context *smu)
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
the smu driver many place will use AMD_IS_APU flags, i think we'd better add a new member "is_apu" in smu_context"
Best Regards,
kevin
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Liang, Prike <[email protected]>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Huang, Ray <[email protected]>; Liang, Prike <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 1/5] drm/amd/powerplay: bypass dpm_context null pointer check guard for some smu series
For now APU has no smu_dpm_context structure for containing default/current related dpm table, thus will not initialize smu_dpm_context and aviod null pointer check guard for APU.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +7 -3
@@ -1554,7 +1554,9 @@ static int smu_enable_umd_pstate(void *handle,struct smu_context *smu = (struct smu_context *)(handle);struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -if (!smu->pm_enabled || !smu_dpm_ctx->dpm_context) +struct amdgpu_device *adev = smu->adev; + +if (!(adev->flags &AMD_IS_APU ) && (!smu->pm_enabled || !smu_dpm_ctx->dpm_context))return -EINVAL ;if (!(smu_dpm_ctx->dpm_level & profile_mode_mask)) {
@@ -1751,8 +1753,9 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu) {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);enum amd_dpm_forced_level level; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ;mutex_lock (&(smu->mutex));
@@ -1766,8 +1769,9 @@ int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_lev {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);int ret =0 ; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ; ret =smu_enable_umd_pstate (smu, &level);
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3296B10F5F4A601EC54B405BA2850-rweVpJHSKTqAm9ToKNQgFgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
That's a good point for simplifying the code and will send another patch for this.
Thanks,
Prike
From: Wang, Kevin(Yang) <[email protected]>
Sent: Monday, September 23, 2019 5:22 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: [email protected]; Huang, Ray <[email protected]>; Quan, Evan <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/5] drm/amd/powerplay: bypass dpm_context null pointer check guard for some smu series
the smu driver many place will use AMD_IS_APU flags, i think we'd better add a new member "is_apu" in smu_context"
Best Regards,
kevin
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:[email protected]>> on behalf of Liang, Prike <[email protected]<mailto:[email protected]>>
Sent: Monday, September 23, 2019 4:43 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Huang, Ray <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>; Quan, Evan <[email protected]<mailto:[email protected]>>; Feng, Kenneth <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/5] drm/amd/powerplay: bypass dpm_context null pointer check guard for some smu series
For now APU has no smu_dpm_context structure for containing default/current related dpm table, thus will not initialize smu_dpm_context and aviod null pointer check guard for APU.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +7 -3
@@ -1554,7 +1554,9 @@ static int smu_enable_umd_pstate(void *handle,struct smu_context *smu = (struct smu_context *)(handle);struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -if (!smu->pm_enabled || !smu_dpm_ctx->dpm_context) +struct amdgpu_device *adev = smu->adev; + +if (!(adev->flags &AMD_IS_APU ) && (!smu->pm_enabled || !smu_dpm_ctx->dpm_context))return -EINVAL ;if (!(smu_dpm_ctx->dpm_level & profile_mode_mask)) {
@@ -1751,8 +1753,9 @@ enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu) {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);enum amd_dpm_forced_level level; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ;mutex_lock (&(smu->mutex));
@@ -1766,8 +1769,9 @@ int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_lev {struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);int ret =0 ; +struct amdgpu_device *adev = smu->adev; -if (!smu_dpm_ctx->dpm_context) +if (!(adev->flags &AMD_IS_APU ) && !smu_dpm_ctx->dpm_context)return -EINVAL ; ret =smu_enable_umd_pstate (smu, &level);
--
2.7.4
_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx