Skip to contentSkip to conversation

tests/pm_rps: Round requested freq correctly

PATCH In review Daniel Vetter 5 participants 7 messages Feb 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tests/pm_rps: Round requested freq correctly

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +3 -0
index 467038104ec6..27e758755e3f 100644
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
 	int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
+	/* hw (and so kernel) currently rounds to 50 MHz ... */
+	fmid = fmid / 50 * 50;
+
 	log("\nCheck original min and max...\n");
 	check();
 
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 2/2 tests/pm_rps: remove setfreq

It's unused.

---
 tests/pm_rps.c | 11 -----------
 1 file changed, 11 deletions(-)
tests/pm_rps.c +0 -11
index 27e758755e3f..3d374f92f82d 100644
@@ -110,17 +110,6 @@ static int do_writeval(FILE *filp, int val, int lerrno)
 #define writeval(filp, val) do_writeval(filp, val, 0)
 #define writeval_inval(filp, val) do_writeval(filp, val, EINVAL)
 
-static void setfreq(int val)
-{
-	if (val > readval(stuff[MAX].filp)) {
-		writeval(stuff[MAX].filp, val);
-		writeval(stuff[MIN].filp, val);
-	} else {
-		writeval(stuff[MIN].filp, val);
-		writeval(stuff[MAX].filp, val);
-	}
-}
-
 static void checkit(const int *freqs)
 {
 	igt_assert(freqs[MIN] <= freqs[MAX]);
Signature · 1 line
1.8.1.4
#2 lore raw
In reply to Daniel Vetter
Quoted 15 lines · Daniel Vetter

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +0 -0
index 467038104ec6..27e758755e3f 100644

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 353

Quoted 4 lines
tests/pm_rps.c +1 -0
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
 	int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
+	/* hw (and so kernel) currently rounds to 50 MHz ... */

s/rounds/truncates/ or if it really does round, you need to adjust the calculation.

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 357

Quoted 4 lines
tests/pm_rps.c +2 -0
+	fmid = fmid / 50 * 50;
+
 	log("\nCheck original min and max...\n");
 	check();

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw
Quoted 19 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +0 -0
index 467038104ec6..27e758755e3f 100644
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
      int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
Quoted 4 lines

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 353

Quoted 1 line
tests/pm_rps.c +1 -0
+     /* hw (and so kernel) currently rounds to 50 MHz ... */

s/rounds/truncates/ or if it really does round, you need to adjust the calculation.

We just need to use something divisible by 50 so that the value we write and the one we get match up. Whether it's truncating or rounding doesn't matter really.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#4 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 19 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +0 -0
index 467038104ec6..27e758755e3f 100644
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
      int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
Quoted 4 lines

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 353

Quoted 1 line
tests/pm_rps.c +1 -0
+     /* hw (and so kernel) currently rounds to 50 MHz ... */

s/rounds/truncates/ or if it really does round, you need to adjust the calculation.

Quoted 4 lines

We just need to use something divisible by 50 so that the value we write and the one we get match up. Whether it's truncating or rounding doesn't matter really.
-Daniel

Darn, I considered this possibility but forgot to account for it in the test. I think what I was going to do was to create another writeval variant which doesn't do read back matching check. This was because I didn't want to assume that all systems use a 50 Mhz frequency increment (do they all?). -Jeff

#5 lore raw
Quoted 31 lines · Jeff McGee
Quoted 25 lines · Daniel Vetter
Quoted 19 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +0 -0
index 467038104ec6..27e758755e3f 100644
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
      int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
Quoted 4 lines

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 353

Quoted 1 line
tests/pm_rps.c +1 -0
+     /* hw (and so kernel) currently rounds to 50 MHz ... */

s/rounds/truncates/ or if it really does round, you need to adjust the calculation.

Quoted 4 lines

We just need to use something divisible by 50 so that the value we write and the one we get match up. Whether it's truncating or rounding doesn't matter really.
-Daniel

Quoted 4 lines

Darn, I considered this possibility but forgot to account for it in the test. I think what I was going to do was to create another writeval variant which doesn't do read back matching check. This was because I didn't want to assume that all systems use a 50 Mhz frequency increment (do they all?).

VLV sure doesn't.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#6 lore raw
Quoted 32 lines · Ville Syrjälä
Quoted 31 lines · Jeff McGee
Quoted 29 lines · Daniel Vetter
Quoted 19 lines · Chris Wilson
Quoted 18 lines · Daniel Vetter

The kernel will round it, so if we don't we'll have a spurious mismatch. Happens on my machine here with 650-1300MHz range, where the midpoint is 975.

---
 tests/pm_rps.c | 3 +++
 1 file changed, 3 insertions(+)
tests/pm_rps.c +0 -0
index 467038104ec6..27e758755e3f 100644
@@ -350,6 +350,9 @@ static void min_max_config(void (*check)(void))
 {
      int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
 
Quoted 4 lines

tests/pm_rps.c static void min_max_config(void (*check)(void)) · line 353

Quoted 1 line
tests/pm_rps.c +1 -0
+     /* hw (and so kernel) currently rounds to 50 MHz ... */

s/rounds/truncates/ or if it really does round, you need to adjust the calculation.

We just need to use something divisible by 50 so that the value we write and the one we get match up. Whether it's truncating or rounding doesn't matter really.
-Daniel

Quoted 6 lines
Quoted 4 lines

Darn, I considered this possibility but forgot to account for it in the test. I think what I was going to do was to create another writeval variant which doesn't do read back matching check. This was because I didn't want to assume that all systems use a 50 Mhz frequency increment (do they all?).

VLV sure doesn't.

Well I've hacked around it for now. But I agree that an unchecked write-val for fmid would be the better approach. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch