Skip to contentSkip to conversation

Unit tests for the new SKL HDMI DPLLs code

PATCH New Damien Lespiau 1 participant 6 messages May 7, 2015

lore
Share & tools
lore
#0 lore raw

cover Unit tests for the new SKL HDMI DPLLs code

The kernel code will follow with all the explanations, but here is the testing code. It's quite handy to have this in userspace to be a bit more exhaustive in the testing that what we can do in the kernel.

Signature · 24 lines
Damien

Damien Lespiau (5):
  compute_wrpll: Rename ddi_compute_wrpll to hsw_compute_wrpll
  skl_compute_wrpll: Add a way to test the SKL WRPLL algorithm
  skl_compute_wrpll: Make sure we respect the DCO frequency constraints
  skl_compute_wrpll: Count how many even/odd dividers we compute
  skl_compute_wrpll: Prefer even dividers

 tools/.gitignore                                   |   3 +-
 tools/Makefile.sources                             |   3 +-
 tools/{ddi_compute_wrpll.c => hsw_compute_wrpll.c} |   0
 tools/skl_compute_wrpll.c                          | 910 +++++++++++++++++++++
 4 files changed, 914 insertions(+), 2 deletions(-)
 rename tools/{ddi_compute_wrpll.c => hsw_compute_wrpll.c} (100%)
 create mode 100644 tools/skl_compute_wrpll.c

-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/5 compute_wrpll: Rename ddi_compute_wrpll to hsw_compute_wrpll

We're going to add the SKL version, time to rename the HSW/BDW one.

---
 tools/.gitignore                                   | 2 +-
 tools/Makefile.sources                             | 2 +-
 tools/{ddi_compute_wrpll.c => hsw_compute_wrpll.c} | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename tools/{ddi_compute_wrpll.c => hsw_compute_wrpll.c} (100%)
tools/.gitignore +1 -1
index 562e3cd..f8f04d0 100644
@@ -1,5 +1,5 @@
 # Please keep sorted alphabetically
-ddi_compute_wrpll
+hsw_compute_wrpll
 intel_audio_dump
 intel_backlight
 intel_bios_dumper
tools/Makefile.sources +1 -1
index 1df1653..ae60a31 100644
@@ -1,5 +1,5 @@
 noinst_PROGRAMS = \
-	ddi_compute_wrpll \
+	hsw_compute_wrpll \
 	skl_ddb_allocation \
 	$(NULL)
 
tools/hsw_compute_wrpll.c renamed from tools/ddi_compute_wrpll.c +0 -0
similarity index 100%
rename from tools/ddi_compute_wrpll.c
rename to tools/hsw_compute_wrpll.c
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/5 skl_compute_wrpll: Add a way to test the SKL WRPLL algorithm

In reply to Damien Lespiau

I had various problems (infinite loops, unable to compute dividers for certain frequencies) after implementing a BSpec update. Much easier to debug that in userspace.

---
 tools/.gitignore          |   1 +
 tools/Makefile.sources    |   1 +
 tools/skl_compute_wrpll.c | 848 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 850 insertions(+)
 create mode 100644 tools/skl_compute_wrpll.c
tools/.gitignore +1 -0
index f8f04d0..b47fafd 100644
@@ -31,4 +31,5 @@ intel_stepping
 intel_vga_read
 intel_vga_write
 intel_watermark
+skl_compute_wrpll
 skl_ddb_allocation
tools/Makefile.sources +1 -0
index ae60a31..b07a71c 100644
@@ -1,5 +1,6 @@
 noinst_PROGRAMS = \
 	hsw_compute_wrpll \
+	skl_compute_wrpll \
 	skl_ddb_allocation \
 	$(NULL)
 
tools/skl_compute_wrpll.c new file +848 -0

848 lines not on this page · raw message

Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/5 skl_compute_wrpll: Make sure we respect the DCO frequency constraints

In reply to Damien Lespiau

We might as well verify that we have a semblance of all being in order by making sure the DCO frequency is within the expected bounds.

---
 tools/skl_compute_wrpll.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tools/skl_compute_wrpll.c +42 -0
index 195163c..4f7ea9a 100644
@@ -60,6 +60,10 @@ struct skl_wrpll_params {
 	uint32_t        kdiv;
 	uint32_t        pdiv;
 	uint32_t        central_freq;
+
+	/* for this test code only */
+	uint64_t central_freq_hz;
+	unsigned int p0, p1, p2;
 };
 
 static bool
@@ -239,6 +243,12 @@ found:
 
 	}
 
+	/* for this unit test only */
+	wrpll_params->central_freq_hz = dco_central_freq[min_dco_index];
+	wrpll_params->p0 = candidate_p0[min_dco_index];
+	wrpll_params->p1 = candidate_p1[min_dco_index];
+	wrpll_params->p2 = candidate_p2[min_dco_index];
+
 	return true;
 }
 
@@ -406,6 +416,7 @@ skl_ddi_calculate_wrpll2(int clock /* in Hz */,
 	};
 	struct skl_wrpll_context ctx;
 	unsigned int dco, d, i;
+	unsigned int p0, p1, p2;
 
 	skl_wrpll_context_init(&ctx);
 
@@ -428,6 +439,12 @@ skl_ddi_calculate_wrpll2(int clock /* in Hz */,
 
 	skl_wrpll_get_multipliers(ctx.p, &p0, &p1, &p2);
 
+	/* for this unit test only */
+	wrpll_params->central_freq_hz = ctx.central_freq;
+	wrpll_params->p0 = p0;
+	wrpll_params->p1 = p1;
+	wrpll_params->p2 = p2;
+
 	return true;
 }
 
@@ -829,6 +846,31 @@ static void test_run(struct test_ops *test)
 				clock);
 			continue;
 		}
+
+		/*
+		 * make sure we respect the +1%/-6% contraint around the
+		 * central frequency
+		 */
+		{
+			unsigned int p = params.p0 * params.p1 * params.p2;
+			uint64_t dco_freq = (uint64_t)p * clock * 5;
+			uint64_t central_freq = params.central_freq_hz;
+			uint64_t deviation;
+			uint64_t diff;
+
+			diff = abs_diff(dco_freq, central_freq);
+			deviation = div64_u64(10000 * diff, central_freq);
+
+			if (dco_freq > central_freq) {
+				if (deviation > 100)
+					printf("failed constraint for %dHz "
+					       "deviation=%"PRIu64"\n", clock,
+					       deviation);
+			} else if (deviation > 600)
+				printf("failed constraint for %dHz "
+				       "deviation=%"PRIu64"\n", clock,
+				       deviation);
+		}
 	}
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 4/5 skl_compute_wrpll: Count how many even/odd dividers we compute

In reply to Damien Lespiau
---
 tools/skl_compute_wrpll.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
tools/skl_compute_wrpll.c +14 -1
index 4f7ea9a..a3a6e58 100644
@@ -836,10 +836,12 @@ struct test_ops {
 static void test_run(struct test_ops *test)
 {
 	unsigned int m;
+	unsigned p_odd_even[2] = { 0, 0 };
 
 	for (m = 0; m < ARRAY_SIZE(modes); m++) {
 		struct skl_wrpll_params params = {};
 		int clock = modes[m].clock;
+		unsigned int p;
 
 		if (!test->compute(clock, &params)) {
 			fprintf(stderr, "Couldn't compute divider for %dHz\n",
@@ -847,12 +849,13 @@ static void test_run(struct test_ops *test)
 			continue;
 		}
 
+		p = params.p0 * params.p1 * params.p2;
+
 		/*
 		 * make sure we respect the +1%/-6% contraint around the
 		 * central frequency
 		 */
 		{
-			unsigned int p = params.p0 * params.p1 * params.p2;
 			uint64_t dco_freq = (uint64_t)p * clock * 5;
 			uint64_t central_freq = params.central_freq_hz;
 			uint64_t deviation;
@@ -871,7 +874,17 @@ static void test_run(struct test_ops *test)
 				       "deviation=%"PRIu64"\n", clock,
 				       deviation);
 		}
+
+		/*
+		 * count how many even/odd dividers we have through the whole
+		 * list of tested frequencies
+		 */
+		{
+			p_odd_even[p % 2]++;
+		}
 	}
+
+	printf("even/odd dividers: %d/%d\n", p_odd_even[0], p_odd_even[1]);
 }
 
 int main(int argc, char **argv)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH 5/5 skl_compute_wrpll: Prefer even dividers

In reply to Damien Lespiau
---
 tools/skl_compute_wrpll.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/skl_compute_wrpll.c +7 -0
index a3a6e58..55f2df4 100644
@@ -431,6 +431,13 @@ skl_ddi_calculate_wrpll2(int clock /* in Hz */,
 						      dco_freq,
 						      p);
 			}
+
+			/*
+			 * If a solution is found with an even divider, prefer
+			 * this one.
+			 */
+			if (d == 0 && ctx.p)
+				break;
 		}
 	}
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx