Skip to content

Commit

Permalink
drm/amd/powerplay: add profiling mode in dpm level
Browse files Browse the repository at this point in the history
In some case, App need to run under max stable clock.
so export profiling mode: GFX CG was disabled.
and user can select the max stable clock of the device.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Rex Zhu authored and Alex Deucher committed Jan 27, 2017
1 parent 9d27349 commit 3bd5897
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
17 changes: 17 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand All @@ -135,13 +136,16 @@ 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 */
if ((adev->flags & AMD_IS_PX) &&
(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) {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/ci_dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/include/amd_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,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) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4031,7 +4031,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) {
Expand Down

0 comments on commit 3bd5897

Please sign in to comment.