Skip to contentSkip to conversation

drm/radeon/kms: simplify storing current and requested PM mode

PATCH Superseded Rafał Miłecki 2 participants 10 messages Feb 17, 2010 – Feb 18, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon/kms: simplify storing current and requested PM mode

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

---
 drivers/gpu/drm/radeon/radeon.h          |   13 +++---
 drivers/gpu/drm/radeon/radeon_atombios.c |   22 +++-------
 drivers/gpu/drm/radeon/radeon_combios.c  |    9 +++-
 drivers/gpu/drm/radeon/radeon_pm.c       |   66 +++++++++++++++++-------------
 4 files changed, 56 insertions(+), 54 deletions(-)
drivers/gpu/drm/radeon/radeon.h +6 -7
index 993cdf2..b533411 100644
@@ -652,9 +652,6 @@ struct radeon_power_state {
 	struct radeon_pm_clock_info clock_info[8];
 	/* number of valid clock modes in this power state */
 	int num_clock_modes;
-	/* currently selected clock mode */
-	struct radeon_pm_clock_info *current_clock_mode;
-	struct radeon_pm_clock_info *requested_clock_mode;
 	struct radeon_pm_clock_info *default_clock_mode;
 	/* non clock info about this state */
 	struct radeon_pm_non_clock_info non_clock_info;
@@ -684,10 +681,12 @@ struct radeon_pm {
 	/* XXX: use a define for num power modes */
 	struct radeon_power_state power_state[8];
 	/* number of valid power states */
-	int                     num_power_states;
-	struct radeon_power_state *current_power_state;
-	struct radeon_power_state *requested_power_state;
-	struct radeon_power_state *default_power_state;
+	int			num_power_states;
+	struct radeon_pm_clock_info	current_clock_mode;
+	int				current_pcie_lanes;
+	struct radeon_pm_clock_info	requested_clock_mode;
+	int				requested_pcie_lanes;
+	struct radeon_power_state	*default_power_state;
 };
 
 
drivers/gpu/drm/radeon/radeon_atombios.c +6 -16
index 4f7dbce..b8e7e81 100644
@@ -1441,7 +1441,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 	power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
 	rdev->pm.default_power_state = NULL;
-	rdev->pm.current_power_state = NULL;
 
 	if (power_info) {
 		if (frev < 4) {
@@ -1508,11 +1507,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.power_state[state_index].type =
 							POWER_STATE_TYPE_DEFAULT;
 						rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1577,11 +1573,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.power_state[state_index].type =
 							POWER_STATE_TYPE_DEFAULT;
 						rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1652,11 +1645,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.power_state[state_index].type =
 							POWER_STATE_TYPE_DEFAULT;
 						rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1756,11 +1746,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.power_state[state_index].type =
 							POWER_STATE_TYPE_DEFAULT;
 						rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[mode_index - 1];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[mode_index - 1];
 					}
 					state_index++;
 				}
@@ -1779,18 +1766,21 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 		rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
 		rdev->pm.power_state[state_index].default_clock_mode =
 			&rdev->pm.power_state[state_index].clock_info[0];
-		rdev->pm.power_state[state_index].current_clock_mode =
-			&rdev->pm.power_state[state_index].clock_info[0];
 		rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
 		if (rdev->asic->get_pcie_lanes)
 			rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
 		else
 			rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
 		rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-		rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 		state_index++;
 	}
 	rdev->pm.num_power_states = state_index;
+
+	memcpy((unsigned char *)&rdev->pm.current_clock_mode,
+		(unsigned char *)rdev->pm.default_power_state->default_clock_mode,
+		sizeof(struct radeon_pm_clock_info));
+	rdev->pm.current_pcie_lanes =
+		rdev->pm.default_power_state->non_clock_info.pcie_lanes;
 }
 
 void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
drivers/gpu/drm/radeon/radeon_combios.c +6 -3
index 9989d22..efc190e 100644
@@ -2358,7 +2358,6 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
 	int state_index = 0;
 
 	rdev->pm.default_power_state = NULL;
-	rdev->pm.current_power_state = NULL;
 
 	if (rdev->flags & RADEON_IS_MOBILITY) {
 		offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
@@ -2447,15 +2446,19 @@ default_mode:
 	rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
 	rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
 	rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-	rdev->pm.power_state[state_index].current_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
 	rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
 	if (rdev->asic->get_pcie_lanes)
 		rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
 	else
 		rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
 	rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-	rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 	rdev->pm.num_power_states = state_index + 1;
+
+	memcpy((unsigned char *)&rdev->pm.current_clock_mode,
+		(unsigned char *)rdev->pm.default_power_state->default_clock_mode,
+		sizeof(struct radeon_pm_clock_info));
+	rdev->pm.current_pcie_lanes =
+		rdev->pm.default_power_state->non_clock_info.pcie_lanes;
 }
 
 void radeon_external_tmds_setup(struct drm_encoder *encoder)
drivers/gpu/drm/radeon/radeon_pm.c +38 -28

89 lines not on this page · raw message

Signature · 12 lines
1.6.4.2


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#1 lore raw

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

NACK. Why are you replacing pointers with copies of of the power state structs? The idea is to keep one array of power states and pointers to the current one, default one, and requested one. Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Alex

Quoted 246 lines

---
 drivers/gpu/drm/radeon/radeon.h          |   13 +++--- drivers/gpu/drm/radeon/radeon_atombios.c |   22 +++------- drivers/gpu/drm/radeon/radeon_combios.c  |    9 +++- drivers/gpu/drm/radeon/radeon_pm.c       |   66 +++++++++++++++++-------------

 4 files changed, 56 insertions(+), 54 deletions(-)
drivers/gpu/drm/radeon/radeon.h +6 -7
index 993cdf2..b533411 100644
@@ -652,9 +652,6 @@ struct radeon_power_state {
        struct radeon_pm_clock_info clock_info[8];
        /* number of valid clock modes in this power state */
        int num_clock_modes;
-       /* currently selected clock mode */
-       struct radeon_pm_clock_info *current_clock_mode;
-       struct radeon_pm_clock_info *requested_clock_mode;
        struct radeon_pm_clock_info *default_clock_mode;
        /* non clock info about this state */
        struct radeon_pm_non_clock_info non_clock_info;
@@ -684,10 +681,12 @@ struct radeon_pm {
        /* XXX: use a define for num power modes */
        struct radeon_power_state power_state[8];
        /* number of valid power states */
-       int                     num_power_states;
-       struct radeon_power_state *current_power_state;
-       struct radeon_power_state *requested_power_state;
-       struct radeon_power_state *default_power_state;
+       int                     num_power_states;
+       struct radeon_pm_clock_info     current_clock_mode;
+       int                             current_pcie_lanes;
+       struct radeon_pm_clock_info     requested_clock_mode;
+       int                             requested_pcie_lanes;
+       struct radeon_power_state       *default_power_state;
  };
 
 
drivers/gpu/drm/radeon/radeon_atombios.c +0 -1
index 4f7dbce..b8e7e81 100644
@@ -1441,7 +1441,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
        rdev->pm.default_power_state = NULL;
-       rdev->pm.current_power_state = NULL;
 
        if (power_info) {
                if (frev < 4) {
@@ -1508,11 +1507,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)

                                               rdev->pm.power_state[state_index].type = POWER_STATE_TYPE_DEFAULT; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-                                               rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-                                               rdev->pm.power_state[state_index].current_clock_mode =
-                                                       &rdev->pm.power_state[state_index].clock_info[0]; }
                                       state_index++;
                                       break;

drivers/gpu/drm/radeon/radeon_atombios.c +0 -0
@@ -1577,11 +1573,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)

                                               rdev->pm.power_state[state_index].type = POWER_STATE_TYPE_DEFAULT; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-                                               rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-                                               rdev->pm.power_state[state_index].current_clock_mode =
-                                                       &rdev->pm.power_state[state_index].clock_info[0]; }
                                       state_index++;
                                       break;

drivers/gpu/drm/radeon/radeon_atombios.c +0 -0
@@ -1652,11 +1645,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)

                                               rdev->pm.power_state[state_index].type = POWER_STATE_TYPE_DEFAULT; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-                                               rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-                                               rdev->pm.power_state[state_index].current_clock_mode =
-                                                       &rdev->pm.power_state[state_index].clock_info[0]; }
                                       state_index++;
                                       break;

