Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
On Thu, Aug 24, 2023 at 10:02 PM Quan, Evan wrote: > > [AMD Official Use Only - General] > > > -Original Message- > > From: Alex Deucher > > Sent: Thursday, August 24, 2023 10:51 PM > > To: Quan, Evan > > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for > > SMU13 > > > > On Wed, Aug 23, 2023 at 10:28 PM Quan, Evan > > wrote: > > > > > > [AMD Official Use Only - General] > > > > > > > -Original Message- > > > > From: Alex Deucher > > > > Sent: Wednesday, August 23, 2023 9:29 PM > > > > To: Quan, Evan > > > > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > > > > > > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support > > > > for > > > > SMU13 > > > > > > > > On Wed, Aug 23, 2023 at 2:45 AM Evan Quan > > > > wrote: > > > > > > > > > > Add SMU13 fan mode OD setting support. > > > > > > > > > > Signed-off-by: Evan Quan > > > > > -- > > > > > v1->v2: > > > > > - add missing kerneldoc for the new interface(Alex) > > > > > --- > > > > > Documentation/gpu/amdgpu/thermal.rst | 6 + > > > > > .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- > > > > > drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 > > > > +- > > > > > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + > > > > > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + > > > > > drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + > > > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- > > > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- > > > > > 8 files changed, 279 insertions(+), 8 deletions(-) > > > > > > > > > > diff --git a/Documentation/gpu/amdgpu/thermal.rst > > > > > b/Documentation/gpu/amdgpu/thermal.rst > > > > > index 5e27e4eb3959..8757ec7f0136 100644 > > > > > --- a/Documentation/gpu/amdgpu/thermal.rst > > > > > +++ b/Documentation/gpu/amdgpu/thermal.rst > > > > > @@ -64,6 +64,12 @@ gpu_metrics > > > > > .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > :doc: gpu_metrics > > > > > > > > > > +fan_mode > > > > > + > > > > > + > > > > > +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > + :doc: fan_mode > > > > > + > > > > > GFXOFF > > > > > == > > > > > > > > > > diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > > b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > > index 84c5224d994c..020c9ce1f735 100644 > > > > > --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > > +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > > @@ -113,6 +113,7 @@ enum pp_clock_type { > > > > > OD_RANGE, > > > > > OD_VDDGFX_OFFSET, > > > > > OD_CCLK, > > > > > + OD_FAN_MODE, > > > > > }; > > > > > > > > > > enum amd_pp_sensors { > > > > > @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { > > > > > PP_OD_EDIT_VDDC_CURVE, > > > > > PP_OD_RESTORE_DEFAULT_TABLE, > > > > > PP_OD_COMMIT_DPM_TABLE, > > > > > - PP_OD_EDIT_VDDGFX_OFFSET > > > > > + PP_OD_EDIT_VDDGFX_OFFSET, > > > > > + PP_OD_EDIT_FAN_MODE, > > > > > }; > > > > > > > > > > struct pp_states_info { > > > > > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > index beb3303fc832..d53d60903fe9 100644 > > > > > --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > > @@ -3383,7 +3383,205 @@ static const struct attribute_group > > > > *hwmon_groups[] = { > > > > > NULL > > > > > }; > > > > > > > > > > -static struct od_feature_set amdgpu_od_set; > > >
RE: [V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
[AMD Official Use Only - General] > -Original Message- > From: Alex Deucher > Sent: Thursday, August 24, 2023 10:51 PM > To: Quan, Evan > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for > SMU13 > > On Wed, Aug 23, 2023 at 10:28 PM Quan, Evan > wrote: > > > > [AMD Official Use Only - General] > > > > > -Original Message- > > > From: Alex Deucher > > > Sent: Wednesday, August 23, 2023 9:29 PM > > > To: Quan, Evan > > > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > > > > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support > > > for > > > SMU13 > > > > > > On Wed, Aug 23, 2023 at 2:45 AM Evan Quan > > > wrote: > > > > > > > > Add SMU13 fan mode OD setting support. > > > > > > > > Signed-off-by: Evan Quan > > > > -- > > > > v1->v2: > > > > - add missing kerneldoc for the new interface(Alex) > > > > --- > > > > Documentation/gpu/amdgpu/thermal.rst | 6 + > > > > .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- > > > > drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 > > > +- > > > > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + > > > > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + > > > > drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + > > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- > > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- > > > > 8 files changed, 279 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/Documentation/gpu/amdgpu/thermal.rst > > > > b/Documentation/gpu/amdgpu/thermal.rst > > > > index 5e27e4eb3959..8757ec7f0136 100644 > > > > --- a/Documentation/gpu/amdgpu/thermal.rst > > > > +++ b/Documentation/gpu/amdgpu/thermal.rst > > > > @@ -64,6 +64,12 @@ gpu_metrics > > > > .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > :doc: gpu_metrics > > > > > > > > +fan_mode > > > > + > > > > + > > > > +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > + :doc: fan_mode > > > > + > > > > GFXOFF > > > > == > > > > > > > > diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > index 84c5224d994c..020c9ce1f735 100644 > > > > --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > > @@ -113,6 +113,7 @@ enum pp_clock_type { > > > > OD_RANGE, > > > > OD_VDDGFX_OFFSET, > > > > OD_CCLK, > > > > + OD_FAN_MODE, > > > > }; > > > > > > > > enum amd_pp_sensors { > > > > @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { > > > > PP_OD_EDIT_VDDC_CURVE, > > > > PP_OD_RESTORE_DEFAULT_TABLE, > > > > PP_OD_COMMIT_DPM_TABLE, > > > > - PP_OD_EDIT_VDDGFX_OFFSET > > > > + PP_OD_EDIT_VDDGFX_OFFSET, > > > > + PP_OD_EDIT_FAN_MODE, > > > > }; > > > > > > > > struct pp_states_info { > > > > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > index beb3303fc832..d53d60903fe9 100644 > > > > --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > > @@ -3383,7 +3383,205 @@ static const struct attribute_group > > > *hwmon_groups[] = { > > > > NULL > > > > }; > > > > > > > > -static struct od_feature_set amdgpu_od_set; > > > > +static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, > > > > + enum pp_clock_type od_type, > > > > + char *buf) { > > > > + int size = 0; > > > > + int ret; > > > > + > > > > + if (amdgpu_in_reset(adev)) > > > > + return -EPERM; > > > > + if (adev->in_suspend && !adev->in_runpm) >
Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
On Wed, Aug 23, 2023 at 10:28 PM Quan, Evan wrote: > > [AMD Official Use Only - General] > > > -Original Message- > > From: Alex Deucher > > Sent: Wednesday, August 23, 2023 9:29 PM > > To: Quan, Evan > > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for > > SMU13 > > > > On Wed, Aug 23, 2023 at 2:45 AM Evan Quan > > wrote: > > > > > > Add SMU13 fan mode OD setting support. > > > > > > Signed-off-by: Evan Quan > > > -- > > > v1->v2: > > > - add missing kerneldoc for the new interface(Alex) > > > --- > > > Documentation/gpu/amdgpu/thermal.rst | 6 + > > > .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- > > > drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 > > +- > > > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + > > > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + > > > drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- > > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- > > > 8 files changed, 279 insertions(+), 8 deletions(-) > > > > > > diff --git a/Documentation/gpu/amdgpu/thermal.rst > > > b/Documentation/gpu/amdgpu/thermal.rst > > > index 5e27e4eb3959..8757ec7f0136 100644 > > > --- a/Documentation/gpu/amdgpu/thermal.rst > > > +++ b/Documentation/gpu/amdgpu/thermal.rst > > > @@ -64,6 +64,12 @@ gpu_metrics > > > .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > :doc: gpu_metrics > > > > > > +fan_mode > > > + > > > + > > > +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > + :doc: fan_mode > > > + > > > GFXOFF > > > == > > > > > > diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > index 84c5224d994c..020c9ce1f735 100644 > > > --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > > @@ -113,6 +113,7 @@ enum pp_clock_type { > > > OD_RANGE, > > > OD_VDDGFX_OFFSET, > > > OD_CCLK, > > > + OD_FAN_MODE, > > > }; > > > > > > enum amd_pp_sensors { > > > @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { > > > PP_OD_EDIT_VDDC_CURVE, > > > PP_OD_RESTORE_DEFAULT_TABLE, > > > PP_OD_COMMIT_DPM_TABLE, > > > - PP_OD_EDIT_VDDGFX_OFFSET > > > + PP_OD_EDIT_VDDGFX_OFFSET, > > > + PP_OD_EDIT_FAN_MODE, > > > }; > > > > > > struct pp_states_info { > > > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > index beb3303fc832..d53d60903fe9 100644 > > > --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > > @@ -3383,7 +3383,205 @@ static const struct attribute_group > > *hwmon_groups[] = { > > > NULL > > > }; > > > > > > -static struct od_feature_set amdgpu_od_set; > > > +static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, > > > + enum pp_clock_type od_type, > > > + char *buf) { > > > + int size = 0; > > > + int ret; > > > + > > > + if (amdgpu_in_reset(adev)) > > > + return -EPERM; > > > + if (adev->in_suspend && !adev->in_runpm) > > > + return -EPERM; > > > + > > > + ret = pm_runtime_get_sync(adev->dev); > > > + if (ret < 0) { > > > + pm_runtime_put_autosuspend(adev->dev); > > > + return ret; > > > + } > > > + > > > + size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); > > > + if (size == 0) > > > + size = sysfs_emit(buf, "\n"); > > > + > > > + pm_runtime_mark_last_busy(adev->dev); > > > + pm_runtime_put_autosuspend(adev->dev); > > > + > > > + return size; > > > +} > > > + > > > +static int parse_input_od_command_lines(const char *buf, > > > +
RE: [V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
[AMD Official Use Only - General] > -Original Message- > From: Alex Deucher > Sent: Wednesday, August 23, 2023 9:29 PM > To: Quan, Evan > Cc: amd-gfx@lists.freedesktop.org; Deucher, Alexander > > Subject: Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for > SMU13 > > On Wed, Aug 23, 2023 at 2:45 AM Evan Quan > wrote: > > > > Add SMU13 fan mode OD setting support. > > > > Signed-off-by: Evan Quan > > -- > > v1->v2: > > - add missing kerneldoc for the new interface(Alex) > > --- > > Documentation/gpu/amdgpu/thermal.rst | 6 + > > .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- > > drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 > +- > > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + > > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + > > drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- > > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- > > 8 files changed, 279 insertions(+), 8 deletions(-) > > > > diff --git a/Documentation/gpu/amdgpu/thermal.rst > > b/Documentation/gpu/amdgpu/thermal.rst > > index 5e27e4eb3959..8757ec7f0136 100644 > > --- a/Documentation/gpu/amdgpu/thermal.rst > > +++ b/Documentation/gpu/amdgpu/thermal.rst > > @@ -64,6 +64,12 @@ gpu_metrics > > .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > :doc: gpu_metrics > > > > +fan_mode > > + > > + > > +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > > + :doc: fan_mode > > + > > GFXOFF > > == > > > > diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > index 84c5224d994c..020c9ce1f735 100644 > > --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > > @@ -113,6 +113,7 @@ enum pp_clock_type { > > OD_RANGE, > > OD_VDDGFX_OFFSET, > > OD_CCLK, > > + OD_FAN_MODE, > > }; > > > > enum amd_pp_sensors { > > @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { > > PP_OD_EDIT_VDDC_CURVE, > > PP_OD_RESTORE_DEFAULT_TABLE, > > PP_OD_COMMIT_DPM_TABLE, > > - PP_OD_EDIT_VDDGFX_OFFSET > > + PP_OD_EDIT_VDDGFX_OFFSET, > > + PP_OD_EDIT_FAN_MODE, > > }; > > > > struct pp_states_info { > > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > index beb3303fc832..d53d60903fe9 100644 > > --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > > @@ -3383,7 +3383,205 @@ static const struct attribute_group > *hwmon_groups[] = { > > NULL > > }; > > > > -static struct od_feature_set amdgpu_od_set; > > +static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, > > + enum pp_clock_type od_type, > > + char *buf) { > > + int size = 0; > > + int ret; > > + > > + if (amdgpu_in_reset(adev)) > > + return -EPERM; > > + if (adev->in_suspend && !adev->in_runpm) > > + return -EPERM; > > + > > + ret = pm_runtime_get_sync(adev->dev); > > + if (ret < 0) { > > + pm_runtime_put_autosuspend(adev->dev); > > + return ret; > > + } > > + > > + size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); > > + if (size == 0) > > + size = sysfs_emit(buf, "\n"); > > + > > + pm_runtime_mark_last_busy(adev->dev); > > + pm_runtime_put_autosuspend(adev->dev); > > + > > + return size; > > +} > > + > > +static int parse_input_od_command_lines(const char *buf, > > + size_t count, > > + u32 *type, > > + long *params, > > + uint32_t *num_of_params) { > > + const char delimiter[3] = {' ', '\n', '\0'}; > > + uint32_t parameter_size = 0; > > + char buf_cpy[128] = {0}; > > + char *tmp_str, *sub_str; > > + int ret; > > + > > + if (count > sizeof(buf_cpy) - 1) > > + return -EINVAL; > > + > > + memcp
Re: [V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
On Wed, Aug 23, 2023 at 2:45 AM Evan Quan wrote: > > Add SMU13 fan mode OD setting support. > > Signed-off-by: Evan Quan > -- > v1->v2: > - add missing kerneldoc for the new interface(Alex) > --- > Documentation/gpu/amdgpu/thermal.rst | 6 + > .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- > drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 +- > drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + > drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + > drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + > .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- > .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- > 8 files changed, 279 insertions(+), 8 deletions(-) > > diff --git a/Documentation/gpu/amdgpu/thermal.rst > b/Documentation/gpu/amdgpu/thermal.rst > index 5e27e4eb3959..8757ec7f0136 100644 > --- a/Documentation/gpu/amdgpu/thermal.rst > +++ b/Documentation/gpu/amdgpu/thermal.rst > @@ -64,6 +64,12 @@ gpu_metrics > .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > :doc: gpu_metrics > > +fan_mode > + > + > +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c > + :doc: fan_mode > + > GFXOFF > == > > diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > index 84c5224d994c..020c9ce1f735 100644 > --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h > +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h > @@ -113,6 +113,7 @@ enum pp_clock_type { > OD_RANGE, > OD_VDDGFX_OFFSET, > OD_CCLK, > + OD_FAN_MODE, > }; > > enum amd_pp_sensors { > @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { > PP_OD_EDIT_VDDC_CURVE, > PP_OD_RESTORE_DEFAULT_TABLE, > PP_OD_COMMIT_DPM_TABLE, > - PP_OD_EDIT_VDDGFX_OFFSET > + PP_OD_EDIT_VDDGFX_OFFSET, > + PP_OD_EDIT_FAN_MODE, > }; > > struct pp_states_info { > diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > index beb3303fc832..d53d60903fe9 100644 > --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c > +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c > @@ -3383,7 +3383,205 @@ static const struct attribute_group *hwmon_groups[] = > { > NULL > }; > > -static struct od_feature_set amdgpu_od_set; > +static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, > + enum pp_clock_type od_type, > + char *buf) > +{ > + int size = 0; > + int ret; > + > + if (amdgpu_in_reset(adev)) > + return -EPERM; > + if (adev->in_suspend && !adev->in_runpm) > + return -EPERM; > + > + ret = pm_runtime_get_sync(adev->dev); > + if (ret < 0) { > + pm_runtime_put_autosuspend(adev->dev); > + return ret; > + } > + > + size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); > + if (size == 0) > + size = sysfs_emit(buf, "\n"); > + > + pm_runtime_mark_last_busy(adev->dev); > + pm_runtime_put_autosuspend(adev->dev); > + > + return size; > +} > + > +static int parse_input_od_command_lines(const char *buf, > + size_t count, > + u32 *type, > + long *params, > + uint32_t *num_of_params) > +{ > + const char delimiter[3] = {' ', '\n', '\0'}; > + uint32_t parameter_size = 0; > + char buf_cpy[128] = {0}; > + char *tmp_str, *sub_str; > + int ret; > + > + if (count > sizeof(buf_cpy) - 1) > + return -EINVAL; > + > + memcpy(buf_cpy, buf, count); > + tmp_str = buf_cpy; > + > + /* skip heading spaces */ > + while (isspace(*tmp_str)) > + tmp_str++; > + > + switch (*tmp_str) { > + case 'c': > + *type = PP_OD_COMMIT_DPM_TABLE; > + return 0; > + default: > + break; > + } > + > + while ((sub_str = strsep(_str, delimiter)) != NULL) { > + if (strlen(sub_str) == 0) > + continue; > + > + ret = kstrtol(sub_str, 0, [parameter_size]); > + if (ret) > + return -EINVAL; > + parameter_size++; > + > + while (isspace(*tmp_str)) > + tmp_str++; > + } > + > + *num_of_params = parameter_size; > + > + return 0; > +} > + > +static int > +amdgpu_distribute_custom_od_settings(struct amdgpu_device *adev, > +enum PP_OD_DPM_TABLE_COMMAND cmd_type, > +const char *in_buf, > +size_t count) > +{ > + uint32_t parameter_size = 0; > + long parameter[64]; > + int ret; > + > + if (amdgpu_in_reset(adev)) > +
[V2 3/8] drm/amd/pm: add fan mode OD setting support for SMU13
Add SMU13 fan mode OD setting support. Signed-off-by: Evan Quan -- v1->v2: - add missing kerneldoc for the new interface(Alex) --- Documentation/gpu/amdgpu/thermal.rst | 6 + .../gpu/drm/amd/include/kgd_pp_interface.h| 4 +- drivers/gpu/drm/amd/pm/amdgpu_pm.c| 200 +- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 4 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 1 + .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 35 ++- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 35 ++- 8 files changed, 279 insertions(+), 8 deletions(-) diff --git a/Documentation/gpu/amdgpu/thermal.rst b/Documentation/gpu/amdgpu/thermal.rst index 5e27e4eb3959..8757ec7f0136 100644 --- a/Documentation/gpu/amdgpu/thermal.rst +++ b/Documentation/gpu/amdgpu/thermal.rst @@ -64,6 +64,12 @@ gpu_metrics .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c :doc: gpu_metrics +fan_mode + + +.. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c + :doc: fan_mode + GFXOFF == diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h index 84c5224d994c..020c9ce1f735 100644 --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h @@ -113,6 +113,7 @@ enum pp_clock_type { OD_RANGE, OD_VDDGFX_OFFSET, OD_CCLK, + OD_FAN_MODE, }; enum amd_pp_sensors { @@ -186,7 +187,8 @@ enum PP_OD_DPM_TABLE_COMMAND { PP_OD_EDIT_VDDC_CURVE, PP_OD_RESTORE_DEFAULT_TABLE, PP_OD_COMMIT_DPM_TABLE, - PP_OD_EDIT_VDDGFX_OFFSET + PP_OD_EDIT_VDDGFX_OFFSET, + PP_OD_EDIT_FAN_MODE, }; struct pp_states_info { diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c index beb3303fc832..d53d60903fe9 100644 --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c @@ -3383,7 +3383,205 @@ static const struct attribute_group *hwmon_groups[] = { NULL }; -static struct od_feature_set amdgpu_od_set; +static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, + enum pp_clock_type od_type, + char *buf) +{ + int size = 0; + int ret; + + if (amdgpu_in_reset(adev)) + return -EPERM; + if (adev->in_suspend && !adev->in_runpm) + return -EPERM; + + ret = pm_runtime_get_sync(adev->dev); + if (ret < 0) { + pm_runtime_put_autosuspend(adev->dev); + return ret; + } + + size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); + if (size == 0) + size = sysfs_emit(buf, "\n"); + + pm_runtime_mark_last_busy(adev->dev); + pm_runtime_put_autosuspend(adev->dev); + + return size; +} + +static int parse_input_od_command_lines(const char *buf, + size_t count, + u32 *type, + long *params, + uint32_t *num_of_params) +{ + const char delimiter[3] = {' ', '\n', '\0'}; + uint32_t parameter_size = 0; + char buf_cpy[128] = {0}; + char *tmp_str, *sub_str; + int ret; + + if (count > sizeof(buf_cpy) - 1) + return -EINVAL; + + memcpy(buf_cpy, buf, count); + tmp_str = buf_cpy; + + /* skip heading spaces */ + while (isspace(*tmp_str)) + tmp_str++; + + switch (*tmp_str) { + case 'c': + *type = PP_OD_COMMIT_DPM_TABLE; + return 0; + default: + break; + } + + while ((sub_str = strsep(_str, delimiter)) != NULL) { + if (strlen(sub_str) == 0) + continue; + + ret = kstrtol(sub_str, 0, [parameter_size]); + if (ret) + return -EINVAL; + parameter_size++; + + while (isspace(*tmp_str)) + tmp_str++; + } + + *num_of_params = parameter_size; + + return 0; +} + +static int +amdgpu_distribute_custom_od_settings(struct amdgpu_device *adev, +enum PP_OD_DPM_TABLE_COMMAND cmd_type, +const char *in_buf, +size_t count) +{ + uint32_t parameter_size = 0; + long parameter[64]; + int ret; + + if (amdgpu_in_reset(adev)) + return -EPERM; + if (adev->in_suspend && !adev->in_runpm) + return -EPERM; + + ret = parse_input_od_command_lines(in_buf, + count, + _type, + parameter, +