diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2018-06-04 04:39:38 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-06-15 13:20:45 -0400 |
commit | 600ae890be59910e65b75fe25a1b900d83c0329c (patch) | |
tree | 5e7472260ca37f77c496304b36e36eb929f41006 /drivers/gpu/drm/amd/amdgpu | |
parent | c5792d7776e61737af200bf6f0d15354b5a3d205 (diff) |
drm/amdgpu: Use real power source in powerplay instand of hardcode
1. move ac_power to struct pm from dpm, so can be shared with powerplay
2. remove power_source in powerplay, use adev->pm.ac_power instand.
3. update ac_power before dispatch power task.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 21 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/si_dpm.c | 4 |
5 files changed, 21 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h index dd6203a0a6b7..9acfbee91c40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | |||
@@ -402,7 +402,6 @@ struct amdgpu_dpm { | |||
402 | u32 tdp_adjustment; | 402 | u32 tdp_adjustment; |
403 | u16 load_line_slope; | 403 | u16 load_line_slope; |
404 | bool power_control; | 404 | bool power_control; |
405 | bool ac_power; | ||
406 | /* special states active */ | 405 | /* special states active */ |
407 | bool thermal_active; | 406 | bool thermal_active; |
408 | bool uvd_active; | 407 | bool uvd_active; |
@@ -439,6 +438,7 @@ struct amdgpu_pm { | |||
439 | struct amd_pp_display_configuration pm_display_cfg;/* set by dc */ | 438 | struct amd_pp_display_configuration pm_display_cfg;/* set by dc */ |
440 | uint32_t smu_prv_buffer_size; | 439 | uint32_t smu_prv_buffer_size; |
441 | struct amdgpu_bo *smu_prv_buffer; | 440 | struct amdgpu_bo *smu_prv_buffer; |
441 | bool ac_power; | ||
442 | }; | 442 | }; |
443 | 443 | ||
444 | #define R600_SSTU_DFLT 0 | 444 | #define R600_SSTU_DFLT 0 |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index f667cb9eb614..113edffb5960 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -68,11 +68,11 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev) | |||
68 | if (adev->pm.dpm_enabled) { | 68 | if (adev->pm.dpm_enabled) { |
69 | mutex_lock(&adev->pm.mutex); | 69 | mutex_lock(&adev->pm.mutex); |
70 | if (power_supply_is_system_supplied() > 0) | 70 | if (power_supply_is_system_supplied() > 0) |
71 | adev->pm.dpm.ac_power = true; | 71 | adev->pm.ac_power = true; |
72 | else | 72 | else |
73 | adev->pm.dpm.ac_power = false; | 73 | adev->pm.ac_power = false; |
74 | if (adev->powerplay.pp_funcs->enable_bapm) | 74 | if (adev->powerplay.pp_funcs->enable_bapm) |
75 | amdgpu_dpm_enable_bapm(adev, adev->pm.dpm.ac_power); | 75 | amdgpu_dpm_enable_bapm(adev, adev->pm.ac_power); |
76 | mutex_unlock(&adev->pm.mutex); | 76 | mutex_unlock(&adev->pm.mutex); |
77 | } | 77 | } |
78 | } | 78 | } |
@@ -1907,6 +1907,14 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev) | |||
1907 | amdgpu_fence_wait_empty(ring); | 1907 | amdgpu_fence_wait_empty(ring); |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | mutex_lock(&adev->pm.mutex); | ||
1911 | /* update battery/ac status */ | ||
1912 | if (power_supply_is_system_supplied() > 0) | ||
1913 | adev->pm.ac_power = true; | ||
1914 | else | ||
1915 | adev->pm.ac_power = false; | ||
1916 | mutex_unlock(&adev->pm.mutex); | ||
1917 | |||
1910 | if (adev->powerplay.pp_funcs->dispatch_tasks) { | 1918 | if (adev->powerplay.pp_funcs->dispatch_tasks) { |
1911 | if (!amdgpu_device_has_dc_support(adev)) { | 1919 | if (!amdgpu_device_has_dc_support(adev)) { |
1912 | mutex_lock(&adev->pm.mutex); | 1920 | mutex_lock(&adev->pm.mutex); |
@@ -1927,14 +1935,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev) | |||
1927 | } else { | 1935 | } else { |
1928 | mutex_lock(&adev->pm.mutex); | 1936 | mutex_lock(&adev->pm.mutex); |
1929 | amdgpu_dpm_get_active_displays(adev); | 1937 | amdgpu_dpm_get_active_displays(adev); |
1930 | /* update battery/ac status */ | ||
1931 | if (power_supply_is_system_supplied() > 0) | ||
1932 | adev->pm.dpm.ac_power = true; | ||
1933 | else | ||
1934 | adev->pm.dpm.ac_power = false; | ||
1935 | |||
1936 | amdgpu_dpm_change_power_state_locked(adev); | 1938 | amdgpu_dpm_change_power_state_locked(adev); |
1937 | |||
1938 | mutex_unlock(&adev->pm.mutex); | 1939 | mutex_unlock(&adev->pm.mutex); |
1939 | } | 1940 | } |
1940 | } | 1941 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index a266dcf5daed..b6248c0578a1 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
@@ -951,12 +951,12 @@ static void ci_apply_state_adjust_rules(struct amdgpu_device *adev, | |||
951 | else | 951 | else |
952 | pi->battery_state = false; | 952 | pi->battery_state = false; |
953 | 953 | ||
954 | if (adev->pm.dpm.ac_power) | 954 | if (adev->pm.ac_power) |
955 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 955 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
956 | else | 956 | else |
957 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 957 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
958 | 958 | ||
959 | if (adev->pm.dpm.ac_power == false) { | 959 | if (adev->pm.ac_power == false) { |
960 | for (i = 0; i < ps->performance_level_count; i++) { | 960 | for (i = 0; i < ps->performance_level_count; i++) { |
961 | if (ps->performance_levels[i].mclk > max_limits->mclk) | 961 | if (ps->performance_levels[i].mclk > max_limits->mclk) |
962 | ps->performance_levels[i].mclk = max_limits->mclk; | 962 | ps->performance_levels[i].mclk = max_limits->mclk; |
@@ -4078,7 +4078,7 @@ static int ci_enable_uvd_dpm(struct amdgpu_device *adev, bool enable) | |||
4078 | const struct amdgpu_clock_and_voltage_limits *max_limits; | 4078 | const struct amdgpu_clock_and_voltage_limits *max_limits; |
4079 | int i; | 4079 | int i; |
4080 | 4080 | ||
4081 | if (adev->pm.dpm.ac_power) | 4081 | if (adev->pm.ac_power) |
4082 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 4082 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
4083 | else | 4083 | else |
4084 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 4084 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
@@ -4127,7 +4127,7 @@ static int ci_enable_vce_dpm(struct amdgpu_device *adev, bool enable) | |||
4127 | const struct amdgpu_clock_and_voltage_limits *max_limits; | 4127 | const struct amdgpu_clock_and_voltage_limits *max_limits; |
4128 | int i; | 4128 | int i; |
4129 | 4129 | ||
4130 | if (adev->pm.dpm.ac_power) | 4130 | if (adev->pm.ac_power) |
4131 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 4131 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
4132 | else | 4132 | else |
4133 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 4133 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
@@ -4160,7 +4160,7 @@ static int ci_enable_samu_dpm(struct amdgpu_device *adev, bool enable) | |||
4160 | const struct amdgpu_clock_and_voltage_limits *max_limits; | 4160 | const struct amdgpu_clock_and_voltage_limits *max_limits; |
4161 | int i; | 4161 | int i; |
4162 | 4162 | ||
4163 | if (adev->pm.dpm.ac_power) | 4163 | if (adev->pm.ac_power) |
4164 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 4164 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
4165 | else | 4165 | else |
4166 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 4166 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
@@ -4191,7 +4191,7 @@ static int ci_enable_acp_dpm(struct amdgpu_device *adev, bool enable) | |||
4191 | const struct amdgpu_clock_and_voltage_limits *max_limits; | 4191 | const struct amdgpu_clock_and_voltage_limits *max_limits; |
4192 | int i; | 4192 | int i; |
4193 | 4193 | ||
4194 | if (adev->pm.dpm.ac_power) | 4194 | if (adev->pm.ac_power) |
4195 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 4195 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
4196 | else | 4196 | else |
4197 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 4197 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index 17f7f074cedc..d79e6f5234da 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
@@ -1921,7 +1921,7 @@ static int kv_dpm_set_power_state(void *handle) | |||
1921 | int ret; | 1921 | int ret; |
1922 | 1922 | ||
1923 | if (pi->bapm_enable) { | 1923 | if (pi->bapm_enable) { |
1924 | ret = amdgpu_kv_smc_bapm_enable(adev, adev->pm.dpm.ac_power); | 1924 | ret = amdgpu_kv_smc_bapm_enable(adev, adev->pm.ac_power); |
1925 | if (ret) { | 1925 | if (ret) { |
1926 | DRM_ERROR("amdgpu_kv_smc_bapm_enable failed\n"); | 1926 | DRM_ERROR("amdgpu_kv_smc_bapm_enable failed\n"); |
1927 | return ret; | 1927 | return ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index b12d7c9d42a0..9567dd0a01bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
@@ -3480,7 +3480,7 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, | |||
3480 | disable_sclk_switching = true; | 3480 | disable_sclk_switching = true; |
3481 | } | 3481 | } |
3482 | 3482 | ||
3483 | if (adev->pm.dpm.ac_power) | 3483 | if (adev->pm.ac_power) |
3484 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | 3484 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; |
3485 | else | 3485 | else |
3486 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | 3486 | max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; |
@@ -3489,7 +3489,7 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, | |||
3489 | if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc) | 3489 | if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc) |
3490 | ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc; | 3490 | ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc; |
3491 | } | 3491 | } |
3492 | if (adev->pm.dpm.ac_power == false) { | 3492 | if (adev->pm.ac_power == false) { |
3493 | for (i = 0; i < ps->performance_level_count; i++) { | 3493 | for (i = 0; i < ps->performance_level_count; i++) { |
3494 | if (ps->performance_levels[i].mclk > max_limits->mclk) | 3494 | if (ps->performance_levels[i].mclk > max_limits->mclk) |
3495 | ps->performance_levels[i].mclk = max_limits->mclk; | 3495 | ps->performance_levels[i].mclk = max_limits->mclk; |