[PATCH 096/165] drm/radeon/dpm/rv6xx: restructure code

2013-06-26 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Needed to properly handle dynamic state adjustment.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/rv6xx_dpm.c |  115 +--
 1 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c 
b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index fa4beb2..e8f07b1 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -961,9 +961,11 @@ static void rv6xx_program_voltage_gpio_pins(struct 
radeon_device *rdev)
 rv6xx_get_master_voltage_mask(rdev));
 }

-static void rv6xx_enable_static_voltage_control(struct radeon_device *rdev, 
bool enable)
+static void rv6xx_enable_static_voltage_control(struct radeon_device *rdev,
+   struct radeon_ps *new_ps,
+   bool enable)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);

if (enable)
radeon_atom_set_voltage(rdev,
@@ -1039,9 +1041,10 @@ static void rv6xx_calculate_ap(struct radeon_device 
*rdev,

 }

-static void rv6xx_calculate_stepping_parameters(struct radeon_device *rdev)
+static void rv6xx_calculate_stepping_parameters(struct radeon_device *rdev,
+   struct radeon_ps *new_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);

rv6xx_calculate_engine_speed_stepping_parameters(rdev, new_state);
rv6xx_calculate_memory_clock_stepping_parameters(rdev, new_state);
@@ -1191,10 +1194,12 @@ static void rv6xx_program_display_gap(struct 
radeon_device *rdev)
WREG32(CG_DISPLAY_GAP_CNTL, tmp);
 }

-static void rv6xx_set_sw_voltage_to_safe(struct radeon_device *rdev)
+static void rv6xx_set_sw_voltage_to_safe(struct radeon_device *rdev,
+struct radeon_ps *new_ps,
+struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);
u16 safe_voltage;

safe_voltage = (new_state->low.vddc >= old_state->low.vddc) ?
@@ -1207,9 +1212,10 @@ static void rv6xx_set_sw_voltage_to_safe(struct 
radeon_device *rdev)
 ~SW_GPIO_INDEX_MASK);
 }

-static void rv6xx_set_sw_voltage_to_low(struct radeon_device *rdev)
+static void rv6xx_set_sw_voltage_to_low(struct radeon_device *rdev,
+   struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);

rv6xx_program_voltage_stepping_entry(rdev, R600_POWER_LEVEL_CTXSW,
 old_state->low.vddc);
@@ -1218,10 +1224,12 @@ static void rv6xx_set_sw_voltage_to_low(struct 
radeon_device *rdev)
~SW_GPIO_INDEX_MASK);
 }

-static void rv6xx_set_safe_backbias(struct radeon_device *rdev)
+static void rv6xx_set_safe_backbias(struct radeon_device *rdev,
+   struct radeon_ps *new_ps,
+   struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);

if ((new_state->low.flags & ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE) &&
(old_state->low.flags & ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE))
@@ -1230,10 +1238,12 @@ static void rv6xx_set_safe_backbias(struct 
radeon_device *rdev)
WREG32_P(GENERAL_PWRMGT, 0, ~BACKBIAS_VALUE);
 }

-static void rv6xx_set_safe_pcie_gen2(struct radeon_device *rdev)
+static void rv6xx_set_safe_pcie_gen2(struct radeon_device *rdev,
+struct radeon_ps *new_ps,
+struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);

if ((new_state->low.flags & ATOM_PPLIB_R600_FLAGS_PCIEGEN2) !=
(old_state->low.flags & ATOM_PPLIB_R600_FLAGS_PCIEGEN2))
@@ -1290,10 +1300,12 @@ static int rv6xx_step_sw_voltage(struct radeon_device 
*rdev,
return 0;
 }

-static int rv6xx_step_voltage_if_increasing(struct radeon_device *rdev)
+static int rv6xx_step_voltage_if_inc

[PATCH 096/165] drm/radeon/dpm/rv6xx: restructure code

2013-06-26 Thread alexdeucher
From: Alex Deucher 

Needed to properly handle dynamic state adjustment.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/rv6xx_dpm.c |  115 +--
 1 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c 
