[PATCH 4/4] drm/amd/powerplay: add profiling mode in dpm level
Alex Deucher
alexdeucher at gmail.com
Sat Dec 31 06:25:28 UTC 2016
On Fri, Dec 23, 2016 at 3:45 AM, Rex Zhu <Rex.Zhu at amd.com> wrote:
> Change-Id: I4a46440882cd94fe5e77e3f351aaccc218a2ece5
Patches 1-3:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
patch 4:
Please add a better patch description and explain what profiling mode
is good for, etc.
Alex
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 17 +++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 4 ++--
> drivers/gpu/drm/amd/include/amd_shared.h | 1 +
> drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 3 ++-
> drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 3 ++-
> 5 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index 2bfede8..8438642 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -124,6 +124,7 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev,
> (level & AMD_DPM_FORCED_LEVEL_LOW) ? "low" :
> (level & AMD_DPM_FORCED_LEVEL_HIGH) ? "high" :
> (level & AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" :
> + (level & AMD_DPM_FORCED_LEVEL_PROFILING) ? "profiling" :
> "unknown"));
> }
>
> @@ -135,6 +136,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
> struct drm_device *ddev = dev_get_drvdata(dev);
> struct amdgpu_device *adev = ddev->dev_private;
> enum amd_dpm_forced_level level;
> + enum amd_dpm_forced_level current_level;
> int ret = 0;
>
> /* Can't force performance level when the card is off */
> @@ -142,6 +144,8 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
> (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
> return -EINVAL;
>
> + current_level = amdgpu_dpm_get_performance_level(adev);
> +
> if (strncmp("low", buf, strlen("low")) == 0) {
> level = AMD_DPM_FORCED_LEVEL_LOW;
> } else if (strncmp("high", buf, strlen("high")) == 0) {
> @@ -150,11 +154,24 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
> level = AMD_DPM_FORCED_LEVEL_AUTO;
> } else if (strncmp("manual", buf, strlen("manual")) == 0) {
> level = AMD_DPM_FORCED_LEVEL_MANUAL;
> + } else if (strncmp("profile", buf, strlen("profile")) == 0) {
> + level = AMD_DPM_FORCED_LEVEL_PROFILING;
> } else {
> count = -EINVAL;
> goto fail;
> }
>
> + if (current_level == level)
> + return 0;
> +
> + if (level == AMD_DPM_FORCED_LEVEL_PROFILING)
> + amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
> + AMD_CG_STATE_UNGATE);
> + else if (level != AMD_DPM_FORCED_LEVEL_PROFILING &&
> + current_level == AMD_DPM_FORCED_LEVEL_PROFILING)
> + amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
> + AMD_CG_STATE_GATE);
> +
> if (adev->pp_enabled)
> amdgpu_dpm_force_performance_level(adev, level);
> else {
> diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
> index d8de7eb..59be694 100644
> --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
> @@ -6571,8 +6571,8 @@ static int ci_dpm_force_clock_level(struct amdgpu_device *adev,
> {
> struct ci_power_info *pi = ci_get_pi(adev);
>
> - if (adev->pm.dpm.forced_level
> - != AMD_DPM_FORCED_LEVEL_MANUAL)
> + if (!(adev->pm.dpm.forced_level &
> + (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING)))
> return -EINVAL;
>
> switch (type) {
> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
> index 3f2a6b9..f3424a1 100644
> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> @@ -85,6 +85,7 @@ enum amd_dpm_forced_level {
> AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
> AMD_DPM_FORCED_LEVEL_LOW = 0x4,
> AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
> + AMD_DPM_FORCED_LEVEL_PROFILING = 0x10,
> };
>
> enum amd_powergating_state {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> index 74dbbd1..beaa7e2 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> @@ -1637,7 +1637,8 @@ static int cz_get_dal_power_level(struct pp_hwmgr *hwmgr,
> static int cz_force_clock_level(struct pp_hwmgr *hwmgr,
> enum pp_clock_type type, uint32_t mask)
> {
> - if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
> + if (!(hwmgr->dpm_level &
> + (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING)))
> return -EINVAL;
>
> switch (type) {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> index ae5517a..146d7dd 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> @@ -4033,7 +4033,8 @@ static int smu7_force_clock_level(struct pp_hwmgr *hwmgr,
> {
> struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
>
> - if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
> + if (!(hwmgr->dpm_level &
> + (AMD_DPM_FORCED_LEVEL_MANUAL | AMD_DPM_FORCED_LEVEL_PROFILING)))
> return -EINVAL;
>
> switch (type) {
> --
> 1.9.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list