2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-29 15:43:59 +08:00

drm/amdgpu: support per device powerplay enablement (v2)

The amdgu_powerplay variable is global for multiple GPU instances.

v2: fold in Flora's module option change, protect adev reference in
macros

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
This commit is contained in:
Jammy Zhou 2015-11-10 18:31:08 -05:00 committed by Alex Deucher
parent 8804b8d5b0
commit e61710c59d
6 changed files with 65 additions and 61 deletions

View File

@ -2040,6 +2040,7 @@ struct amdgpu_device {
/* powerplay */ /* powerplay */
struct amd_powerplay powerplay; struct amd_powerplay powerplay;
bool pp_enabled;
/* dpm */ /* dpm */
struct amdgpu_pm pm; struct amdgpu_pm pm;
@ -2268,58 +2269,58 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
#define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e)) #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e))
#define amdgpu_dpm_get_temperature(adev) \ #define amdgpu_dpm_get_temperature(adev) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \ (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \
(adev)->pm.funcs->get_temperature((adev)) (adev)->pm.funcs->get_temperature((adev))
#define amdgpu_dpm_set_fan_control_mode(adev, m) \ #define amdgpu_dpm_set_fan_control_mode(adev, m) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \ (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \
(adev)->pm.funcs->set_fan_control_mode((adev), (m)) (adev)->pm.funcs->set_fan_control_mode((adev), (m))
#define amdgpu_dpm_get_fan_control_mode(adev) \ #define amdgpu_dpm_get_fan_control_mode(adev) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \ (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \
(adev)->pm.funcs->get_fan_control_mode((adev)) (adev)->pm.funcs->get_fan_control_mode((adev))
#define amdgpu_dpm_set_fan_speed_percent(adev, s) \ #define amdgpu_dpm_set_fan_speed_percent(adev, s) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
(adev)->pm.funcs->set_fan_speed_percent((adev), (s)) (adev)->pm.funcs->set_fan_speed_percent((adev), (s))
#define amdgpu_dpm_get_fan_speed_percent(adev, s) \ #define amdgpu_dpm_get_fan_speed_percent(adev, s) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
(adev)->pm.funcs->get_fan_speed_percent((adev), (s)) (adev)->pm.funcs->get_fan_speed_percent((adev), (s))
#define amdgpu_dpm_get_sclk(adev, l) \ #define amdgpu_dpm_get_sclk(adev, l) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \ (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
(adev)->pm.funcs->get_sclk((adev), (l)) (adev)->pm.funcs->get_sclk((adev), (l))
#define amdgpu_dpm_get_mclk(adev, l) \ #define amdgpu_dpm_get_mclk(adev, l) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \ (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \
(adev)->pm.funcs->get_mclk((adev), (l)) (adev)->pm.funcs->get_mclk((adev), (l))
#define amdgpu_dpm_force_performance_level(adev, l) \ #define amdgpu_dpm_force_performance_level(adev, l) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \ (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \
(adev)->pm.funcs->force_performance_level((adev), (l)) (adev)->pm.funcs->force_performance_level((adev), (l))
#define amdgpu_dpm_powergate_uvd(adev, g) \ #define amdgpu_dpm_powergate_uvd(adev, g) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \ (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \
(adev)->pm.funcs->powergate_uvd((adev), (g)) (adev)->pm.funcs->powergate_uvd((adev), (g))
#define amdgpu_dpm_powergate_vce(adev, g) \ #define amdgpu_dpm_powergate_vce(adev, g) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \ (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \
(adev)->pm.funcs->powergate_vce((adev), (g)) (adev)->pm.funcs->powergate_vce((adev), (g))
#define amdgpu_dpm_debugfs_print_current_performance_level(adev, m) \ #define amdgpu_dpm_debugfs_print_current_performance_level(adev, m) \
amdgpu_powerplay ? \ (adev)->pp_enabled ? \
(adev)->powerplay.pp_funcs->print_current_performance_level((adev)->powerplay.pp_handle, (m)) : \ (adev)->powerplay.pp_funcs->print_current_performance_level((adev)->powerplay.pp_handle, (m)) : \
(adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m)) (adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m))

View File

@ -82,7 +82,7 @@ int amdgpu_enable_scheduler = 1;
int amdgpu_sched_jobs = 32; int amdgpu_sched_jobs = 32;
int amdgpu_sched_hw_submission = 2; int amdgpu_sched_hw_submission = 2;
int amdgpu_enable_semaphores = 0; int amdgpu_enable_semaphores = 0;
int amdgpu_powerplay = 0; int amdgpu_powerplay = -1;
MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@ -166,7 +166,7 @@ MODULE_PARM_DESC(enable_semaphores, "Enable semaphores (1 = enable, 0 = disable
module_param_named(enable_semaphores, amdgpu_enable_semaphores, int, 0644); module_param_named(enable_semaphores, amdgpu_enable_semaphores, int, 0644);
#ifdef CONFIG_DRM_AMD_POWERPLAY #ifdef CONFIG_DRM_AMD_POWERPLAY
MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable (default))"); MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable, -1 = auto (default))");
module_param_named(powerplay, amdgpu_powerplay, int, 0444); module_param_named(powerplay, amdgpu_powerplay, int, 0444);
#endif #endif

View File

@ -36,7 +36,7 @@ static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev) void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
{ {
if (amdgpu_powerplay) if (adev->pp_enabled)
/* TODO */ /* TODO */
return; return;
@ -60,7 +60,7 @@ static ssize_t amdgpu_get_dpm_state(struct device *dev,
struct amdgpu_device *adev = ddev->dev_private; struct amdgpu_device *adev = ddev->dev_private;
enum amd_pm_state_type pm; enum amd_pm_state_type pm;
if (amdgpu_powerplay) { if (adev->pp_enabled) {
pm = amdgpu_dpm_get_current_power_state(adev); pm = amdgpu_dpm_get_current_power_state(adev);
} else } else
pm = adev->pm.dpm.user_state; pm = adev->pm.dpm.user_state;
@ -90,7 +90,7 @@ static ssize_t amdgpu_set_dpm_state(struct device *dev,
goto fail; goto fail;
} }
if (amdgpu_powerplay) { if (adev->pp_enabled) {
amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_ENABLE_USER_STATE, &state, NULL); amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_ENABLE_USER_STATE, &state, NULL);
} else { } else {
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
@ -113,7 +113,7 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev); struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = ddev->dev_private; struct amdgpu_device *adev = ddev->dev_private;
if (amdgpu_powerplay) { if (adev->pp_enabled) {
enum amd_dpm_forced_level level; enum amd_dpm_forced_level level;
level = amdgpu_dpm_get_performance_level(adev); level = amdgpu_dpm_get_performance_level(adev);
@ -151,7 +151,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
goto fail; goto fail;
} }
if (amdgpu_powerplay) if (adev->pp_enabled)
amdgpu_dpm_force_performance_level(adev, level); amdgpu_dpm_force_performance_level(adev, level);
else { else {
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
@ -184,7 +184,7 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
struct amdgpu_device *adev = dev_get_drvdata(dev); struct amdgpu_device *adev = dev_get_drvdata(dev);
int temp; int temp;
if (!amdgpu_powerplay && !adev->pm.funcs->get_temperature) if (!adev->pp_enabled && !adev->pm.funcs->get_temperature)
temp = 0; temp = 0;
else else
temp = amdgpu_dpm_get_temperature(adev); temp = amdgpu_dpm_get_temperature(adev);
@ -215,7 +215,7 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,
struct amdgpu_device *adev = dev_get_drvdata(dev); struct amdgpu_device *adev = dev_get_drvdata(dev);
u32 pwm_mode = 0; u32 pwm_mode = 0;
if (!amdgpu_powerplay && !adev->pm.funcs->get_fan_control_mode) if (!adev->pp_enabled && !adev->pm.funcs->get_fan_control_mode)
return -EINVAL; return -EINVAL;
pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
@ -233,7 +233,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,
int err; int err;
int value; int value;
if (!amdgpu_powerplay && !adev->pm.funcs->set_fan_control_mode) if (!adev->pp_enabled && !adev->pm.funcs->set_fan_control_mode)
return -EINVAL; return -EINVAL;
err = kstrtoint(buf, 10, &value); err = kstrtoint(buf, 10, &value);
@ -340,7 +340,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
return 0; return 0;
if (amdgpu_powerplay) if (adev->pp_enabled)
return effective_mode; return effective_mode;
/* Skip fan attributes if fan is not present */ /* Skip fan attributes if fan is not present */
@ -674,7 +674,7 @@ done:
void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable) void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
{ {
if (amdgpu_powerplay) if (adev->pp_enabled)
amdgpu_dpm_powergate_uvd(adev, !enable); amdgpu_dpm_powergate_uvd(adev, !enable);
else { else {
if (adev->pm.funcs->powergate_uvd) { if (adev->pm.funcs->powergate_uvd) {
@ -701,7 +701,7 @@ void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)
void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
{ {
if (amdgpu_powerplay) if (adev->pp_enabled)
amdgpu_dpm_powergate_vce(adev, !enable); amdgpu_dpm_powergate_vce(adev, !enable);
else { else {
if (adev->pm.funcs->powergate_vce) { if (adev->pm.funcs->powergate_vce) {
@ -729,7 +729,7 @@ void amdgpu_pm_print_power_states(struct amdgpu_device *adev)
{ {
int i; int i;
if (amdgpu_powerplay) if (adev->pp_enabled)
/* TO DO */ /* TO DO */
return; return;
@ -745,7 +745,7 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
if (adev->pm.sysfs_initialized) if (adev->pm.sysfs_initialized)
return 0; return 0;
if (!amdgpu_powerplay) { if (!adev->pp_enabled) {
if (adev->pm.funcs->get_temperature == NULL) if (adev->pm.funcs->get_temperature == NULL)
return 0; return 0;
} }
@ -798,7 +798,7 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
if (!adev->pm.dpm_enabled) if (!adev->pm.dpm_enabled)
return; return;
if (amdgpu_powerplay) { if (adev->pp_enabled) {
int i = 0; int i = 0;
amdgpu_display_bandwidth_update(adev); amdgpu_display_bandwidth_update(adev);
@ -852,7 +852,7 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
seq_printf(m, "dpm not enabled\n"); seq_printf(m, "dpm not enabled\n");
return 0; return 0;
} }
if (amdgpu_powerplay) { if (adev->pp_enabled) {
amdgpu_dpm_debugfs_print_current_performance_level(adev, m); amdgpu_dpm_debugfs_print_current_performance_level(adev, m);
} else { } else {
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);

View File

@ -40,7 +40,7 @@ static int amdgpu_powerplay_init(struct amdgpu_device *adev)
amd_pp = &(adev->powerplay); amd_pp = &(adev->powerplay);
if (amdgpu_powerplay) { if (adev->pp_enabled) {
#ifdef CONFIG_DRM_AMD_POWERPLAY #ifdef CONFIG_DRM_AMD_POWERPLAY
struct amd_pp_init *pp_init; struct amd_pp_init *pp_init;
@ -100,11 +100,14 @@ static int amdgpu_pp_early_init(void *handle)
switch (adev->asic_type) { switch (adev->asic_type) {
case CHIP_TONGA: case CHIP_TONGA:
case CHIP_FIJI: case CHIP_FIJI:
amdgpu_powerplay = 1; adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true;
break; break;
default: default:
adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false;
break; break;
} }
#else
adev->pp_enabled = false;
#endif #endif
ret = amdgpu_powerplay_init(adev); ret = amdgpu_powerplay_init(adev);
@ -127,7 +130,7 @@ static int amdgpu_pp_sw_init(void *handle)
adev->powerplay.pp_handle); adev->powerplay.pp_handle);
#ifdef CONFIG_DRM_AMD_POWERPLAY #ifdef CONFIG_DRM_AMD_POWERPLAY
if (amdgpu_powerplay) { if (adev->pp_enabled) {
adev->pm.dpm_enabled = true; adev->pm.dpm_enabled = true;
amdgpu_pm_sysfs_init(adev); amdgpu_pm_sysfs_init(adev);
} }
@ -148,7 +151,7 @@ static int amdgpu_pp_sw_fini(void *handle)
return ret; return ret;
#ifdef CONFIG_DRM_AMD_POWERPLAY #ifdef CONFIG_DRM_AMD_POWERPLAY
if (amdgpu_powerplay) { if (adev->pp_enabled) {
amdgpu_pm_sysfs_fini(adev); amdgpu_pm_sysfs_fini(adev);
amd_powerplay_fini(adev->powerplay.pp_handle); amd_powerplay_fini(adev->powerplay.pp_handle);
} }
@ -162,7 +165,7 @@ static int amdgpu_pp_hw_init(void *handle)
int ret = 0; int ret = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
if (amdgpu_powerplay && adev->firmware.smu_load) if (adev->pp_enabled && adev->firmware.smu_load)
amdgpu_ucode_init_bo(adev); amdgpu_ucode_init_bo(adev);
if (adev->powerplay.ip_funcs->hw_init) if (adev->powerplay.ip_funcs->hw_init)
@ -181,7 +184,7 @@ static int amdgpu_pp_hw_fini(void *handle)
ret = adev->powerplay.ip_funcs->hw_fini( ret = adev->powerplay.ip_funcs->hw_fini(
adev->powerplay.pp_handle); adev->powerplay.pp_handle);
if (amdgpu_powerplay && adev->firmware.smu_load) if (adev->pp_enabled && adev->firmware.smu_load)
amdgpu_ucode_fini_bo(adev); amdgpu_ucode_fini_bo(adev);
return ret; return ret;

View File

@ -2902,7 +2902,7 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
gfx_v8_0_rlc_reset(adev); gfx_v8_0_rlc_reset(adev);
if (!amdgpu_powerplay) { if (!adev->pp_enabled) {
if (!adev->firmware.smu_load) { if (!adev->firmware.smu_load) {
/* legacy rlc firmware loading */ /* legacy rlc firmware loading */
r = gfx_v8_0_rlc_load_microcode(adev); r = gfx_v8_0_rlc_load_microcode(adev);
@ -3804,7 +3804,7 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)
if (!(adev->flags & AMD_IS_APU)) if (!(adev->flags & AMD_IS_APU))
gfx_v8_0_enable_gui_idle_interrupt(adev, false); gfx_v8_0_enable_gui_idle_interrupt(adev, false);
if (!amdgpu_powerplay) { if (!adev->pp_enabled) {
if (!adev->firmware.smu_load) { if (!adev->firmware.smu_load) {
/* legacy firmware loading */ /* legacy firmware loading */
r = gfx_v8_0_cp_gfx_load_microcode(adev); r = gfx_v8_0_cp_gfx_load_microcode(adev);

View File

@ -727,7 +727,7 @@ static int sdma_v3_0_start(struct amdgpu_device *adev)
{ {
int r, i; int r, i;
if (!amdgpu_powerplay) { if (!adev->pp_enabled) {
if (!adev->firmware.smu_load) { if (!adev->firmware.smu_load) {
r = sdma_v3_0_load_microcode(adev); r = sdma_v3_0_load_microcode(adev);
if (r) if (r)