b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index fa4beb2..e8f07b1 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -961,9 +961,11 @@ static void rv6xx_program_voltage_gpio_pins(struct 
radeon_device *rdev)
 rv6xx_get_master_voltage_mask(rdev));
 }
 
-static void rv6xx_enable_static_voltage_control(struct radeon_device *rdev, 
bool enable)
+static void rv6xx_enable_static_voltage_control(struct radeon_device *rdev,
+   struct radeon_ps *new_ps,
+   bool enable)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
 
if (enable)
radeon_atom_set_voltage(rdev,
@@ -1039,9 +1041,10 @@ static void rv6xx_calculate_ap(struct radeon_device 
*rdev,
 
 }
 
-static void rv6xx_calculate_stepping_parameters(struct radeon_device *rdev)
+static void rv6xx_calculate_stepping_parameters(struct radeon_device *rdev,
+   struct radeon_ps *new_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
 
rv6xx_calculate_engine_speed_stepping_parameters(rdev, new_state);
rv6xx_calculate_memory_clock_stepping_parameters(rdev, new_state);
@@ -1191,10 +1194,12 @@ static void rv6xx_program_display_gap(struct 
radeon_device *rdev)
WREG32(CG_DISPLAY_GAP_CNTL, tmp);
 }
 
-static void rv6xx_set_sw_voltage_to_safe(struct radeon_device *rdev)
+static void rv6xx_set_sw_voltage_to_safe(struct radeon_device *rdev,
+struct radeon_ps *new_ps,
+struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);
u16 safe_voltage;
 
safe_voltage = (new_state->low.vddc >= old_state->low.vddc) ?
@@ -1207,9 +1212,10 @@ static void rv6xx_set_sw_voltage_to_safe(struct 
radeon_device *rdev)
 ~SW_GPIO_INDEX_MASK);
 }
 
-static void rv6xx_set_sw_voltage_to_low(struct radeon_device *rdev)
+static void rv6xx_set_sw_voltage_to_low(struct radeon_device *rdev,
+   struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);
 
rv6xx_program_voltage_stepping_entry(rdev, R600_POWER_LEVEL_CTXSW,
 old_state->low.vddc);
@@ -1218,10 +1224,12 @@ static void rv6xx_set_sw_voltage_to_low(struct 
radeon_device *rdev)
~SW_GPIO_INDEX_MASK);
 }
 
-static void rv6xx_set_safe_backbias(struct radeon_device *rdev)
+static void rv6xx_set_safe_backbias(struct radeon_device *rdev,
+   struct radeon_ps *new_ps,
+   struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);
 
if ((new_state->low.flags & ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE) &&
(old_state->low.flags & ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE))
@@ -1230,10 +1238,12 @@ static void rv6xx_set_safe_backbias(struct 
radeon_device *rdev)
WREG32_P(GENERAL_PWRMGT, 0, ~BACKBIAS_VALUE);
 }
 
-static void rv6xx_set_safe_pcie_gen2(struct radeon_device *rdev)
+static void rv6xx_set_safe_pcie_gen2(struct radeon_device *rdev,
+struct radeon_ps *new_ps,
+struct radeon_ps *old_ps)
 {
-   struct rv6xx_ps *new_state = rv6xx_get_ps(rdev->pm.dpm.requested_ps);
-   struct rv6xx_ps *old_state = rv6xx_get_ps(rdev->pm.dpm.current_ps);
+   struct rv6xx_ps *new_state = rv6xx_get_ps(new_ps);
+   struct rv6xx_ps *old_state = rv6xx_get_ps(old_ps);
 
if ((new_state->low.flags & ATOM_PPLIB_R600_FLAGS_PCIEGEN2) !=
(old_state->low.flags & ATOM_PPLIB_R600_FLAGS_PCIEGEN2))
@@ -1290,10 +1300,12 @@ static int rv6xx_step_sw_voltage(struct radeon_device 
*rdev,
return 0;
 }
 
-static int rv6xx_step_voltage_if_increasing(struct radeon_device *rdev)
+static int rv6xx_step_