Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tests/core_setmaster: Handle the test even if cards are non-continuous
@ 2024-09-17  7:21 Bommu Krishnaiah
  2024-09-17  8:48 ` ✓ Fi.CI.BAT: success for tests/core_setmaster: Handle the test even if cards are non-continuous (rev5) Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bommu Krishnaiah @ 2024-09-17  7:21 UTC (permalink / raw)
  To: igt-dev; +Cc: Bommu Krishnaiah

Although most of user space assumes drm cards to be populated continuously,
this assumption may not be always true. After hot unpluging and repluging
of card, the card may be non-continuous. To address such scenarios where
the cards can be non-continuous Modify the tweak_perm function to loop all
possible card numbers(card0-card255) and break after first card found.

Problem Description:
The test fails after running the `core_hotunplug@hot*` subtest, where
Card0 is populated as card1, This leads to a failure in the subsequent
`master-drop-set-user` test.

Command sequence for reproducing the issue:
- Check available cards: `ls /dev/dri/`
        - Output: by-path  card0  renderD128
- Run the test: `# ./core_hotunplug --r hotrebind-lateclose`
- Check again: ‘ls /dev/dri/’
        - Output after core_hotunplug : by-path  card1  renderD129
- Run the test: `# ./core_setmaster --r master-drop-set-user`
        - Output: gta@ core_setmaster@master-drop-set-user failure

This failures on both XE and i915 for above sequence.

v2: Break the loop after first card found and check return value of chmod.
v3: Undated comments in code.

Signed-off-by: Bommu Krishnaiah krishnaiah.bommu@intel.com
Cc: Emil Velikov emil.l.velikov@gmail.com
Cc: Himal Prasad Ghimiray himal.prasad.ghimiray@intel.com
Cc: Kamil Konieczny kamil.konieczny@linux.intel.com
---
 tests/core_setmaster.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tests/core_setmaster.c b/tests/core_setmaster.c
index 9c2083f66..91cbc1b39 100644
--- a/tests/core_setmaster.c
+++ b/tests/core_setmaster.c
@@ -107,18 +107,21 @@ static void check_drop_set(void)
 	drm_close_driver(master);
 }
 
-static unsigned tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
+static int tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
 {
 	char path[256];
 	struct stat st;
-	unsigned i;
+	int i;
 
 	for (i = 0; i < max_perm; i++) {
+		int ret = 0;
+
 		snprintf(path, sizeof(path), "/dev/dri/card%u", i);
 
-		/* Existing userspace assumes there's no gaps, do the same. */
+		/* Userspace cannot always have continuous card0...N due to
+		 * dynamic unloading or removal of cards */
 		if (stat(path, &st) != 0)
-			break;
+			continue;
 
 		if (save) {
 			/* Save and toggle */
@@ -136,7 +139,13 @@ static unsigned tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
 		 * - __drm_open_driver() can open another device, aka the
 		 * failure may be irrelevant.
 		 */
-		chmod(path, st.st_mode);
+		ret = chmod(path, st.st_mode);
+		if (ret)
+			return ret;
+
+		/* Break the loop after the frist card */
+		if (save)
+			return i;
 	}
 	return i;
 }
@@ -161,7 +170,7 @@ igt_main
 
 	igt_subtest_group {
 		uint8_t saved_perm[255];
-		unsigned num;
+		int num;
 
 		/* Upon dropping root we end up as random user, which
 		 * a) is not in the video group, and
-- 
2.25.1


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

end of thread, other threads:[~2024-09-18  3:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17  7:21 [PATCH v3] tests/core_setmaster: Handle the test even if cards are non-continuous Bommu Krishnaiah
2024-09-17  8:48 ` ✓ Fi.CI.BAT: success for tests/core_setmaster: Handle the test even if cards are non-continuous (rev5) Patchwork
2024-09-17  9:08 ` ✓ CI.xeBAT: " Patchwork
2024-09-17 11:10 ` ✓ CI.xeFULL: " Patchwork
2024-09-18  3:54 ` ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox