Skip to contentSkip to conversation

lib/psr: Do not use out of bound enum for psr_set.

PATCH In review Maarten Lankhorst 3 participants 7 messages Jan 31, 2019 – Feb 1, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/psr: Do not use out of bound enum for psr_set.

Using an undefined int not in the enum is undefined. Use -1 and change mode to an integer.

Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
---
 lib/igt_psr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/igt_psr.c +4 -4
index d726fad58e9d..5eb6d2c6ace5 100644
@@ -100,13 +100,13 @@ static void restore_psr_debugfs(int sig)
 	psr_write(psr_restore_debugfs_fd, "0");
 }
 
-static bool psr_set(int debugfs_fd, enum psr_mode mode)
+static bool psr_set(int debugfs_fd, int mode)
 {
 	int ret;
 
 	ret = has_psr_debugfs(debugfs_fd);
 	if (ret == -ENODEV) {
-		igt_skip("PSR not available\n");
+		igt_skip_on_f(mode >= PSR_MODE_1, "PSR not available\n");
 		return false;
 	}
 
@@ -117,7 +117,7 @@ static bool psr_set(int debugfs_fd, enum psr_mode mode)
 		 * version enabled and the PSR version of the test, it will
 		 * fail in the first psr_wait_entry() of the test.
 		 */
-		ret = psr_modparam_set(mode <= PSR_MODE_2);
+		ret = psr_modparam_set(mode >= PSR_MODE_1);
 	} else {
 		const char *debug_val;
 
@@ -155,7 +155,7 @@ bool psr_enable(int debugfs_fd, enum psr_mode mode)
 bool psr_disable(int debugfs_fd)
 {
 	/* Any mode different than PSR_MODE_1/2 will disable PSR */
-	return psr_set(debugfs_fd, PSR_MODE_2 + 1);
+	return psr_set(debugfs_fd, -1);
 }
 
 bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH 2/2 tests/kms_frontbuffer_tracking: Fix skips when PSR is not available.

Use psr.can_test to determine we can disable PSR, and not skip because PSR is unavailable.

Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
---
 lib/igt_psr.c                    | 2 +-
 tests/kms_frontbuffer_tracking.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/igt_psr.c +1 -1
index 5eb6d2c6ace5..6ad2c522f9a4 100644
@@ -106,7 +106,7 @@ static bool psr_set(int debugfs_fd, int mode)
 
 	ret = has_psr_debugfs(debugfs_fd);
 	if (ret == -ENODEV) {
-		igt_skip_on_f(mode >= PSR_MODE_1, "PSR not available\n");
+		igt_skip("PSR not available\n");
 		return false;
 	}
 
tests/kms_frontbuffer_tracking.c +1 -1
index 609f7b41a527..4d15ce1cf1d6 100644
@@ -1134,7 +1134,7 @@ static bool disable_features(const struct test_mode *t)
 
 	fbc_disable();
 	drrs_disable();
-	return psr_disable(drm.debugfs);
+	return psr.can_test ? psr_disable(drm.debugfs) : false;
 }
 
 static void *busy_thread_func(void *data)
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/psr: Do not use out of bound enum for psr_set.

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,1/2] lib/psr: Do not use out of bound enum for psr_set.
URL : https://patchwork.freedesktop.org/series/56047/
State : success

== Summary ==