drivers/gpu/drm/radeon/radeon_atombios.c +0 -0
@@ -1756,11 +1746,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)

                                               rdev->pm.power_state[state_index].type = POWER_STATE_TYPE_DEFAULT; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-                                               rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[mode_index - 1];
-                                               rdev->pm.power_state[state_index].current_clock_mode =
-                                                       &rdev->pm.power_state[state_index].clock_info[mode_index - 1]; }
                                       state_index++;
                               }

drivers/gpu/drm/radeon/radeon_atombios.c +0 -0
@@ -1779,18 +1766,21 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
                rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;

               rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-               rdev->pm.power_state[state_index].current_clock_mode =
-                       &rdev->pm.power_state[state_index].clock_info[0]; rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
               if (rdev->asic->get_pcie_lanes) rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev); else
                       rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-               rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; state_index++;
       }
       rdev->pm.num_power_states = state_index;
+
+       memcpy((unsigned char *)&rdev->pm.current_clock_mode,
+               (unsigned char *)rdev->pm.default_power_state->default_clock_mode,
+               sizeof(struct radeon_pm_clock_info));
+       rdev->pm.current_pcie_lanes =
+               rdev->pm.default_power_state->non_clock_info.pcie_lanes;
 }

 void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)

drivers/gpu/drm/radeon/radeon_combios.c +0 -2
index 9989d22..efc190e 100644
@@ -2358,7 +2358,6 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
        int state_index = 0;
 
        rdev->pm.default_power_state = NULL;
-       rdev->pm.current_power_state = NULL;
 
        if (rdev->flags & RADEON_IS_MOBILITY) {
                offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
@@ -2447,15 +2446,19 @@ default_mode:
        rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
        rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
        rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-       rdev->pm.power_state[state_index].current_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
        rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
        if (rdev->asic->get_pcie_lanes)
                rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);

       else rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16; rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-       rdev->pm.current_power_state = &rdev->pm.power_state[state_index]; rdev->pm.num_power_states = state_index + 1;
+
+       memcpy((unsigned char *)&rdev->pm.current_clock_mode,
+               (unsigned char *)rdev->pm.default_power_state->default_clock_mode,
+               sizeof(struct radeon_pm_clock_info));
+       rdev->pm.current_pcie_lanes =
+               rdev->pm.default_power_state->non_clock_info.pcie_lanes; }

 void radeon_external_tmds_setup(struct drm_encoder *encoder)

drivers/gpu/drm/radeon/radeon_pm.c +3 -6
index 520197f..8426aff 100644
@@ -162,51 +162,61 @@ static struct radeon_pm_clock_info * radeon_pick_clock_mode(struct radeon_device
  static void radeon_get_power_state(struct radeon_device *rdev,
                                   enum radeon_pm_action action)
  {
+       struct radeon_power_state *requested_power_state;
+       struct radeon_pm_clock_info *requested_clock_mode;
+
        switch (action) {
-       case PM_ACTION_NONE:
-       default:
-               rdev->pm.requested_power_state = rdev->pm.current_power_state;
-               rdev->pm.requested_power_state->requested_clock_mode =
-                       rdev->pm.requested_power_state->current_clock_mode;
-               break;

       case PM_ACTION_MINIMUM:
-               rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_BATTERY);
-               rdev->pm.requested_power_state->requested_clock_mode =
-                       radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_LOW);
+               requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_BATTERY);
+               requested_clock_mode = radeon_pick_clock_mode(rdev, requested_power_state, POWER_MODE_TYPE_LOW); break;
       case PM_ACTION_DOWNCLOCK:
-               rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_POWERSAVE);
-               rdev->pm.requested_power_state->requested_clock_mode =
-                       radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_MID);
+               requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_POWERSAVE);
+               requested_clock_mode = radeon_pick_clock_mode(rdev, requested_power_state, POWER_MODE_TYPE_MID); break;
       case PM_ACTION_UPCLOCK:
-               rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_DEFAULT);
-               rdev->pm.requested_power_state->requested_clock_mode =
-                       radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_HIGH);
+               requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_DEFAULT);
+               requested_clock_mode = radeon_pick_clock_mode(rdev, requested_power_state, POWER_MODE_TYPE_HIGH); break;
+       case PM_ACTION_NONE:
+       default:
+               DRM_ERROR("Trying to get power state for not defined action!\n");
+               return;
       }
