intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
@ 2020-05-16 13:24 Chris Wilson
  2020-05-16 13:31 ` Chris Wilson
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-16 13:24 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson

Count the number of CS_TIMESTAMP ticks and check that it matches our
expectations.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 113 +++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
index 242181a5214c..a72631b5e8ec 100644
--- a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
@@ -5,10 +5,122 @@
  * Copyright © 2019 Intel Corporation
  */
 
+#include <linux/sort.h>
+
+#include "intel_gt_clock_utils.h"
+
 #include "selftest_llc.h"
 #include "selftest_rc6.h"
 #include "selftest_rps.h"
 
+static int cmp_u64(const void *A, const void *B)
+{
+	const u64 *a = A, *b = B;
+
+	if (a < b)
+		return -1;
+	else if (a > b)
+		return 1;
+	else
+		return 0;
+}
+
+static int cmp_u32(const void *A, const void *B)
+{
+	const u32 *a = A, *b = B;
+
+	if (a < b)
+		return -1;
+	else if (a > b)
+		return 1;
+	else
+		return 0;
+}
+
+static void measure_clocks(struct intel_engine_cs *engine,
+			   u32 *out_cycles, ktime_t *out_dt)
+{
+	ktime_t dt[5];
+	u32 cycles[5];
+	int i;
+
+	for (i = 0; i < 5; i++) {
+		preempt_disable();
+		dt[i] = ktime_get();
+		cycles[i] = -ENGINE_READ_FW(engine, RING_TIMESTAMP);
+
+		udelay(1000);
+
+		dt[i] = ktime_sub(ktime_get(), dt[i]);
+		cycles[i] += ENGINE_READ_FW(engine, RING_TIMESTAMP);
+		preempt_enable();
+	}
+
+	/* Use the median of both cycle/dt; close enough */
+	sort(cycles, 5, sizeof(*cycles), cmp_u32, NULL);
+	*out_cycles = (cycles[1] + 2 * cycles[2] + cycles[3]) / 4;
+
+	sort(dt, 5, sizeof(*dt), cmp_u64, NULL);
+	*out_dt = div_u64(dt[1] + 2 * dt[2] + dt[3], 4);
+}
+
+static int live_gt_clocks(void *arg)
+{
+	struct intel_gt *gt = arg;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	int err = 0;
+
+	if (!RUNTIME_INFO(gt->i915)->cs_timestamp_frequency_hz) { /* unknown */
+		pr_info("CS_TIMESTAMP frequency unknown\n");
+		return 0;
+	}
+
+	if (INTEL_GEN(gt->i915) < 4) /* Any CS_TIMESTAMP? */
+		return 0;
+
+	intel_gt_pm_get(gt);
+	intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_ALL);
+
+	for_each_engine(engine, gt, id) {
+		u32 cycles;
+		u32 expected;
+		u64 time;
+		u64 dt;
+
+		if (INTEL_GEN(engine->i915) < 7 && engine->id != RCS0)
+			continue;
+
+		measure_clocks(engine, &cycles, &dt);
+
+		time = i915_cs_timestamp_ticks_to_ns(engine->i915, cycles);
+		expected = i915_cs_timestamp_ns_to_ticks(engine->i915, dt);
+
+		pr_info("%s: TIMESTAMP %d cycles [%lldns] in %lldns [%d cycles], using CS clock frequency of %uKHz\n",
+			engine->name, cycles, time, dt, expected,
+			RUNTIME_INFO(engine->i915)->cs_timestamp_frequency_hz / 1000);
+
+		if (9 * time < 8 * dt || 8 * time > 9 * dt) {
+			pr_err("%s: rps clock time does not match walltime!\n",
+			       engine->name);
+			err = -EINVAL;
+			break;
+		}
+
+		if (9 * expected < 8 * cycles || 8 * expected > 9 * cycles) {
+			pr_err("%s: walltime does not match rps clock ticks!\n",
+			       engine->name);
+			err = -EINVAL;
+			break;
+		}
+	}
+
+	intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL);
+	intel_gt_pm_put(gt);
+
+	return err;
+}
+
 static int live_gt_resume(void *arg)
 {
 	struct intel_gt *gt = arg;
@@ -52,6 +164,7 @@ static int live_gt_resume(void *arg)
 int intel_gt_pm_live_selftests(struct drm_i915_private *i915)
 {
 	static const struct i915_subtest tests[] = {
+		SUBTEST(live_gt_clocks),
 		SUBTEST(live_rc6_manual),
 		SUBTEST(live_rps_clock_interval),
 		SUBTEST(live_rps_control),
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
  2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
@ 2020-05-16 13:31 ` Chris Wilson
  2020-05-18  9:18   ` Chris Wilson
  2020-05-19 10:42   ` Ville Syrjälä
  2020-05-18  8:16 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev2) Patchwork
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-16 13:31 UTC (permalink / raw)
  To: intel-gfx; +Cc: Chris Wilson

Count the number of CS_TIMESTAMP ticks and check that it matches our
expectations.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 113 +++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
index 242181a5214c..cac4cf2a5e1d 100644
--- a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
@@ -5,10 +5,122 @@
  * Copyright © 2019 Intel Corporation
  */
 
+#include <linux/sort.h>
+
+#include "intel_gt_clock_utils.h"
+
 #include "selftest_llc.h"
 #include "selftest_rc6.h"
 #include "selftest_rps.h"
 
+static int cmp_u64(const void *A, const void *B)
+{
+	const u64 *a = A, *b = B;
+
+	if (a < b)
+		return -1;
+	else if (a > b)
+		return 1;
+	else
+		return 0;
+}
+
+static int cmp_u32(const void *A, const void *B)
+{
+	const u32 *a = A, *b = B;
+
+	if (a < b)
+		return -1;
+	else if (a > b)
+		return 1;
+	else
+		return 0;
+}
+
+static void measure_clocks(struct intel_engine_cs *engine,
+			   u32 *out_cycles, ktime_t *out_dt)
+{
+	ktime_t dt[5];
+	u32 cycles[5];
+	int i;
+
+	for (i = 0; i < 5; i++) {
+		preempt_disable();
+		dt[i] = ktime_get();
+		cycles[i] = -ENGINE_READ_FW(engine, RING_TIMESTAMP);
+
+		udelay(1000);
+
+		dt[i] = ktime_sub(ktime_get(), dt[i]);
+		cycles[i] += ENGINE_READ_FW(engine, RING_TIMESTAMP);
+		preempt_enable();
+	}
+
+	/* Use the median of both cycle/dt; close enough */
+	sort(cycles, 5, sizeof(*cycles), cmp_u32, NULL);
+	*out_cycles = (cycles[1] + 2 * cycles[2] + cycles[3]) / 4;
+
+	sort(dt, 5, sizeof(*dt), cmp_u64, NULL);
+	*out_dt = div_u64(dt[1] + 2 * dt[2] + dt[3], 4);
+}
+
+static int live_gt_clocks(void *arg)
+{
+	struct intel_gt *gt = arg;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	int err = 0;
+
+	if (!RUNTIME_INFO(gt->i915)->cs_timestamp_frequency_hz) { /* unknown */
+		pr_info("CS_TIMESTAMP frequency unknown\n");
+		return 0;
+	}
+
+	if (INTEL_GEN(gt->i915) < 4) /* Any CS_TIMESTAMP? */
+		return 0;
+
+	intel_gt_pm_get(gt);
+	intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_ALL);
+
+	for_each_engine(engine, gt, id) {
+		u32 cycles;
+		u32 expected;
+		u64 time;
+		u64 dt;
+
+		if (INTEL_GEN(engine->i915) < 7 && engine->id != RCS0)
+			continue;
+
+		measure_clocks(engine, &cycles, &dt);
+
+		time = i915_cs_timestamp_ticks_to_ns(engine->i915, cycles);
+		expected = i915_cs_timestamp_ns_to_ticks(engine->i915, dt);
+
+		pr_info("%s: TIMESTAMP %d cycles [%lldns] in %lldns [%d cycles], using CS clock frequency of %uKHz\n",
+			engine->name, cycles, time, dt, expected,
+			RUNTIME_INFO(engine->i915)->cs_timestamp_frequency_hz / 1000);
+
+		if (9 * time < 8 * dt || 8 * time > 9 * dt) {
+			pr_err("%s: CS ticks did not match walltime!\n",
+			       engine->name);
+			err = -EINVAL;
+			break;
+		}
+
+		if (9 * expected < 8 * cycles || 8 * expected > 9 * cycles) {
+			pr_err("%s: walltime did not match CS ticks!\n",
+			       engine->name);
+			err = -EINVAL;
+			break;
+		}
+	}
+
+	intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL);
+	intel_gt_pm_put(gt);
+
+	return err;
+}
+
 static int live_gt_resume(void *arg)
 {
 	struct intel_gt *gt = arg;
@@ -52,6 +164,7 @@ static int live_gt_resume(void *arg)
 int intel_gt_pm_live_selftests(struct drm_i915_private *i915)
 {
 	static const struct i915_subtest tests[] = {
+		SUBTEST(live_gt_clocks),
 		SUBTEST(live_rc6_manual),
 		SUBTEST(live_rps_clock_interval),
 		SUBTEST(live_rps_control),
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev2)
  2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
  2020-05-16 13:31 ` Chris Wilson
@ 2020-05-18  8:16 ` Patchwork
  2020-05-18  8:39 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-18  8:16 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/selftests: Measure CS_TIMESTAMP (rev2)
URL   : https://patchwork.freedesktop.org/series/77320/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
07967d1266af drm/i915/selftests: Measure CS_TIMESTAMP
-:67: CHECK:USLEEP_RANGE: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst
#67: FILE: drivers/gpu/drm/i915/gt/selftest_gt_pm.c:52:
+		udelay(1000);

total: 0 errors, 0 warnings, 1 checks, 129 lines checked

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/selftests: Measure CS_TIMESTAMP (rev2)
  2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
  2020-05-16 13:31 ` Chris Wilson
  2020-05-18  8:16 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev2) Patchwork
@ 2020-05-18  8:39 ` Patchwork
  2020-05-19 12:36 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev3) Patchwork
  2020-05-19 12:59 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
  4 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-18  8:39 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/selftests: Measure CS_TIMESTAMP (rev2)
URL   : https://patchwork.freedesktop.org/series/77320/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8493 -> Patchwork_17679
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_17679 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_17679, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17679/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_17679:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@gt_pm:
    - fi-elk-e7500:       [PASS][1] -> [DMESG-FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8493/fi-elk-e7500/igt@i915_selftest@live@gt_pm.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17679/fi-elk-e7500/igt@i915_selftest@live@gt_pm.html
    - fi-ilk-650:         [PASS][3] -> [DMESG-FAIL][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8493/fi-ilk-650/igt@i915_selftest@live@gt_pm.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17679/fi-ilk-650/igt@i915_selftest@live@gt_pm.html

  
Known issues
------------

  Here are the changes found in Patchwork_17679 that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@i915_selftest@live@execlists:
    - fi-tgl-y:           [INCOMPLETE][5] ([i915#1803]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8493/fi-tgl-y/igt@i915_selftest@live@execlists.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17679/fi-tgl-y/igt@i915_selftest@live@execlists.html

  
  [i915#1803]: https://gitlab.freedesktop.org/drm/intel/issues/1803


Participating hosts (51 -> 45)
------------------------------

  Additional (1): fi-kbl-7560u 
  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * Linux: CI_DRM_8493 -> Patchwork_17679

  CI-20190529: 20190529
  CI_DRM_8493: 47e0097b33017be45f6826ef82a1f535b81ab9a3 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5657: 649eae5c905a7460b44305800f95db83a6dd47cb @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17679: 07967d1266aff2a58aadc6cbb3faa4ec4725d274 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

07967d1266af drm/i915/selftests: Measure CS_TIMESTAMP

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17679/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
  2020-05-16 13:31 ` Chris Wilson
@ 2020-05-18  9:18   ` Chris Wilson
  2020-05-19 10:42   ` Ville Syrjälä
  1 sibling, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2020-05-18  9:18 UTC (permalink / raw)
  To: intel-gfx

Quoting Chris Wilson (2020-05-16 14:31:02)
> Count the number of CS_TIMESTAMP ticks and check that it matches our
> expectations.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

ilk:
<6> [197.410742] rcs0: TIMESTAMP 0 cycles [0ns] in 1001322ns [12517 cycles], using CS clock frequency of 12500KHz

elk:
<6> [203.278858] rcs0: TIMESTAMP 562036736 cycles [33722163018ns] in 1001366ns [16690 cycles], using CS clock frequency of 16666KHz

Those two do look gibberish.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
  2020-05-16 13:31 ` Chris Wilson
  2020-05-18  9:18   ` Chris Wilson
@ 2020-05-19 10:42   ` Ville Syrjälä
  2020-05-19 10:46     ` Chris Wilson
  1 sibling, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2020-05-19 10:42 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Sat, May 16, 2020 at 02:31:02PM +0100, Chris Wilson wrote:
> Count the number of CS_TIMESTAMP ticks and check that it matches our
> expectations.

Looks ok for everything except g4x/ilk. Those would need something
like
https://patchwork.freedesktop.org/patch/355944/?series=74145&rev=1
+ read TIMESTAMP_UDW instead of TIMESTAMP.

bw/cl still needs
https://patchwork.freedesktop.org/patch/355946/?series=74145&rev=1
though the test seems a bit flaky on my cl. Sometimes the cycle count
comes up short. Never seen it exceed the expected value, but it can 
come up significantly short. And curiously it does seem to have a
tendency to come out as roughly some nice fraction (seen at least
1/2 and 1/4 quite a few times). Dunno if the tick rate actually
changes due to some unknown circumstances, or if the counter just
updates somehow lazily. Certainly polling the counter over a longer
period does show it to tick at the expected rate.

Anyways, test looks sane to me
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 113 +++++++++++++++++++++++
>  1 file changed, 113 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
> index 242181a5214c..cac4cf2a5e1d 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
> @@ -5,10 +5,122 @@
>   * Copyright © 2019 Intel Corporation
>   */
>  
> +#include <linux/sort.h>
> +
> +#include "intel_gt_clock_utils.h"
> +
>  #include "selftest_llc.h"
>  #include "selftest_rc6.h"
>  #include "selftest_rps.h"
>  
> +static int cmp_u64(const void *A, const void *B)
> +{
> +	const u64 *a = A, *b = B;
> +
> +	if (a < b)
> +		return -1;
> +	else if (a > b)
> +		return 1;
> +	else
> +		return 0;
> +}
> +
> +static int cmp_u32(const void *A, const void *B)
> +{
> +	const u32 *a = A, *b = B;
> +
> +	if (a < b)
> +		return -1;
> +	else if (a > b)
> +		return 1;
> +	else
> +		return 0;
> +}
> +
> +static void measure_clocks(struct intel_engine_cs *engine,
> +			   u32 *out_cycles, ktime_t *out_dt)
> +{
> +	ktime_t dt[5];
> +	u32 cycles[5];
> +	int i;
> +
> +	for (i = 0; i < 5; i++) {
> +		preempt_disable();
> +		dt[i] = ktime_get();
> +		cycles[i] = -ENGINE_READ_FW(engine, RING_TIMESTAMP);
> +
> +		udelay(1000);
> +
> +		dt[i] = ktime_sub(ktime_get(), dt[i]);
> +		cycles[i] += ENGINE_READ_FW(engine, RING_TIMESTAMP);
> +		preempt_enable();
> +	}
> +
> +	/* Use the median of both cycle/dt; close enough */
> +	sort(cycles, 5, sizeof(*cycles), cmp_u32, NULL);
> +	*out_cycles = (cycles[1] + 2 * cycles[2] + cycles[3]) / 4;
> +
> +	sort(dt, 5, sizeof(*dt), cmp_u64, NULL);
> +	*out_dt = div_u64(dt[1] + 2 * dt[2] + dt[3], 4);
> +}
> +
> +static int live_gt_clocks(void *arg)
> +{
> +	struct intel_gt *gt = arg;
> +	struct intel_engine_cs *engine;
> +	enum intel_engine_id id;
> +	int err = 0;
> +
> +	if (!RUNTIME_INFO(gt->i915)->cs_timestamp_frequency_hz) { /* unknown */
> +		pr_info("CS_TIMESTAMP frequency unknown\n");
> +		return 0;
> +	}
> +
> +	if (INTEL_GEN(gt->i915) < 4) /* Any CS_TIMESTAMP? */
> +		return 0;
> +
> +	intel_gt_pm_get(gt);
> +	intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_ALL);
> +
> +	for_each_engine(engine, gt, id) {
> +		u32 cycles;
> +		u32 expected;
> +		u64 time;
> +		u64 dt;
> +
> +		if (INTEL_GEN(engine->i915) < 7 && engine->id != RCS0)
> +			continue;
> +
> +		measure_clocks(engine, &cycles, &dt);
> +
> +		time = i915_cs_timestamp_ticks_to_ns(engine->i915, cycles);
> +		expected = i915_cs_timestamp_ns_to_ticks(engine->i915, dt);
> +
> +		pr_info("%s: TIMESTAMP %d cycles [%lldns] in %lldns [%d cycles], using CS clock frequency of %uKHz\n",
> +			engine->name, cycles, time, dt, expected,
> +			RUNTIME_INFO(engine->i915)->cs_timestamp_frequency_hz / 1000);
> +
> +		if (9 * time < 8 * dt || 8 * time > 9 * dt) {
> +			pr_err("%s: CS ticks did not match walltime!\n",
> +			       engine->name);
> +			err = -EINVAL;
> +			break;
> +		}
> +
> +		if (9 * expected < 8 * cycles || 8 * expected > 9 * cycles) {
> +			pr_err("%s: walltime did not match CS ticks!\n",
> +			       engine->name);
> +			err = -EINVAL;
> +			break;
> +		}
> +	}
> +
> +	intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL);
> +	intel_gt_pm_put(gt);
> +
> +	return err;
> +}
> +
>  static int live_gt_resume(void *arg)
>  {
>  	struct intel_gt *gt = arg;
> @@ -52,6 +164,7 @@ static int live_gt_resume(void *arg)
>  int intel_gt_pm_live_selftests(struct drm_i915_private *i915)
>  {
>  	static const struct i915_subtest tests[] = {
> +		SUBTEST(live_gt_clocks),
>  		SUBTEST(live_rc6_manual),
>  		SUBTEST(live_rps_clock_interval),
>  		SUBTEST(live_rps_control),
> -- 
> 2.20.1

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
  2020-05-19 10:42   ` Ville Syrjälä
@ 2020-05-19 10:46     ` Chris Wilson
  2020-05-19 11:47       ` Ville Syrjälä
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2020-05-19 10:46 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

Quoting Ville Syrjälä (2020-05-19 11:42:45)
> On Sat, May 16, 2020 at 02:31:02PM +0100, Chris Wilson wrote:
> > Count the number of CS_TIMESTAMP ticks and check that it matches our
> > expectations.
> 
> Looks ok for everything except g4x/ilk. Those would need something
> like
> https://patchwork.freedesktop.org/patch/355944/?series=74145&rev=1
> + read TIMESTAMP_UDW instead of TIMESTAMP.
> 
> bw/cl still needs
> https://patchwork.freedesktop.org/patch/355946/?series=74145&rev=1
> though the test seems a bit flaky on my cl. Sometimes the cycle count
> comes up short. Never seen it exceed the expected value, but it can 
> come up significantly short. And curiously it does seem to have a
> tendency to come out as roughly some nice fraction (seen at least
> 1/2 and 1/4 quite a few times). Dunno if the tick rate actually
> changes due to some unknown circumstances, or if the counter just
> updates somehow lazily. Certainly polling the counter over a longer
> period does show it to tick at the expected rate.

Any guestimate at how short a period is long enough?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP
  2020-05-19 10:46     ` Chris Wilson
@ 2020-05-19 11:47       ` Ville Syrjälä
  0 siblings, 0 replies; 10+ messages in thread
From: Ville Syrjälä @ 2020-05-19 11:47 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Tue, May 19, 2020 at 11:46:54AM +0100, Chris Wilson wrote:
> Quoting Ville Syrjälä (2020-05-19 11:42:45)
> > On Sat, May 16, 2020 at 02:31:02PM +0100, Chris Wilson wrote:
> > > Count the number of CS_TIMESTAMP ticks and check that it matches our
> > > expectations.
> > 
> > Looks ok for everything except g4x/ilk. Those would need something
> > like
> > https://patchwork.freedesktop.org/patch/355944/?series=74145&rev=1
> > + read TIMESTAMP_UDW instead of TIMESTAMP.
> > 
> > bw/cl still needs
> > https://patchwork.freedesktop.org/patch/355946/?series=74145&rev=1
> > though the test seems a bit flaky on my cl. Sometimes the cycle count
> > comes up short. Never seen it exceed the expected value, but it can 
> > come up significantly short. And curiously it does seem to have a
> > tendency to come out as roughly some nice fraction (seen at least
> > 1/2 and 1/4 quite a few times). Dunno if the tick rate actually
> > changes due to some unknown circumstances, or if the counter just
> > updates somehow lazily. Certainly polling the counter over a longer
> > period does show it to tick at the expected rate.
> 
> Any guestimate at how short a period is long enough?

After a bit more debugging it looks like the read just sometimes returns
a stale value:
[ 5248.749794] rcs0: 0: TIMESTAMP 75->123 (48) cycles [1013808ns]
[ 5248.749817] rcs0: 1: TIMESTAMP 202859->202859 (0) cycles [1031688ns]
[ 5248.749818] rcs0: 2: TIMESTAMP 409179->613179 (204000) cycles [1020234ns]
[ 5248.749820] rcs0: 3: TIMESTAMP 613227->825083 (211856) cycles [1059623ns]
[ 5248.749821] rcs0: 4: TIMESTAMP 825163->1036491 (211328) cycles [1057109ns]

So far it looks like doing a double read is sufficient to get
an up to date value.

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev3)
  2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
                   ` (2 preceding siblings ...)
  2020-05-18  8:39 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
@ 2020-05-19 12:36 ` Patchwork
  2020-05-19 12:59 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
  4 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-19 12:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/selftests: Measure CS_TIMESTAMP (rev3)
URL   : https://patchwork.freedesktop.org/series/77320/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
4686c5234501 drm/i915/selftests: Measure CS_TIMESTAMP
-:68: CHECK:USLEEP_RANGE: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst
#68: FILE: drivers/gpu/drm/i915/gt/selftest_gt_pm.c:52:
+		udelay(1000);

total: 0 errors, 0 warnings, 1 checks, 129 lines checked

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/selftests: Measure CS_TIMESTAMP (rev3)
  2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
                   ` (3 preceding siblings ...)
  2020-05-19 12:36 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev3) Patchwork
@ 2020-05-19 12:59 ` Patchwork
  4 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2020-05-19 12:59 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/selftests: Measure CS_TIMESTAMP (rev3)
URL   : https://patchwork.freedesktop.org/series/77320/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8502 -> Patchwork_17708
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_17708 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_17708, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_17708:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@gt_pm:
    - fi-elk-e7500:       [PASS][1] -> [DMESG-FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8502/fi-elk-e7500/igt@i915_selftest@live@gt_pm.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/fi-elk-e7500/igt@i915_selftest@live@gt_pm.html
    - fi-ilk-650:         [PASS][3] -> [DMESG-FAIL][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8502/fi-ilk-650/igt@i915_selftest@live@gt_pm.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/fi-ilk-650/igt@i915_selftest@live@gt_pm.html
    - fi-bwr-2160:        [PASS][5] -> [DMESG-FAIL][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8502/fi-bwr-2160/igt@i915_selftest@live@gt_pm.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/fi-bwr-2160/igt@i915_selftest@live@gt_pm.html

  
Known issues
------------

  Here are the changes found in Patchwork_17708 that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@i915_selftest@live@execlists:
    - fi-cfl-guc:         [INCOMPLETE][7] ([i915#656]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8502/fi-cfl-guc/igt@i915_selftest@live@execlists.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/fi-cfl-guc/igt@i915_selftest@live@execlists.html

  
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656


Participating hosts (50 -> 44)
------------------------------

  Missing    (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper 


Build changes
-------------

  * Linux: CI_DRM_8502 -> Patchwork_17708

  CI-20190529: 20190529
  CI_DRM_8502: 5bafb3de802a8dd663009250b587c1a78ad298c9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5659: 66ab5e42811fee3dea8c21ab29e70e323a0650de @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17708: 4686c52345011560c020f375436eea7fcb31fbae @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

4686c5234501 drm/i915/selftests: Measure CS_TIMESTAMP

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17708/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-19 12:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 13:24 [Intel-gfx] [PATCH] drm/i915/selftests: Measure CS_TIMESTAMP Chris Wilson
2020-05-16 13:31 ` Chris Wilson
2020-05-18  9:18   ` Chris Wilson
2020-05-19 10:42   ` Ville Syrjälä
2020-05-19 10:46     ` Chris Wilson
2020-05-19 11:47       ` Ville Syrjälä
2020-05-18  8:16 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev2) Patchwork
2020-05-18  8:39 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2020-05-19 12:36 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/selftests: Measure CS_TIMESTAMP (rev3) Patchwork
2020-05-19 12:59 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).