For vega20, activity_monitor is also a temporary structure and you should not rely on that for judging existence of custom profile. Regards Evan > -----Original Message----- > From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of > Russell, Kent > Sent: Wednesday, March 27, 2019 9:59 PM > To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx > Cc: Russell, Kent <Kent.Russell@xxxxxxx> > Subject: [PATCH 1/2] drm/amdgpu: Allow switching to CUSTOM profile on > Vega10/20 v2 > > Don't return an error if the CUSTOM profile is selected, just apply it with the > values saved to the GPU > > v2: Remove reference to fixed bug, check that CUSTOM profile was set > > Change-Id: I114cc9783226ee9ebb146863897e951527a85e20 > Signed-off-by: Kent Russell <kent.russell@xxxxxxx> > --- > drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 14 > +++++++++++++- > drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 14 > +++++++++++++- > 2 files changed, 26 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c > b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c > index 85a536924571..7e9e7e254a0d 100644 > --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c > +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c > @@ -4910,9 +4910,20 @@ static int vega10_set_power_profile_mode(struct > pp_hwmgr *hwmgr, long *input, ui > 1 << power_profile_mode); > > if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { > - if (size == 0 || size > 4) > + if (size != 0 && size != 4) > return -EINVAL; > > + /* If size = 0 and the CUSTOM profile has been set already > + * (check BUSY_SET_POINT since that is always >0 for a valid > + * profile) then just apply the profile. > + */ > + if (size == 0) { > + if (data->custom_profile_mode[0] != 0) > + goto out; > + else > + return -EINVAL; > + } > + > data->custom_profile_mode[0] = busy_set_point = input[0]; > data->custom_profile_mode[1] = FPS = input[1]; > data->custom_profile_mode[2] = use_rlc_busy = input[2]; > @@ -4923,6 +4934,7 @@ static int vega10_set_power_profile_mode(struct > pp_hwmgr *hwmgr, long *input, ui > use_rlc_busy << 16 | > min_active_level<<24); > } > > +out: > hwmgr->power_profile_mode = power_profile_mode; > > return 0; > diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c > b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c > index 70dc641bf94d..6dc16a9e766b 100644 > --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c > +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c > @@ -3843,7 +3843,7 @@ static int vega20_set_power_profile_mode(struct > pp_hwmgr *hwmgr, long *input, ui > } > > if (power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) { > - if (size < 10) > + if (size < 10 && size != 0) > return -EINVAL; > > result = vega20_get_activity_monitor_coeff(hwmgr, > @@ -3853,6 +3853,17 @@ static int vega20_set_power_profile_mode(struct > pp_hwmgr *hwmgr, long *input, ui > "[SetPowerProfile] Failed to get activity > monitor!", > return result); > > + /* If size = 0 and the CUSTOM profile has been set already > + * (check BoosterFreqType since that is always >0 for a valid > + * profile) then just apply the profile. > + */ > + if (size == 0) { > + if (activity_monitor.Soc_BoosterFreqType != 0) > + goto out; > + else > + return -EINVAL; > + } > + > switch (input[0]) { > case 0: /* Gfxclk */ > activity_monitor.Gfx_FPS = input[1]; @@ -3908,6 > +3919,7 @@ static int vega20_set_power_profile_mode(struct pp_hwmgr > *hwmgr, long *input, ui > return result); > } > > +out: > /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ > workload_type = > > conv_power_profile_to_pplib_workload(power_profile_mode); > -- > 2.17.1 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx