[PATCH] drm/i915/selftests: Don't restart WL for every frequency step

Vinay Belgaumkar vinay.belgaumkar at intel.com
Thu Jan 20 17:42:43 UTC 2022


Move spinner start out of the steps loop. If we restart WL for each
freq step, the rapid start/stop causes SLPC algorithm to think that
GT busyness is 50% for it's evaluation interval. This leads to SLPC
not increasing the requested frequency as per the test expectation.

Fixes: 8ee2c227822e (drm/i915/guc/slpc: Add SLPC selftest)

Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar at intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_slpc.c | 104 ++++++++++++------------
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_slpc.c b/drivers/gpu/drm/i915/gt/selftest_slpc.c
index b768cea5943d..eef416747c67 100644
--- a/drivers/gpu/drm/i915/gt/selftest_slpc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_slpc.c
@@ -79,6 +79,29 @@ static int live_slpc_clamp_min(void *arg)
 		if (!intel_engine_can_store_dword(engine))
 			continue;
 
+		st_engine_heartbeat_disable(engine);
+
+		rq = igt_spinner_create_request(&spin,
+						engine->kernel_context,
+						MI_NOOP);
+		if (IS_ERR(rq)) {
+			err = PTR_ERR(rq);
+			st_engine_heartbeat_enable(engine);
+			break;
+		}
+
+		i915_request_add(rq);
+
+		if (!igt_wait_for_spinner(&spin, rq)) {
+			pr_err("%s: Spinner did not start\n",
+			       engine->name);
+			igt_spinner_end(&spin);
+			st_engine_heartbeat_enable(engine);
+			intel_gt_set_wedged(engine->gt);
+			err = -EIO;
+			break;
+		}
+
 		/* Go from min to max in 5 steps */
 		step = (slpc_max_freq - slpc_min_freq) / NUM_STEPS;
 		max_act_freq = slpc_min_freq;
@@ -88,29 +111,6 @@ static int live_slpc_clamp_min(void *arg)
 			if (err)
 				break;
 
-			st_engine_heartbeat_disable(engine);
-
-			rq = igt_spinner_create_request(&spin,
-							engine->kernel_context,
-							MI_NOOP);
-			if (IS_ERR(rq)) {
-				err = PTR_ERR(rq);
-				st_engine_heartbeat_enable(engine);
-				break;
-			}
-
-			i915_request_add(rq);
-
-			if (!igt_wait_for_spinner(&spin, rq)) {
-				pr_err("%s: Spinner did not start\n",
-				       engine->name);
-				igt_spinner_end(&spin);
-				st_engine_heartbeat_enable(engine);
-				intel_gt_set_wedged(engine->gt);
-				err = -EIO;
-				break;
-			}
-
 			/* Wait for GuC to detect business and raise
 			 * requested frequency if necessary.
 			 */
@@ -131,9 +131,6 @@ static int live_slpc_clamp_min(void *arg)
 			act_freq =  intel_rps_read_actual_frequency(rps);
 			if (act_freq > max_act_freq)
 				max_act_freq = act_freq;
-
-			igt_spinner_end(&spin);
-			st_engine_heartbeat_enable(engine);
 		}
 
 		pr_info("Max actual frequency for %s was %d\n",
@@ -145,6 +142,9 @@ static int live_slpc_clamp_min(void *arg)
 			err = -EINVAL;
 		}
 
+		igt_spinner_end(&spin);
+		st_engine_heartbeat_enable(engine);
+
 		if (err)
 			break;
 	}
@@ -210,6 +210,29 @@ static int live_slpc_clamp_max(void *arg)
 		if (!intel_engine_can_store_dword(engine))
 			continue;
 
+		st_engine_heartbeat_disable(engine);
+
+		rq = igt_spinner_create_request(&spin,
+						engine->kernel_context,
+						MI_NOOP);
+		if (IS_ERR(rq)) {
+			st_engine_heartbeat_enable(engine);
+			err = PTR_ERR(rq);
+			break;
+		}
+
+		i915_request_add(rq);
+
+		if (!igt_wait_for_spinner(&spin, rq)) {
+			pr_err("%s: SLPC spinner did not start\n",
+			       engine->name);
+			igt_spinner_end(&spin);
+			st_engine_heartbeat_enable(engine);
+			intel_gt_set_wedged(engine->gt);
+			err = -EIO;
+			break;
+		}
+
 		/* Go from max to min in 5 steps */
 		step = (slpc_max_freq - slpc_min_freq) / NUM_STEPS;
 		max_act_freq = slpc_min_freq;
@@ -219,29 +242,6 @@ static int live_slpc_clamp_max(void *arg)
 			if (err)
 				break;
 
-			st_engine_heartbeat_disable(engine);
-
-			rq = igt_spinner_create_request(&spin,
-							engine->kernel_context,
-							MI_NOOP);
-			if (IS_ERR(rq)) {
-				st_engine_heartbeat_enable(engine);
-				err = PTR_ERR(rq);
-				break;
-			}
-
-			i915_request_add(rq);
-
-			if (!igt_wait_for_spinner(&spin, rq)) {
-				pr_err("%s: SLPC spinner did not start\n",
-				       engine->name);
-				igt_spinner_end(&spin);
-				st_engine_heartbeat_enable(engine);
-				intel_gt_set_wedged(engine->gt);
-				err = -EIO;
-				break;
-			}
-
 			delay_for_h2g();
 
 			/* Verify that SWREQ indeed was set to specific value */
@@ -261,9 +261,6 @@ static int live_slpc_clamp_max(void *arg)
 			if (act_freq > max_act_freq)
 				max_act_freq = act_freq;
 
-			st_engine_heartbeat_enable(engine);
-			igt_spinner_end(&spin);
-
 			if (err)
 				break;
 		}
@@ -277,6 +274,9 @@ static int live_slpc_clamp_max(void *arg)
 			err = -EINVAL;
 		}
 
+		st_engine_heartbeat_enable(engine);
+		igt_spinner_end(&spin);
+
 		if (igt_flush_test(gt->i915)) {
 			err = -EIO;
 			break;
-- 
2.34.0



More information about the dri-devel mailing list