diff options
author | Robert Bragg <robert@sixbynine.org> | 2017-02-06 15:40:22 +0000 |
---|---|---|
committer | Lionel Landwerlin <lionel.g.landwerlin@intel.com> | 2017-08-04 12:01:54 +0100 |
commit | f1c5a02e3c5b95a79659182316af513fcff2e2b2 (patch) | |
tree | 5dcfb8df50bba3ed0563e6314df1bf66f4aacc51 /tests/perf.c | |
parent | 8519411b68bec168306b8be8c770f986b09f0490 (diff) |
tests/perf: move timebase + oa exponent utilities up
Signed-off-by: Robert Bragg <robert@sixbynine.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Diffstat (limited to 'tests/perf.c')
-rw-r--r-- | tests/perf.c | 56 |
1 files 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 |