diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c index e952aa14ae4c837b298fe03989e4d3d8f52242eb..f26cefe2432f7866dec37ff0f653348ee1a49df3 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.c +++ b/drivers/gpu/drm/radeon/btc_dpm.c @@ -2062,18 +2062,12 @@ static void btc_init_stutter_mode(struct radeon_device *rdev) static void btc_apply_state_adjust_rules(struct radeon_device *rdev, struct radeon_ps *rps) { - struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); struct rv7xx_ps *ps = rv770_get_ps(rps); struct radeon_clock_and_voltage_limits *max_limits; bool disable_mclk_switching; u32 mclk, sclk; u16 vddc, vddci; - /* point to the hw copy since this function will modify the ps */ - eg_pi->hw_ps = *ps; - rdev->pm.dpm.hw_ps.ps_priv = &eg_pi->hw_ps; - ps = &eg_pi->hw_ps; - if (rdev->pm.dpm.new_active_crtc_count > 1) disable_mclk_switching = true; else @@ -2222,6 +2216,28 @@ static void btc_apply_state_adjust_rules(struct radeon_device *rdev, ps->high.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2; } +static void btc_update_current_ps(struct radeon_device *rdev, + struct radeon_ps *rps) +{ + struct rv7xx_ps *new_ps = rv770_get_ps(rps); + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + + eg_pi->current_rps = *rps; + eg_pi->current_ps = *new_ps; + eg_pi->current_rps.ps_priv = &eg_pi->current_ps; +} + +static void btc_update_requested_ps(struct radeon_device *rdev, + struct radeon_ps *rps) +{ + struct rv7xx_ps *new_ps = rv770_get_ps(rps); + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + + eg_pi->requested_rps = *rps; + eg_pi->requested_ps = *new_ps; + eg_pi->requested_rps.ps_priv = &eg_pi->requested_ps; +} + void btc_dpm_reset_asic(struct radeon_device *rdev) { rv770_restrict_performance_levels_before_switch(rdev); @@ -2230,13 +2246,24 @@ void btc_dpm_reset_asic(struct radeon_device *rdev) rv770_set_boot_state(rdev); } -int btc_dpm_set_power_state(struct radeon_device *rdev) +int btc_dpm_pre_set_power_state(struct radeon_device *rdev) { struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); - struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps; - struct radeon_ps *old_ps = rdev->pm.dpm.current_ps; + struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps; + struct radeon_ps *new_ps = &requested_ps; + + btc_update_requested_ps(rdev, new_ps); + + btc_apply_state_adjust_rules(rdev, &eg_pi->requested_rps); - btc_apply_state_adjust_rules(rdev, new_ps); + return 0; +} + +int btc_dpm_set_power_state(struct radeon_device *rdev) +{ + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct radeon_ps *new_ps = &eg_pi->requested_rps; + struct radeon_ps *old_ps = &eg_pi->current_rps; btc_disable_ulv(rdev); btc_set_boot_state_timing(rdev); @@ -2274,6 +2301,14 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) return 0; } +void btc_dpm_post_set_power_state(struct radeon_device *rdev) +{ + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct radeon_ps *new_ps = &eg_pi->requested_rps; + + btc_update_current_ps(rdev, new_ps); +} + int btc_dpm_enable(struct radeon_device *rdev) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); @@ -2369,6 +2404,8 @@ int btc_dpm_enable(struct radeon_device *rdev) btc_init_stutter_mode(rdev); + btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps); + return 0; }; @@ -2407,6 +2444,8 @@ void btc_dpm_disable(struct radeon_device *rdev) btc_reset_to_default(rdev); btc_stop_smc(rdev); cypress_enable_spread_spectrum(rdev, false); + + btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps); } void btc_dpm_setup_asic(struct radeon_device *rdev) @@ -2591,3 +2630,25 @@ void btc_dpm_fini(struct radeon_device *rdev) kfree(rdev->pm.dpm.priv); r600_free_extended_power_table(rdev); } + +u32 btc_dpm_get_sclk(struct radeon_device *rdev, bool low) +{ + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps); + + if (low) + return requested_state->low.sclk; + else + return requested_state->high.sclk; +} + +u32 btc_dpm_get_mclk(struct radeon_device *rdev, bool low) +{ + struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps); + + if (low) + return requested_state->low.mclk; + else + return requested_state->high.mclk; +} diff --git a/drivers/gpu/drm/radeon/cypress_dpm.h b/drivers/gpu/drm/radeon/cypress_dpm.h index 5b19364a5810f4cd733ac5d6852b6507138bb972..4c3f18c69f4f3f591ced7f0b775cb9474a329c9d 100644 --- a/drivers/gpu/drm/radeon/cypress_dpm.h +++ b/drivers/gpu/drm/radeon/cypress_dpm.h @@ -88,7 +88,10 @@ struct evergreen_power_info { struct at ats[2]; /* smc offsets */ u16 mc_reg_table_start; - struct rv7xx_ps hw_ps; + struct radeon_ps current_rps; + struct rv7xx_ps current_ps; + struct radeon_ps requested_rps; + struct rv7xx_ps requested_ps; }; #define CYPRESS_HASI_DFLT 400000 diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index c99fae7b6f7a1b77e274b148b9a32ca284d5b37b..fb11ba79b3881029b6171de7c84c12c2a37a0f84 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c @@ -1749,11 +1749,13 @@ static struct radeon_asic btc_asic = { .setup_asic = &btc_dpm_setup_asic, .enable = &btc_dpm_enable, .disable = &btc_dpm_disable, + .pre_set_power_state = &btc_dpm_pre_set_power_state, .set_power_state = &btc_dpm_set_power_state, + .post_set_power_state = &btc_dpm_post_set_power_state, .display_configuration_changed = &cypress_dpm_display_configuration_changed, .fini = &btc_dpm_fini, - .get_sclk = &rv770_dpm_get_sclk, - .get_mclk = &rv770_dpm_get_mclk, + .get_sclk = &btc_dpm_get_sclk, + .get_mclk = &btc_dpm_get_mclk, .print_power_state = &rv770_dpm_print_power_state, }, .pflip = { diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 4870ef97b00619e48ee12b189d0e414c9033be83..83e6bf4ac4085fecc8b6b93a48bbbb6378564b54 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -542,8 +542,12 @@ int btc_dpm_init(struct radeon_device *rdev); void btc_dpm_setup_asic(struct radeon_device *rdev); int btc_dpm_enable(struct radeon_device *rdev); void btc_dpm_disable(struct radeon_device *rdev); +int btc_dpm_pre_set_power_state(struct radeon_device *rdev); int btc_dpm_set_power_state(struct radeon_device *rdev); +void btc_dpm_post_set_power_state(struct radeon_device *rdev); void btc_dpm_fini(struct radeon_device *rdev); +u32 btc_dpm_get_sclk(struct radeon_device *rdev, bool low); +u32 btc_dpm_get_mclk(struct radeon_device *rdev, bool low); int sumo_dpm_init(struct radeon_device *rdev); int sumo_dpm_enable(struct radeon_device *rdev); void sumo_dpm_disable(struct radeon_device *rdev);