Skip to contentSkip to conversation

PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS.

PATCH Superseded Thara Gopinath 3 participants 5 messages Feb 18, 2010 – Feb 23, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS.

As per the current implementaion (u8*)&target_level is being passed to freq_to_opp in set_opp. This would result in updating just the first 8 bits of a u32 variable. Later target_level is passed to resource_set_opp_level as a u32 parameter. This maens
a. Initially target_level was 0xabcdefgh.
b. freq_to_opp updates the lower eight bits of target_level to 0xXX. Now target_level = 0xabcdefXX.
c. We pass 0xabcdefXX as target_level to resource_set_opp_level when we want to pass just 0xXX.
This is leading to some corrupted bookkeeping later on in the dvfs path.

This patch ensures that target_level passed to resource_set_opp_level is actually the level that is intended by freq_to_opp API.

---
 arch/arm/mach-omap2/resource34xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/resource34xx.c +3 -1
index 3604a38..d2336d8 100644
@@ -463,6 +463,7 @@ int set_opp(struct shared_resource *resp, u32 target_level)
 	} else if (resp == vdd2_resp) {
 		unsigned long req_l3_freq;
 		struct omap_opp *oppx = NULL;
+		u8 opp;
 
 		/* Convert the tput in KiB/s to Bus frequency in MHz */
 		req_l3_freq = (target_level * 1000)/4;
@@ -478,10 +479,11 @@ int set_opp(struct shared_resource *resp, u32 target_level)
 		/* uh uh.. no OPPs?? */
 		BUG_ON(IS_ERR(oppx));
 
-		ret = freq_to_opp((u8 *)&target_level, OPP_L3, req_l3_freq);
+		ret = freq_to_opp(&opp, OPP_L3, req_l3_freq);
 		/* we dont expect this to fail */
 		BUG_ON(ret);
 
+		target_level = opp;
 		ret = resource_set_opp_level(VDD2_OPP, target_level, 0);
 	}
 	return 0;
Signature · 1 line
1.5.4.7
#1 lore raw

Gopinath, Thara said the following on 02/18/2010 10:31 AM:

Quoted 12 lines

As per the current implementaion (u8*)&target_level is being passed to freq_to_opp in set_opp. This would result in updating just the first 8 bits of a u32 variable. Later target_level is passed to resource_set_opp_level as a u32 parameter. This maens
a. Initially target_level was 0xabcdefgh.
b. freq_to_opp updates the lower eight bits of target_level to 0xXX. Now target_level = 0xabcdefXX.
c. We pass 0xabcdefXX as target_level to resource_set_opp_level when we want to pass just 0xXX.
This is leading to some corrupted bookkeeping later on in the dvfs path.

Quoted 2 lines

This patch ensures that target_level passed to resource_set_opp_level is actually the level that is intended by freq_to_opp API.

Thanks.. good catch.
[PATCH] PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS. Suggestion on the subject:
could you put it something like the following so that git-am will throw away PM-WIP-OPP? [PATCH] [PM-WIP-OPP] omap3: pm: Fix wrong target level during core dvfs

?
Some suggestion below.

Quoted 20 lines
---
 arch/arm/mach-omap2/resource34xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/resource34xx.c +1 -0
index 3604a38..d2336d8 100644
@@ -463,6 +463,7 @@ int set_opp(struct shared_resource *resp, u32 target_level)
 	} else if (resp == vdd2_resp) {
 		unsigned long req_l3_freq;
 		struct omap_opp *oppx = NULL;
+		u8 opp;
 
 		/* Convert the tput in KiB/s to Bus frequency in MHz */
 		req_l3_freq = (target_level * 1000)/4;

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32 target_level) · line 481

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
@@ -478,10 +479,11 @@ int set_opp(struct shared_resource *resp, u32 target_level)
 		/* uh uh.. no OPPs?? */
 		BUG_ON(IS_ERR(oppx));
 

If you do target_level = 0; here, the entire patch is a oneliner :)

Quoted 9 lines
arch/arm/mach-omap2/resource34xx.c +2 -1
-		ret = freq_to_opp((u8 *)&target_level, OPP_L3, req_l3_freq);
+		ret = freq_to_opp(&opp, OPP_L3, req_l3_freq);
 		/* we dont expect this to fail */
 		BUG_ON(ret);
 
+		target_level = opp;
 		ret = resource_set_opp_level(VDD2_OPP, target_level, 0);
 	}
 	return 0;
Signature · 2 lines
Regards,
Nishanth Menon
#2 lore raw

Nishanth,

Quoted 56 lines

-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Menon, Nishanth
Sent: Thursday, February 18, 2010 8:58 AM
To: Gopinath, Thara
Cc: [email protected]; Kevin Hilman; Kristo Tero (Nokia- D/Tampere)
Subject: Re: [PATCH] PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS.

Gopinath, Thara said the following on 02/18/2010 10:31 AM:

Quoted 12 lines

As per the current implementaion (u8*)&target_level is being passed to freq_to_opp in set_opp. This would result in updating just the first 8 bits of a u32 variable. Later target_level is passed to resource_set_opp_level as a u32 parameter. This maens
a. Initially target_level was 0xabcdefgh.
b. freq_to_opp updates the lower eight bits of target_level to 0xXX. Now target_level = 0xabcdefXX.
c. We pass 0xabcdefXX as target_level to resource_set_opp_level when we want to pass just 0xXX.
This is leading to some corrupted bookkeeping later on in the dvfs path.

Quoted 2 lines

This patch ensures that target_level passed to resource_set_opp_level is actually the level that is intended by freq_to_opp API.

Thanks.. good catch.
[PATCH] PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS.
Suggestion on the subject:
could you put it something like the following so that git-am will throw away PM-WIP-OPP?
[PATCH] [PM-WIP-OPP] omap3: pm: Fix wrong target level during core dvfs

?
Some suggestion below.

arch/arm/mach-

Quoted 8 lines
---
 arch/arm/mach-omap2/resource34xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/resource34xx.c +0 -0

omap2/resource34xx.c

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 4 lines

index 3604a38..d2336d8 100644

arch/arm/mach-omap2/resource34xx.c +0 -0
@@ -463,6 +463,7 @@ int set_opp(struct shared_resource *resp, u32

target_level)

Quoted 5 lines
arch/arm/mach-omap2/resource34xx.c +1 -0
 	} else if (resp == vdd2_resp) {
 		unsigned long req_l3_freq;
 		struct omap_opp *oppx = NULL;
+		u8 opp;
 
Quoted 8 lines

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 		/* Convert the tput in KiB/s to Bus frequency in MHz */
 		req_l3_freq = (target_level * 1000)/4;
@@ -478,10 +479,11 @@ int set_opp(struct shared_resource *resp, u32

target_level)

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32 target_level) · line 481

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 		/* uh uh.. no OPPs?? */
 		BUG_ON(IS_ERR(oppx));
 

If you do target_level = 0; here, the entire patch is a oneliner :)

Actually, IMHO will be even more clean, to standardize all OPP value passing to be u8.

Do you really need to be prepared for 2^32 opp values? ;)

Regards,
Sergio

Quoted 18 lines

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32 target_level) · line 489

Quoted 10 lines
arch/arm/mach-omap2/resource34xx.c +2 -1
-		ret = freq_to_opp((u8 *)&target_level, OPP_L3, req_l3_freq);
+		ret = freq_to_opp(&opp, OPP_L3, req_l3_freq);
 		/* we dont expect this to fail */
 		BUG_ON(ret);
 
+		target_level = opp;
 		ret = resource_set_opp_level(VDD2_OPP, target_level, 0);
 	}
 	return 0;

--
Regards,
Nishanth Menon
--
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

#3 lore raw
Quoted 3 lines

From: Aguirre, Sergio
Sent: Tuesday, February 23, 2010 7:28 AM
To: Menon, Nishanth; Gopinath, Thara

[...]

Quoted 27 lines
Quoted 27 lines

arch/arm/mach-

Quoted 9 lines
---
 arch/arm/mach-omap2/resource34xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/resource34xx.c +0 -0

omap2/resource34xx.c

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 4 lines

index 3604a38..d2336d8 100644

arch/arm/mach-omap2/resource34xx.c +0 -0
@@ -463,6 +463,7 @@ int set_opp(struct shared_resource *resp, u32

target_level)

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 8 lines
arch/arm/mach-omap2/resource34xx.c +1 -0
 	} else if (resp == vdd2_resp) {
 		unsigned long req_l3_freq;
 		struct omap_opp *oppx = NULL;
+		u8 opp;
 
 		/* Convert the tput in KiB/s to Bus frequency in MHz */
 		req_l3_freq = (target_level * 1000)/4;
@@ -478,10 +479,11 @@ int set_opp(struct shared_resource *resp, u32

target_level)

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 		/* uh uh.. no OPPs?? */
 		BUG_ON(IS_ERR(oppx));
 
Quoted 7 lines
Quoted 1 line

If you do target_level = 0; here, the entire patch is a oneliner :)

Actually, IMHO will be even more clean, to standardize all OPP value passing to be u8.

Do you really need to be prepared for 2^32 opp values? ;)

Using OPP ID has to be completely removed from resource34xx.c -> this action is still pending. In this case, using u8 OR initing the target_level to 0 has the same impact. Why add code that will be removed later on anyways?

Regards,
Nishanth Menon

#4 lore raw
Quoted 47 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Monday, February 22, 2010 11:31 PM
To: Aguirre, Sergio; Gopinath, Thara
Cc: [email protected]; Kevin Hilman; Kristo Tero (Nokia- D/Tampere)
Subject: RE: [PATCH] PM-WIP-OPP: Fixing wrong target level being passed during Core DVFS.

Quoted 3 lines

From: Aguirre, Sergio
Sent: Tuesday, February 23, 2010 7:28 AM
To: Menon, Nishanth; Gopinath, Thara

[...]

Quoted 32 lines
Quoted 20 lines

arch/arm/mach-

Quoted 9 lines
---
 arch/arm/mach-omap2/resource34xx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/resource34xx.c +0 -0

omap2/resource34xx.c

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 4 lines

index 3604a38..d2336d8 100644

arch/arm/mach-omap2/resource34xx.c +0 -0
@@ -463,6 +463,7 @@ int set_opp(struct shared_resource *resp, u32

target_level)

Quoted 5 lines
arch/arm/mach-omap2/resource34xx.c +1 -0
 	} else if (resp == vdd2_resp) {
 		unsigned long req_l3_freq;
 		struct omap_opp *oppx = NULL;
+		u8 opp;
 
Quoted 8 lines

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 		/* Convert the tput in KiB/s to Bus frequency in MHz */
 		req_l3_freq = (target_level * 1000)/4;
@@ -478,10 +479,11 @@ int set_opp(struct shared_resource *resp, u32

target_level)

arch/arm/mach-omap2/resource34xx.c int set_opp(struct shared_resource *resp, u32 target_level) · line 481

Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 		/* uh uh.. no OPPs?? */
 		BUG_ON(IS_ERR(oppx));
 

If you do target_level = 0; here, the entire patch is a oneliner :)

Actually, IMHO will be even more clean, to standardize all OPP value passing to be u8.

Quoted 6 lines
Quoted 2 lines

Do you really need to be prepared for 2^32 opp values? ;)

Using OPP ID has to be completely removed from resource34xx.c -> this action is still pending. In this case, using u8 OR initing the target_level to 0 has the same impact. Why add code that will be removed later on anyways?

Well, I'm not proposing for code addition, but to fix that code just by changing opp level parameters to u8, instead of u32, like this:

-int set_opp(struct shared_resource *resp, u32 target_level) +int set_opp(struct shared_resource *resp, u8 target_level)

If you're going to replace all this in the near future, then it's understandable to hold even this patch (target_level = 0).

Regards,
Sergio

Quoted 3 lines

Regards,
Nishanth Menon