[igt-dev] [PATCH i-g-t 2/2] i915/i915_pm_rps: Write values in pm_rps_exit_handler only for min-max configs

Karolina Drobnik karolina.drobnik at intel.com
Thu Jul 28 15:06:58 UTC 2022


From: Chris Wilson <chris at chris-wilson.co.uk>

pm_rps_exit_handler writes min and max frequencies to the corresponding
sysfs files. In a situation where each test initializes only specific
handlers, it's possible that the exit handler will dereference a NULL
value in MIN and MAX file handlers.

To prevent this, check if the exit handler is called by a subtest
that initialized handlers to files describing frequency constraints.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Karolina Drobnik <karolina.drobnik at intel.com>
---
 tests/i915/i915_pm_rps.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index 0af46038..a45a6905 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -859,12 +859,14 @@ static void engine_order(int i915)

 static void pm_rps_exit_handler(int sig)
 {
-	if (origfreqs[MIN] > readval(sysfs_files[MAX].filp)) {
-		writeval(sysfs_files[MAX].filp, origfreqs[MAX]);
-		writeval(sysfs_files[MIN].filp, origfreqs[MIN]);
-	} else {
-		writeval(sysfs_files[MIN].filp, origfreqs[MIN]);
-		writeval(sysfs_files[MAX].filp, origfreqs[MAX]);
+	if (sysfs_files[MAX].filp) {
+		if (origfreqs[MIN] > readval(sysfs_files[MAX].filp)) {
+			writeval(sysfs_files[MAX].filp, origfreqs[MAX]);
+			writeval(sysfs_files[MIN].filp, origfreqs[MIN]);
+		} else {
+			writeval(sysfs_files[MIN].filp, origfreqs[MIN]);
+			writeval(sysfs_files[MAX].filp, origfreqs[MAX]);
+		}
 	}

 	if (lh.igt_proc.running)
--
2.25.1


More information about the igt-dev mailing list