-       DRM_INFO("Requested: e: %d m: %d p: %d\n",
-                rdev->pm.requested_power_state->requested_clock_mode->sclk,
-                rdev->pm.requested_power_state->requested_clock_mode->mclk,
-                rdev->pm.requested_power_state->non_clock_info.pcie_lanes);

drivers/gpu/drm/radeon/radeon_pm.c +11 -0
+
+       memcpy((unsigned char *)&rdev->pm.requested_clock_mode,
+               (unsigned char *)requested_clock_mode,
+               sizeof(struct radeon_pm_clock_info));
+       rdev->pm.requested_pcie_lanes =
+               requested_power_state->non_clock_info.pcie_lanes;
+
+       DRM_INFO("Requested: eng: %d; mem: %d; lanes: %d\n",
+                rdev->pm.requested_clock_mode.sclk,
+                rdev->pm.requested_clock_mode.mclk,
+                rdev->pm.requested_pcie_lanes);

 }

 static void radeon_set_power_state(struct radeon_device *rdev) {
-       if (rdev->pm.requested_power_state == rdev->pm.current_power_state)
-               return;
+       struct radeon_pm_clock_info *req = &rdev->pm.requested_clock_mode;
+       struct radeon_pm_clock_info *curr = &rdev->pm.current_clock_mode;

drivers/gpu/drm/radeon/radeon_pm.c +6 -4
+
+       /*DRM_INFO("Current: eng: %d; mem: %d; lanes: %d\n",
+                curr->sclk, curr->mclk, rdev->pm.current_pcie_lanes);*/
+
+       DRM_INFO("Setting: eng: %d; mem: %d; lanes: %d\n",
+                req->sclk, req->mclk, rdev->pm.requested_pcie_lanes);
 
-       DRM_INFO("Setting: e: %d m: %d p: %d\n",
-                rdev->pm.requested_power_state->requested_clock_mode->sclk,
-                rdev->pm.requested_power_state->requested_clock_mode->mclk,
-                rdev->pm.requested_power_state->non_clock_info.pcie_lanes);

       /* set pcie lanes */
       /* set voltage */
+
       /* set engine clock */
-       radeon_set_engine_clock(rdev, rdev->pm.requested_power_state->requested_clock_mode->sclk);
-       /* set memory clock */
+       if (req->sclk != curr->sclk) {
+               radeon_set_engine_clock(rdev, req->sclk);
+               curr->sclk = req->sclk;
+       }

Quoted 9 lines

-       rdev->pm.current_power_state = rdev->pm.requested_power_state;
+       /* set memory clock */
 }

 int radeon_pm_init(struct radeon_device *rdev)
--
1.6.4.2

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#2 lore raw

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#3 lore raw
Quoted 21 lines · W dniu 18 lutego 2010 20:39 użytkownik Rafał Miłecki <[email protected]> napisał:

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

Quoted 6 lines

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

We may also consider hacking eng/mem clocks in requested mode for DPMS OFF. Maybe we could use chip's minimum instead lowest entry from AtomBIOS table?

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#4 lore raw

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 29 lines
Quoted 21 lines · W dniu 18 lutego 2010 20:39 użytkownik Rafał Miłecki <[email protected]> napisał:

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

Quoted 6 lines

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

Quoted 3 lines

We may also consider hacking eng/mem clocks in requested mode for DPMS OFF. Maybe we could use chip's minimum instead lowest entry from AtomBIOS table?

You could try, but for stability sake, we should try and stick to the tables; that's why there are there. Certain clock combinations just don't work well.

Alex

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

#5 lore raw

W dniu 18 lutego 2010 21:48 użytkownik Alex Deucher

Quoted 8 lines · <[email protected]> napisał:

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 3 lines

We may also consider hacking eng/mem clocks in requested mode for DPMS OFF. Maybe we could use chip's minimum instead lowest entry from AtomBIOS table?

You could try, but for stability sake, we should try and stick to the tables; that's why there are there.  Certain clock combinations just don't work well.

That's why I said "consider". This would need serious testing.

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#6 lore raw
In reply to Rafał Miłecki

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 18 lines

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Quoted 2 lines

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

What do you mean? There is not a pointer to every state. There are
only 3 (1. current, 2. requested 3. default) and they are not useless.

You have power states which defines the global state of a particular power state and then each power state has a set of 1 or more clock modes. So within a power state you can switch between clock modes. You need a set of clock pointers to track the current clock mode and the requested clock mode. You also need to know the current and requested power state so you need pointers there as well. We could get rid of the default pointers, but that's mostly there for convenience to avoid having to look up the default state when we need it.

For example, say you had the following power tables:

1. 3d power state:
a. low clock mode
b. medium clock mode
c. high clock mode

2. battery power state
a. low clock mode
b. medium clock mode
c. high clock mode

3. default power state
a. low clock mode
b. medium clock mode
c. high clock mode

By default state 3 would be selected so the current state would be '3' and the current clock mode would be a say 'a'. The current state pointer would point to '3' and the current clock mode pointer would point to 'a'. If you then went on battery, you'd want power state '2'. At that point, the requested state pointer points to '2' and one of the clock modes gets selected, lets say 'c', so the requested clock mode pointer points to 'c'. When we change the power state, we compare the current and requested power state pointers, if they are the same, no need to change anything. if they are different, we make the changes, then set the current power state pointer to the requested power state pointer and the current clock mode pointer to the requested clock mode pointer. Now say we are in power state '2' and clock mode 'c' (the high clock for power state '2') and the system goes idle; at the point we will want to stay in power state '2', but select clock mode 'a' (the low clock for power state '2'). So we compare the current and requested clock mode pointers and if they are not equal, we change the clock mode, at which time we update the current clock mode pointers to point to the requested clock.

Quoted 7 lines

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

That's fine for a local hack, but we don't want that upstream. If you are planning to hack all the power tables, then why even use them? I'm not sure we really change the lanes that often if at all on r6xx+.
In my experience, a lot of cards lock up when change the lanes or
fail to change properly which results in getting stuck at lower numbers of lanes.

Alex

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

#7 lore raw

W dniu 18 lutego 2010 21:47 użytkownik Alex Deucher

Quoted 63 lines · <[email protected]> napisał:

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 18 lines

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Quoted 2 lines

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

What do you mean?   There is not a pointer to every state.  There are only 3 (1. current, 2. requested 3. default) and they are not useless.

You have power states which defines the global state of a particular power state and then each power state has a set of 1 or more clock modes.  So within a power state you can switch between clock modes. You need a set of clock pointers to track the current clock mode and the requested clock mode.  You also need to know the current and requested power state so you need pointers there as well.  We could get rid of the default pointers, but that's mostly there for convenience to avoid having to look up the default state when we need it.

For example, say you had the following power tables:

1. 3d power state:
a. low clock mode
b. medium clock mode
c. high clock mode

2. battery power state
a. low clock mode
b. medium clock mode
c. high clock mode

3. default power state
a. low clock mode
b. medium clock mode
c. high clock mode

By default state 3 would be selected so the current state would be '3' and the current clock mode would be a say 'a'.  The current state pointer would point to '3' and the current clock mode pointer would point to 'a'.  If you then went on battery, you'd want power state '2'.  At that point, the requested state pointer points to '2' and one of the clock modes gets selected, lets say 'c', so the requested clock mode pointer points to 'c'.  When we change the power state, we compare the current and requested power state pointers, if they are the same, no need to change anything.  if they are different, we make the changes, then set the current power state pointer to the requested

Quoted 8 lines

power state pointer and the current clock mode pointer to the requested clock mode pointer.  Now say we are in power state '2' and clock mode 'c' (the high clock for power state '2') and the system goes idle; at the point we will want to stay in power state '2', but select clock mode 'a' (the low clock for power state '2').  So we compare the current and requested clock mode pointers and if they are not equal, we change the clock mode, at which time we update the current clock mode pointers to point to the requested clock.

Really, you didn't need to explain all of that. I understand current idea and implementation :)

The thing is that in your implementation we have 8 (eight!) pointers to current clock mode and 8 pointers to requested clock mode. This part is useless IMO.

Let me prepare another patch to show reduction without introducing stuct & memcpy.

Quoted 7 lines
Quoted 6 lines

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

Quoted 6 lines

That's fine for a local hack, but we don't want that upstream.  If you are planning to hack all the power tables, then why even use them? I'm not sure we really change the lanes that often if at all on r6xx+. In my experience, a lot of cards lock up when change the lanes or fail to change properly which results in getting stuck at lower numbers of lanes.

I don't want to hack all power tables, just consider hacking clocks/etc for minimal (dpms off). Don't want to touch other.

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
#8 lore raw
Quoted 77 lines · W dniu 18 lutego 2010 22:36 użytkownik Rafał Miłecki <[email protected]> napisał:

W dniu 18 lutego 2010 21:47 użytkownik Alex Deucher

Quoted 63 lines · <[email protected]> napisał:

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 18 lines

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Quoted 2 lines

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

What do you mean?   There is not a pointer to every state.  There are only 3 (1. current, 2. requested 3. default) and they are not useless.

You have power states which defines the global state of a particular power state and then each power state has a set of 1 or more clock modes.  So within a power state you can switch between clock modes. You need a set of clock pointers to track the current clock mode and the requested clock mode.  You also need to know the current and requested power state so you need pointers there as well.  We could get rid of the default pointers, but that's mostly there for convenience to avoid having to look up the default state when we need it.

For example, say you had the following power tables:

1. 3d power state:
a. low clock mode
b. medium clock mode
c. high clock mode

2. battery power state
a. low clock mode
b. medium clock mode
c. high clock mode

3. default power state
a. low clock mode
b. medium clock mode
c. high clock mode

By default state 3 would be selected so the current state would be '3' and the current clock mode would be a say 'a'.  The current state pointer would point to '3' and the current clock mode pointer would point to 'a'.  If you then went on battery, you'd want power state '2'.  At that point, the requested state pointer points to '2' and one of the clock modes gets selected, lets say 'c', so the requested clock mode pointer points to 'c'.  When we change the power state, we compare the current and requested power state pointers, if they are the same, no need to change anything.  if they are different, we make the changes, then set the current power state pointer to the requested

Quoted 8 lines

power state pointer and the current clock mode pointer to the requested clock mode pointer.  Now say we are in power state '2' and clock mode 'c' (the high clock for power state '2') and the system goes idle; at the point we will want to stay in power state '2', but select clock mode 'a' (the low clock for power state '2').  So we compare the current and requested clock mode pointers and if they are not equal, we change the clock mode, at which time we update the current clock mode pointers to point to the requested clock.

Really, you didn't need to explain all of that. I understand current idea and implementation :)

Quoted 6 lines

The thing is that in your implementation we have 8 (eight!) pointers to current clock mode and 8 pointers to requested clock mode. This part is useless IMO.

Let me prepare another patch to show reduction without introducing stuct & memcpy.

Not tested!

Signature · 1 line
Rafał
drivers/gpu/drm/radeon/radeon.h +2 -3
index 0ca83ca..fc9044e 100644
@@ -652,9 +652,6 @@ struct radeon_power_state {
 	struct radeon_pm_clock_info clock_info[8];
 	/* number of valid clock modes in this power state */
 	int num_clock_modes;
-	/* currently selected clock mode */
-	struct radeon_pm_clock_info *current_clock_mode;
-	struct radeon_pm_clock_info *requested_clock_mode;
 	struct radeon_pm_clock_info *default_clock_mode;
 	/* non clock info about this state */
 	struct radeon_pm_non_clock_info non_clock_info;
@@ -691,7 +688,9 @@ struct radeon_pm {
 	/* number of valid power states */
 	int                     num_power_states;
 	struct radeon_power_state *current_power_state;
+	struct radeon_pm_clock_info *current_clock_mode;
 	struct radeon_power_state *requested_power_state;
+	struct radeon_pm_clock_info *requested_clock_mode;
 	struct radeon_power_state *default_power_state;
 };
 
drivers/gpu/drm/radeon/radeon_atombios.c +2 -10
index 79d4453..f47d139 100644
@@ -1520,8 +1520,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1589,8 +1587,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1664,8 +1660,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[0];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[0];
 					}
 					state_index++;
 					break;
@@ -1768,8 +1762,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 						rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 						rdev->pm.power_state[state_index].default_clock_mode =
 							&rdev->pm.power_state[state_index].clock_info[mode_index - 1];
-						rdev->pm.power_state[state_index].current_clock_mode =
-							&rdev->pm.power_state[state_index].clock_info[mode_index - 1];
 					}
 					state_index++;
 				}
@@ -1788,8 +1780,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 		rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
 		rdev->pm.power_state[state_index].default_clock_mode =
 			&rdev->pm.power_state[state_index].clock_info[0];
-		rdev->pm.power_state[state_index].current_clock_mode =
-			&rdev->pm.power_state[state_index].clock_info[0];
 		rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
 		if (rdev->asic->get_pcie_lanes)
 			rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
@@ -1800,6 +1790,8 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 		state_index++;
 	}
 	rdev->pm.num_power_states = state_index;
+
+	rdev->pm.current_clock_mode = rdev->pm.default_power_state->default_clock_mode;
 }
 
 void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
drivers/gpu/drm/radeon/radeon_combios.c +3 -2
index 5ef791b..e462cfa 100644
@@ -2447,15 +2447,16 @@ default_mode:
 	rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
 	rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
 	rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
-	rdev->pm.power_state[state_index].current_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
 	rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
 	if (rdev->asic->get_pcie_lanes)
 		rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
 	else
 		rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
 	rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
-	rdev->pm.current_power_state = &rdev->pm.power_state[state_index];
 	rdev->pm.num_power_states = state_index + 1;
+
+	rdev->pm.current_power_state = rdev->pm.default_power_state;
+	rdev->pm.current_clock_mode = rdev->pm.default_power_state->default_clock_mode;
 }
 
 void radeon_external_tmds_setup(struct drm_encoder *encoder)
drivers/gpu/drm/radeon/radeon_pm.c +9 -10
index 6dbfdf4..745189d 100644
@@ -146,28 +146,27 @@ static void radeon_get_power_state(struct radeon_device *rdev,
 	case PM_ACTION_NONE:
 	default:
 		rdev->pm.requested_power_state = rdev->pm.current_power_state;
-		rdev->pm.requested_power_state->requested_clock_mode =
-			rdev->pm.requested_power_state->current_clock_mode;
+		rdev->pm.requested_clock_mode = rdev->pm.current_clock_mode;
 		break;
 	case PM_ACTION_MINIMUM:
 		rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_BATTERY);
-		rdev->pm.requested_power_state->requested_clock_mode =
+		rdev->pm.requested_clock_mode =
 			radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_LOW);
 		break;
 	case PM_ACTION_DOWNCLOCK:
 		rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_POWERSAVE);
-		rdev->pm.requested_power_state->requested_clock_mode =
+		rdev->pm.requested_clock_mode =
 			radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_MID);
 		break;
 	case PM_ACTION_UPCLOCK:
 		rdev->pm.requested_power_state = radeon_pick_power_state(rdev, POWER_STATE_TYPE_DEFAULT);
-		rdev->pm.requested_power_state->requested_clock_mode =
+		rdev->pm.requested_clock_mode =
 			radeon_pick_clock_mode(rdev, rdev->pm.requested_power_state, POWER_MODE_TYPE_HIGH);
 		break;
 	}
 	DRM_INFO("Requested: e: %d m: %d p: %d\n",
-		 rdev->pm.requested_power_state->requested_clock_mode->sclk,
-		 rdev->pm.requested_power_state->requested_clock_mode->mclk,
+		 rdev->pm.requested_clock_mode->sclk,
+		 rdev->pm.requested_clock_mode->mclk,
 		 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
 }
 
@@ -177,13 +176,13 @@ static void radeon_set_power_state(struct radeon_device *rdev)
 		return;
 
 	DRM_INFO("Setting: e: %d m: %d p: %d\n",
-		 rdev->pm.requested_power_state->requested_clock_mode->sclk,
-		 rdev->pm.requested_power_state->requested_clock_mode->mclk,
+		 rdev->pm.requested_clock_mode->sclk,
+		 rdev->pm.requested_clock_mode->mclk,
 		 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
 	/* set pcie lanes */
 	/* set voltage */
 	/* set engine clock */
-	radeon_set_engine_clock(rdev, rdev->pm.requested_power_state->requested_clock_mode->sclk);
+	radeon_set_engine_clock(rdev, rdev->pm.requested_clock_mode->sclk);
 	/* set memory clock */
 
 	rdev->pm.current_power_state = rdev->pm.requested_power_state;

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#9 lore raw
In reply to Rafał Miłecki

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 74 lines

W dniu 18 lutego 2010 21:47 użytkownik Alex Deucher

Quoted 63 lines · <[email protected]> napisał:

2010/2/18 Rafał Miłecki <[email protected]>:

Quoted 18 lines

W dniu 18 lutego 2010 20:29 użytkownik Alex Deucher

Quoted 9 lines · <[email protected]> napisał:

2010/2/17 Rafał Miłecki <[email protected]>:

Quoted 7 lines

We kept requested and current modes in many places, depending on current state. That was useless, one place for holding that is enough.

---
Tested on my RV620, no problems. Alex: can you review this patch? It's your code I modify/remove in it.

Quoted 6 lines

NACK.  Why are you replacing pointers with copies of of the power state structs?  The idea is to keep one array of power states and pointers to the current one, default one, and requested one.  Then comparing power states is just comparing pointers and when you change the power state, you just update the pointer rather then memcpying the entire struct.

Quoted 2 lines

Then first of all we would need to reduce modes pointers. Keeping mode pointer in every state struct is/was useless.

What do you mean?   There is not a pointer to every state.  There are only 3 (1. current, 2. requested 3. default) and they are not useless.

You have power states which defines the global state of a particular power state and then each power state has a set of 1 or more clock modes.  So within a power state you can switch between clock modes. You need a set of clock pointers to track the current clock mode and the requested clock mode.  You also need to know the current and requested power state so you need pointers there as well.  We could get rid of the default pointers, but that's mostly there for convenience to avoid having to look up the default state when we need it.

For example, say you had the following power tables:

1. 3d power state:
a. low clock mode
b. medium clock mode
c. high clock mode

2. battery power state
a. low clock mode
b. medium clock mode
c. high clock mode

3. default power state
a. low clock mode
b. medium clock mode
c. high clock mode

By default state 3 would be selected so the current state would be '3' and the current clock mode would be a say 'a'.  The current state pointer would point to '3' and the current clock mode pointer would point to 'a'.  If you then went on battery, you'd want power state '2'.  At that point, the requested state pointer points to '2' and one of the clock modes gets selected, lets say 'c', so the requested clock mode pointer points to 'c'.  When we change the power state, we compare the current and requested power state pointers, if they are the same, no need to change anything.  if they are different, we make the changes, then set the current power state pointer to the requested

Quoted 8 lines

power state pointer and the current clock mode pointer to the requested clock mode pointer.  Now say we are in power state '2' and clock mode 'c' (the high clock for power state '2') and the system goes idle; at the point we will want to stay in power state '2', but select clock mode 'a' (the low clock for power state '2').  So we compare the current and requested clock mode pointers and if they are not equal, we change the clock mode, at which time we update the current clock mode pointers to point to the requested clock.

Quoted 6 lines

Really, you didn't need to explain all of that. I understand current idea and implementation :)

The thing is that in your implementation we have 8 (eight!) pointers to current clock mode and 8 pointers to requested clock mode. This part is useless IMO.

Ok, I see what you are trying to say. For the current and requested clock modes we could move the pointers up into the pm struct.

Alex

Quoted 19 lines

Let me prepare another patch to show reduction without introducing stuct & memcpy.

Quoted 7 lines
Quoted 6 lines

About introduced solution (keeping struct and memcpy to it) I introduced that to make hacking requested mode possible. Info from AtomBIOS about PCIE lanes seem to be useless (I've never seen anything else than 16) so I want to hack found mode for DPMS OFF to use 1 PCIE lane. Without keeping whole struct it would be impossible without overwriting original entry in array and loosing original info.

Quoted 6 lines

That's fine for a local hack, but we don't want that upstream.  If you are planning to hack all the power tables, then why even use them? I'm not sure we really change the lanes that often if at all on r6xx+. In my experience, a lot of cards lock up when change the lanes or fail to change properly which results in getting stuck at lower numbers of lanes.

Quoted 7 lines

I don't want to hack all power tables, just consider hacking clocks/etc for minimal (dpms off). Don't want to touch other.

--
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--