Skip to contentSkip to conversation

PM: Start C-state definitions from base 0

PATCH Superseded Sanjeev Premi 2 participants 3 messages Mar 12, 2009 – Mar 13, 2009

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PM: Start C-state definitions from base 0

The current definition of C-states starts from base 1. Whereas, the cpuidle driver uses base 0. This patch eliminates need for explicit mapping due to different base values.

---
 arch/arm/mach-omap2/cpuidle34xx.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +10 -13
index 62fbb2e..50bf412 100644
@@ -33,13 +33,13 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-#define OMAP3_MAX_STATES 7
-#define OMAP3_STATE_C1 1 /* C1 - MPU WFI + Core active */
-#define OMAP3_STATE_C2 2 /* C2 - MPU CSWR + Core active */
-#define OMAP3_STATE_C3 3 /* C3 - MPU OFF + Core active */
-#define OMAP3_STATE_C4 4 /* C4 - MPU RET + Core RET */
-#define OMAP3_STATE_C5 5 /* C5 - MPU OFF + Core RET */
-#define OMAP3_STATE_C6 6 /* C6 - MPU OFF + Core OFF */
+#define OMAP3_MAX_STATES 6
+#define OMAP3_STATE_C1 0 /* C1 - MPU WFI + Core active */
+#define OMAP3_STATE_C2 1 /* C2 - MPU CSWR + Core active */
+#define OMAP3_STATE_C3 2 /* C3 - MPU OFF + Core active */
+#define OMAP3_STATE_C4 3 /* C4 - MPU RET + Core RET */
+#define OMAP3_STATE_C5 4 /* C5 - MPU OFF + Core RET */
+#define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core OFF */
 
 struct omap3_processor_cx {
 	u8 valid;
@@ -228,7 +228,7 @@ struct cpuidle_driver omap3_idle_driver = {
  */
 int omap3_idle_init(void)
 {
-	int i, count = 0;
+	int count;
 	struct omap3_processor_cx *cx;
 	struct cpuidle_state *state;
 	struct cpuidle_device *dev;
@@ -244,8 +244,8 @@ int omap3_idle_init(void)
 
 	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
 
-	for (i = 1; i < OMAP3_MAX_STATES; i++) {
-		cx = &omap3_power_states[i];
+	for (count = 0; count < OMAP3_MAX_STATES; count++) {
+		cx = &omap3_power_states[count];
 		state = &dev->states[count];
 
 		if (!cx->valid)
@@ -259,11 +259,8 @@ int omap3_idle_init(void)
 		if (cx->type == OMAP3_STATE_C1)
 			dev->safe_state = state;
 		sprintf(state->name, "C%d", count+1);
-		count++;
 	}
 
-	if (!count)
-		return -EINVAL;
 	dev->state_count = count;
 
 	if (cpuidle_register_device(dev)) {
Signature · 1 line
1.5.6
#1 lore raw
Quoted 45 lines · Sanjeev Premi

The current definition of C-states starts from base 1. Whereas, the cpuidle driver uses base 0. This patch eliminates need for explicit mapping due to different base values.

---
 arch/arm/mach-omap2/cpuidle34xx.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +8 -8
index 62fbb2e..50bf412 100644
@@ -33,13 +33,13 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-#define OMAP3_MAX_STATES 7
-#define OMAP3_STATE_C1 1 /* C1 - MPU WFI + Core active */
-#define OMAP3_STATE_C2 2 /* C2 - MPU CSWR + Core active */
-#define OMAP3_STATE_C3 3 /* C3 - MPU OFF + Core active */
-#define OMAP3_STATE_C4 4 /* C4 - MPU RET + Core RET */
-#define OMAP3_STATE_C5 5 /* C5 - MPU OFF + Core RET */
-#define OMAP3_STATE_C6 6 /* C6 - MPU OFF + Core OFF */
+#define OMAP3_MAX_STATES 6
+#define OMAP3_STATE_C1 0 /* C1 - MPU WFI + Core active */
+#define OMAP3_STATE_C2 1 /* C2 - MPU CSWR + Core active */
+#define OMAP3_STATE_C3 2 /* C3 - MPU OFF + Core active */
+#define OMAP3_STATE_C4 3 /* C4 - MPU RET + Core RET */
+#define OMAP3_STATE_C5 4 /* C5 - MPU OFF + Core RET */
+#define OMAP3_STATE_C6 5 /* C6 - MPU OFF + Core OFF */
 
 struct omap3_processor_cx {
 	u8 valid;
@@ -228,7 +228,7 @@ struct cpuidle_driver omap3_idle_driver = {
  */
 int omap3_idle_init(void)
 {
-	int i, count = 0;
+	int count;
 	struct omap3_processor_cx *cx;
 	struct cpuidle_state *state;
 	struct cpuidle_device *dev;

arch/arm/mach-omap2/cpuidle34xx.c int omap3_idle_init(void) · line 251

Quoted 10 lines
arch/arm/mach-omap2/cpuidle34xx.c +2 -2
@@ -244,8 +244,8 @@ int omap3_idle_init(void)
 
 	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
 
-	for (i = 1; i < OMAP3_MAX_STATES; i++) {
-		cx = &omap3_power_states[i];
+	for (count = 0; count < OMAP3_MAX_STATES; count++) {
+		cx = &omap3_power_states[count];
 		state = &dev->states[count];
 
 		if (!cx->valid)

Still not quite right.

The reason for a different loop iterator and 'count' was so that states that are not 'valid' do not get regsitered with CPUidle. With this patch, some of the dev->states[] pointers that get registered with CPUidle will have bogus values if there are any !valid states at boot time.

Since you are not fixing the valid state problem in this patch, I suggest you keep the separate iterator and count, and just start i at zero instead of 1.

Then, when you fix the valid state problem, you can drop the checking for valid sates at init time all together, and then use a single iterator for this loop.

Kevin

Quoted 19 lines
arch/arm/mach-omap2/cpuidle34xx.c +0 -3
@@ -259,11 +259,8 @@ int omap3_idle_init(void)
 		if (cx->type == OMAP3_STATE_C1)
 			dev->safe_state = state;
 		sprintf(state->name, "C%d", count+1);
-		count++;
 	}
 
-	if (!count)
-		return -EINVAL;
 	dev->state_count = count;
 
 	if (cpuidle_register_device(dev)) {
Signature · 6 lines
1.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 78 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Friday, March 13, 2009 4:49 AM
To: Premi, Sanjeev
Cc: [email protected]
Subject: Re: [PATCHv2] PM: Start C-state definitions from base 0

Quoted 20 lines · Sanjeev Premi

The current definition of C-states starts from base 1. Whereas, the cpuidle driver uses base 0. This patch eliminates need for explicit mapping due to different base values.

---
 arch/arm/mach-omap2/cpuidle34xx.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +0 -2
index 62fbb2e..50bf412 100644
@@ -33,13 +33,13 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-#define OMAP3_MAX_STATES 7
-#define OMAP3_STATE_C1 1 /* C1 - MPU WFI + Core active */ -#define 
Quoted 3 lines

OMAP3_STATE_C2 2 /* C2 - MPU CSWR + Core active */ -#define OMAP3_STATE_C3 3 /* C3 - MPU OFF + Core active */ -#define OMAP3_STATE_C4 4 /* C4 - MPU RET + Core RET */ -#define

OMAP3_STATE_C5

Quoted 1 line

5 /* C5 - MPU OFF + Core RET */ -#define OMAP3_STATE_C6 6

/* C6 - MPU

arch/arm/mach-omap2/cpuidle34xx.c

Quoted 6 lines

OFF + Core OFF */

arch/arm/mach-omap2/cpuidle34xx.c +5 -0
+#define OMAP3_MAX_STATES 6
+#define OMAP3_STATE_C1 0 /* C1 - MPU WFI + Core active */ #define 
+OMAP3_STATE_C2 1 /* C2 - MPU CSWR + Core active */ #define 
+OMAP3_STATE_C3 2 /* C3 - MPU OFF + Core active */ #define 
+OMAP3_STATE_C4 3 /* C4 - MPU RET + Core RET */ #define 

OMAP3_STATE_C5

Quoted 1 line

+4 /* C5 - MPU OFF + Core RET */ #define OMAP3_STATE_C6 5

/* C6 - MPU

Quoted 14 lines
arch/arm/mach-omap2/cpuidle34xx.c +2 -1
+OFF + Core OFF */
 
 struct omap3_processor_cx {
 	u8 valid;
@@ -228,7 +228,7 @@ struct cpuidle_driver omap3_idle_driver = {
  */
 int omap3_idle_init(void)
 {
-	int i, count = 0;
+	int count;
 	struct omap3_processor_cx *cx;
 	struct cpuidle_state *state;
 	struct cpuidle_device *dev;

arch/arm/mach-omap2/cpuidle34xx.c int omap3_idle_init(void) · line 251

Quoted 10 lines
arch/arm/mach-omap2/cpuidle34xx.c +2 -2
@@ -244,8 +244,8 @@ int omap3_idle_init(void)
 
 	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
 
-	for (i = 1; i < OMAP3_MAX_STATES; i++) {
-		cx = &omap3_power_states[i];
+	for (count = 0; count < OMAP3_MAX_STATES; count++) {
+		cx = &omap3_power_states[count];
 		state = &dev->states[count];
 
 		if (!cx->valid)

Still not quite right.

The reason for a different loop iterator and 'count' was so that states that are not 'valid' do not get regsitered with CPUidle. With this patch, some of the dev->states[] pointers that get registered with CPUidle will have bogus values if there are any !valid states at boot time.

Quoted 7 lines

Since you are not fixing the valid state problem in this patch, I suggest you keep the separate iterator and count, and just start i at zero instead of 1.

Then, when you fix the valid state problem, you can drop the checking for valid sates at init time all together, and then use a single iterator for this loop.

Since the ".valid" for each of the states was 1 in the init for all states; I did the change above. Will re-submit v3 later today.

~sanjeev

Quoted 26 lines

Kevin

Quoted 15 lines
arch/arm/mach-omap2/cpuidle34xx.c +0 -4
@@ -259,11 +259,8 @@ int omap3_idle_init(void)
 		if (cx->type == OMAP3_STATE_C1)
 			dev->safe_state = state;
 		sprintf(state->name, "C%d", count+1);
-		count++;
 	}
 
-	if (!count)
-		return -EINVAL;
 	dev->state_count = count;
 
 	if (cpuidle_register_device(dev)) {
--

1.5.6

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe

linux-omap"

Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at http://vger.kernel.org/majordomo-info.html