CI Bug Log - changes from IGT_4802 -> IGTPW_2327
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56047/revisions/1/mbox/

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_coherency:
- fi-gdg-551: PASS -> DMESG-FAIL [fdo#107164]

* igt@kms_flip@basic-flip-vs-wf_vblank:
- fi-bsw-n3050: PASS -> FAIL [fdo#100368]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362]

* igt@prime_vgem@basic-fence-flip:
- fi-gdg-551: PASS -> DMESG-FAIL [fdo#103182]

#### Possible fixes ####

* igt@i915_module_load@reload:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS

* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: FAIL [fdo#103167] -> PASS

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
- fi-byt-clapper: FAIL [fdo#107362] -> PASS

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS

* igt@pm_rpm@module-reload:
- fi-skl-6770hq: FAIL [fdo#108511] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#100368]: https://bugs.freedesktop.org/show_bug.cgi?id=100368
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#107164]: https://bugs.freedesktop.org/show_bug.cgi?id=107164
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#108915]: https://bugs.freedesktop.org/show_bug.cgi?id=108915
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271

Participating hosts (48 -> 45)
------------------------------

Additional (2): fi-icl-y fi-kbl-7567u
Missing (5): fi-kbl-soraka fi-ilk-m540 fi-byt-j1900 fi-byt-squawks fi-bsw-cyan

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

* IGT: IGT_4802 -> IGTPW_2327

CI_DRM_5518: 2369fd28d3a46b865f6d4f1d309a4c6b7b4e6d93 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2327: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2327/
IGT_4802: 4049adf01014af077df2174def4fadf7cecb066e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2327/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 2/2
#2 lore raw

Re: [igt-dev] [PATCH i-g-t 2/2] tests/kms_frontbuffer_tracking: Fix skips when PSR is not available.

In reply to Maarten Lankhorst
Quoted 32 lines · Maarten Lankhorst

Use psr.can_test to determine we can disable PSR, and not skip because
PSR is unavailable.

Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
---
 lib/igt_psr.c                    | 2 +-
 tests/kms_frontbuffer_tracking.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/igt_psr.c +1 -1
index 5eb6d2c6ace5..6ad2c522f9a4 100644
@@ -106,7 +106,7 @@ static bool psr_set(int debugfs_fd, int mode)
 
 	ret = has_psr_debugfs(debugfs_fd);
 	if (ret == -ENODEV) {
-		igt_skip_on_f(mode >= PSR_MODE_1, "PSR not
 available\n");
+		igt_skip("PSR not available\n");
 		return false;
 	}
tests/kms_frontbuffer_tracking.c +0 -0
index 609f7b41a527..4d15ce1cf1d6 100644

tests/kms_frontbuffer_tracking.c static bool disable_features(const struct · line 1138

Quoted 5 lines
tests/kms_frontbuffer_tracking.c +0 -1
@@ -1134,7 +1134,7 @@ static bool disable_features(const struct
 test_mode *t)
 
 	fbc_disable();
 	drrs_disable();
-	return psr_disable(drm.debugfs);

Although the return true of this functions will cause a unecessary igt_display_commit() this changes looks good. In other patch we could just drop the return and remove the commit in prepare_subtest_data().

Quoted 4 lines
tests/kms_frontbuffer_tracking.c +1 -0
+	return psr.can_test ? psr_disable(drm.debugfs) : false;
 }
 

static void *busy_thread_func(void *data)

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/2
#5 lore raw
In reply to Maarten Lankhorst
Quoted 3 lines · Maarten Lankhorst

Using an undefined int not in the enum is undefined. Use -1 and change
mode to an integer.

Quoted 49 lines
Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
---
 lib/igt_psr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/igt_psr.c +2 -2
index d726fad58e9d..5eb6d2c6ace5 100644
@@ -100,13 +100,13 @@ static void restore_psr_debugfs(int sig)
 	psr_write(psr_restore_debugfs_fd, "0");
 }
 
-static bool psr_set(int debugfs_fd, enum psr_mode mode)
+static bool psr_set(int debugfs_fd, int mode)
 {
 	int ret;
 
 	ret = has_psr_debugfs(debugfs_fd);
 	if (ret == -ENODEV) {
-		igt_skip("PSR not available\n");
+		igt_skip_on_f(mode >= PSR_MODE_1, "PSR not
 available\n");
 		return false;
 	}
@@ -117,7 +117,7 @@ static bool psr_set(int debugfs_fd, enum psr_mode
 mode)
 		 * version enabled and the PSR version of the test, it

will

lib/igt_psr.c +2 -2
 		 * fail in the first psr_wait_entry() of the test.
 		 */
-		ret = psr_modparam_set(mode <= PSR_MODE_2);
+		ret = psr_modparam_set(mode >= PSR_MODE_1);
 	} else {
 		const char *debug_val;
@@ -155,7 +155,7 @@ bool psr_enable(int debugfs_fd, enum psr_mode
 mode)
 bool psr_disable(int debugfs_fd)
 {
 	/* Any mode different than PSR_MODE_1/2 will disable PSR */
-	return psr_set(debugfs_fd, PSR_MODE_2 + 1);
+	return psr_set(debugfs_fd, -1);
 }
 
Quoted 1 line

bool psr_sink_support(int debugfs_fd, enum psr_mode mode)

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] lib/psr: Do not use out of bound enum for psr_set.

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,1/2] lib/psr: Do not use out of bound enum for psr_set.
URL : https://patchwork.freedesktop.org/series/56047/
State : success

== Summary ==

CI Bug Log - changes from IGT_4802_full -> IGTPW_2327_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56047/revisions/1/mbox/

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_eio@reset-stress:
- shard-snb: PASS -> INCOMPLETE [fdo#105411]

* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
- shard-snb: NOTRUN -> DMESG-WARN [fdo#107956] +2

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-c:
- shard-glk: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_color@pipe-a-legacy-gamma:
- shard-kbl: PASS -> FAIL [fdo#104782] / [fdo#108145]
- shard-apl: PASS -> FAIL [fdo#104782] / [fdo#108145]

* igt@kms_color@pipe-c-degamma:
- shard-apl: PASS -> FAIL [fdo#104782]

* igt@kms_cursor_crc@cursor-128x128-suspend:

    - shard-glk:          PASS -> FAIL [fdo#103232] +2
    - shard-apl:          PASS -> FAIL [fdo#103191] / [fdo#103232]
    - shard-kbl:          PASS -> FAIL [fdo#103191] / [fdo#103232]

* igt@kms_cursor_crc@cursor-64x21-random:
- shard-apl: PASS -> FAIL [fdo#103232] +6
- shard-kbl: PASS -> FAIL [fdo#103232] +1

* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-hsw: PASS -> INCOMPLETE [fdo#103540]

* igt@kms_plane@plane-position-covered-pipe-c-planes:

    - shard-apl:          PASS -> FAIL [fdo#103166] +3
    - shard-glk:          NOTRUN -> FAIL [fdo#103166]
    - shard-kbl:          PASS -> FAIL [fdo#103166]

* igt@kms_plane_alpha_blend@pipe-b-alpha-7efc:
- shard-kbl: NOTRUN -> FAIL [fdo#108145] / [fdo#108590]

* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max:
- shard-glk: PASS -> FAIL [fdo#108145] +1

* igt@kms_plane_multiple@atomic-pipe-b-tiling-none:
- shard-glk: PASS -> FAIL [fdo#103166] +1

* igt@kms_setmode@basic:
- shard-snb: NOTRUN -> FAIL [fdo#99912]

* igt@kms_vblank@crtc-id:
- shard-snb: NOTRUN -> FAIL [fdo#109490]

#### Possible fixes ####

* igt@gem_exec_params@rel-constants-invalid-rel-gen5:
- shard-snb: INCOMPLETE [fdo#105411] -> PASS

* igt@i915_suspend@fence-restore-untiled:
- shard-apl: DMESG-WARN [fdo#108566] -> PASS

* igt@kms_available_modes_crc@available_mode_test_crc:
- shard-glk: FAIL [fdo#106641] -> PASS

* igt@kms_color@pipe-b-legacy-gamma:
- shard-apl: FAIL [fdo#104782] -> PASS

* igt@kms_cursor_crc@cursor-256x85-random:
- shard-apl: FAIL [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-64x21-onscreen:
- shard-kbl: FAIL [fdo#103232] -> PASS +1

* igt@kms_cursor_crc@cursor-size-change:
- shard-glk: FAIL [fdo#103232] -> PASS +4

* igt@kms_flip@2x-flip-vs-modeset:
- shard-hsw: DMESG-WARN [fdo#102614] -> PASS

* igt@kms_flip@modeset-vs-vblank-race:
- shard-apl: FAIL [fdo#103060] -> PASS

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
- shard-snb: {SKIP} [fdo#109271] -> PASS +57

* igt@kms_frontbuffer_tracking@fbc-1p-shrfb-fliptrack:
- shard-glk: {SKIP} [fdo#109271] -> PASS +129

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-pwrite:
- shard-hsw: {SKIP} [fdo#109271] -> PASS +139

* igt@kms_frontbuffer_tracking@fbc-farfromfence:
- shard-kbl: {SKIP} [fdo#109271] -> PASS +67

* igt@kms_frontbuffer_tracking@fbc-rgb101010-draw-render:
- shard-apl: {SKIP} [fdo#109271] -> PASS +65

* igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
- shard-glk: FAIL [fdo#108145] -> PASS

* igt@kms_plane_multiple@atomic-pipe-b-tiling-none:
- shard-apl: FAIL [fdo#103166] -> PASS +1

* igt@kms_plane_multiple@atomic-pipe-c-tiling-none:
- shard-glk: FAIL [fdo#103166] -> PASS +4

#### Warnings ####

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
- shard-apl: {SKIP} [fdo#109271] -> FAIL [fdo#103167] +4

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-onoff:
- shard-kbl: {SKIP} [fdo#109271] -> FAIL [fdo#103167] +1

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: {SKIP} [fdo#109271] -> FAIL [fdo#103167] +5

* igt@kms_frontbuffer_tracking@fbc-stridechange:
- shard-hsw: {SKIP} [fdo#109271] -> FAIL [fdo#105682]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103060]: https://bugs.freedesktop.org/show_bug.cgi?id=103060
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#105682]: https://bugs.freedesktop.org/show_bug.cgi?id=105682
[fdo#106641]: https://bugs.freedesktop.org/show_bug.cgi?id=106641
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108590]: https://bugs.freedesktop.org/show_bug.cgi?id=108590
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109490]: https://bugs.freedesktop.org/show_bug.cgi?id=109490
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (7 -> 5)
------------------------------

Missing (2): shard-skl shard-iclb

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

* IGT: IGT_4802 -> IGTPW_2327

CI_DRM_5518: 2369fd28d3a46b865f6d4f1d309a4c6b7b4e6d93 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2327: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2327/
IGT_4802: 4049adf01014af077df2174def4fadf7cecb066e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2327/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Re: [igt-dev] [PATCH i-g-t 2/2] tests/kms_frontbuffer_tracking: Fix skips when PSR is not available.

In reply to Souza, Jose

Op 31-01-2019 om 21:58 schreef Souza, Jose:

Quoted 35 lines · Maarten Lankhorst
Quoted 34 lines

Use psr.can_test to determine we can disable PSR, and not skip because
PSR is unavailable.

Cc Dhinakaran Pandiyan <[email protected]>
Cc José Roberto de Souza <[email protected]>
---
 lib/igt_psr.c                    | 2 +-
 tests/kms_frontbuffer_tracking.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/igt_psr.c +1 -1
index 5eb6d2c6ace5..6ad2c522f9a4 100644
@@ -106,7 +106,7 @@ static bool psr_set(int debugfs_fd, int mode)
 
 	ret = has_psr_debugfs(debugfs_fd);
 	if (ret == -ENODEV) {
-		igt_skip_on_f(mode >= PSR_MODE_1, "PSR not
 available\n");
+		igt_skip("PSR not available\n");
 		return false;
 	}
tests/kms_frontbuffer_tracking.c +0 -0
index 609f7b41a527..4d15ce1cf1d6 100644
@@ -1134,7 +1134,7 @@ static bool disable_features(const struct
 test_mode *t)
 
Quoted 8 lines

tests/kms_frontbuffer_tracking.c static bool disable_features(const struct test_mode *t) · line 1137

Quoted 3 lines
tests/kms_frontbuffer_tracking.c +0 -1
 	fbc_disable();
 	drrs_disable();
-	return psr_disable(drm.debugfs);

Although the return true of this functions will cause a unecessary igt_display_commit() this changes looks good. In other patch we could just drop the return and remove the commit in prepare_subtest_data().

Thanks, pushed.

This should have been documented, but the function must return true if and only if a modeset is required.

Specifically, It should return false for the debugfs case so we don't do unnecessary modesets,

but true for the modparam case.

I think the rework borked it.

~Maarten

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev