[PATCH i-g-t 09/29] igt/perf: move timebase + oa exponent utilities up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Robert Bragg <robert@xxxxxxxxxxxxx>

Signed-off-by: Robert Bragg <robert@xxxxxxxxxxxxx>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@xxxxxxxxx>
---
 tests/perf.c | 56 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/tests/perf.c b/tests/perf.c
index 48e8750f..600fa7d9 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -417,6 +417,34 @@ gen8_read_report_ticks(uint32_t *report, enum drm_i915_oa_format format)
 	return report[3];
 }
 
+static uint64_t
+timebase_scale(uint32_t u32_delta)
+{
+	return ((uint64_t)u32_delta * NSEC_PER_SEC) / timestamp_frequency;
+}
+
+/* Return the largest OA exponent that will still result in a sampling
+ * frequency higher than the given frequency.
+ */
+static int
+max_oa_exponent_for_higher_freq(uint64_t freq)
+{
+	/* NB: timebase_scale() takes a uint32_t and an exponent of 30
+	 * would already represent a period of ~3 minutes so there's
+	 * really no need to consider higher exponents.
+	 */
+	for (int i = 0; i < 30; i++) {
+		uint64_t oa_period = timebase_scale(2 << i);
+		uint32_t oa_freq = NSEC_PER_SEC / oa_period;
+
+		if (oa_freq <= freq)
+			return max(0, i - 1);
+	}
+
+	igt_assert(!"reached");
+	return -1;
+}
+
 static bool
 init_sys_info(void)
 {
@@ -531,12 +559,6 @@ gt_frequency_range_restore(void)
 	gt_max_freq_mhz = gt_max_freq_mhz_saved;
 }
 
-static uint64_t
-timebase_scale(uint32_t u32_delta)
-{
-	return ((uint64_t)u32_delta * NSEC_PER_SEC) / timestamp_frequency;
-}
-
 /* CAP_SYS_ADMIN is required to open system wide metrics, unless the system
  * control parameter dev.i915.perf_stream_paranoid == 0 */
 static void
@@ -1184,28 +1206,6 @@ test_invalid_oa_exponent(void)
 	}
 }
 
-/* Return the largest OA exponent that will still result in a sampling
- * frequency higher than the given frequency.
- */
-static int
-max_oa_exponent_for_higher_freq(uint64_t freq)
-{
-	/* NB: timebase_scale() takes a uint32_t and an exponent of 30
-	 * would already represent a period of ~3 minutes so there's
-	 * really no need to consider higher exponents.
-	 */
-	for (int i = 0; i < 30; i++) {
-		uint64_t oa_period = timebase_scale(2 << i);
-		uint32_t oa_freq = NSEC_PER_SEC / oa_period;
-
-		if (oa_freq <= freq)
-			return max(0, i - 1);
-	}
-
-	igt_assert(!"reached");
-	return -1;
-}
-
 /* The lowest periodic sampling exponent equates to a period of 160 nanoseconds
  * or a frequency of 6.25MHz which is only possible to request as root by
  * default. By default the maximum OA sampling rate is 100KHz
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux