All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices
@ 2020-04-29 15:49 Arkadiusz Hiler
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters Arkadiusz Hiler
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Arkadiusz Hiler @ 2020-04-29 15:49 UTC (permalink / raw)
  To: igt-dev

By default the first two devices that are matching provided chipset requirements
are used (ANY + VGEM). This is sensitive to enumeration order, but as long as
there are only two devices it's fine - PRIME will get tested both directions.

# kms_prime
IGT-Version: 1.25-g0b58fd8c (x86_64) (Linux: 5.7.0-rc2-CI-CI_DRM_8370+ x86_64)
Starting subtest: basic-crc
Starting dynamic subtest: first-to-second
Test requirement not met in function igt_require_pipe_crc, file ../lib/igt_debugfs.c:522:
Test requirement: fstatat(dir, "crtc-0/crc/control", &stat, 0) == 0
CRCs not supported on this platform
Last errno: 2, No such file or directory
Dynamic subtest first-to-second: SKIP (0,000s)
Starting dynamic subtest: second-to-first
Dynamic subtest second-to-first: SUCCESS (1,779s)
Subtest basic-crc: SUCCESS (2,024s)

In case there are more than two devices you can specify which ones should be
used or force ordering, e.g.:

# lsgpu
sys:/sys/devices/pci0000:00/0000:00:02.0
    subsystem       : pci
    drm card        : /dev/dri/card0
    drm render      : /dev/dri/renderD128
    vendor          : 8086
    device          : 9A49

sys:/sys/devices/platform/vgem
    subsystem       : platform
    drm card        : /dev/dri/card1
    drm render      : /dev/dri/renderD129

# kms_prime --device "sys:/sys/devices/platform/vgem;pci:vendor=Intel"
IGT-Version: 1.25-g0b58fd8c (x86_64) (Linux: 5.7.0-rc2-CI-CI_DRM_8370+ x86_64)
Starting subtest: basic-crc
Looking for devices to open using filter 0: sys:/sys/devices/platform/vgem
Filter matched /dev/dri/card1 | /dev/dri/renderD129
Looking for devices to open using filter 1: pci:vendor=Intel
Filter matched /dev/dri/card0 | /dev/dri/renderD128
Starting dynamic subtest: first-to-second
Dynamic subtest first-to-second: SUCCESS (1,978s)
Starting dynamic subtest: second-to-first
Test requirement not met in function igt_require_pipe_crc, file ../lib/igt_debugfs.c:522:
Test requirement: fstatat(dir, "crtc-0/crc/control", &stat, 0) == 0
CRCs not supported on this platform
Last errno: 2, No such file or directory
Dynamic subtest second-to-first: SKIP (0,000s)
Subtest basic-crc: SUCCESS (2,944s)

You can also use the IGT_DEVICE environment variable or Common::Device in .igtrc.

Arkadiusz Hiler (2):
  lib: Support multiple filters
  lib/drmtest: Introduce __drm_open_driver_another

 lib/drmtest.c          | 165 +++++++++++++++++++++++++++++++++++------
 lib/drmtest.h          |   1 +
 lib/igt_core.c         |  16 ++--
 lib/igt_device_scan.c  |  87 ++++++++++++++++------
 lib/igt_device_scan.h  |   8 +-
 tests/core_hotunplug.c |   3 +-
 tests/kms_prime.c      | 107 ++++++++++++++++----------
 7 files changed, 288 insertions(+), 99 deletions(-)

-- 
2.25.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters
  2020-04-29 15:49 [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices Arkadiusz Hiler
@ 2020-04-29 15:49 ` Arkadiusz Hiler
  2020-04-30  8:42   ` Petri Latvala
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another Arkadiusz Hiler
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Arkadiusz Hiler @ 2020-04-29 15:49 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

This patch brings back support for multiple filters that was in the
original series by Zbyszek.

We can now take multiple, semicolon separated filters. Right now the
tests are using only the first filter.

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 lib/drmtest.c          |  8 ++--
 lib/igt_core.c         | 16 ++++----
 lib/igt_device_scan.c  | 87 +++++++++++++++++++++++++++++++-----------
 lib/igt_device_scan.h  |  8 ++--
 tests/core_hotunplug.c |  3 +-
 5 files changed, 83 insertions(+), 39 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 1fc39925..7b2fd337 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -324,8 +324,8 @@ static bool __get_the_first_card(struct igt_device_card *card)
 {
 	const char *filter;
 
-	if (igt_device_is_filter_set()) {
-		filter = igt_device_filter_get();
+	if (igt_device_filter_count() > 0) {
+		filter = igt_device_filter_get(0);
 		igt_info("Looking for devices to open using filter: %s\n", filter);
 
 		if (igt_device_card_match(filter, card)) {
@@ -354,7 +354,7 @@ static bool __get_the_first_card(struct igt_device_card *card)
  */
 int __drm_open_driver(int chipset)
 {
-	if (igt_device_is_filter_set()) {
+	if (igt_device_filter_count() > 0) {
 		bool found;
 		struct igt_device_card card;
 
@@ -371,7 +371,7 @@ int __drm_open_driver(int chipset)
 
 int __drm_open_driver_render(int chipset)
 {
-	if (igt_device_is_filter_set()) {
+	if (igt_device_filter_count() > 0) {
 		bool found;
 		struct igt_device_card card;
 
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3f7b9f68..44705d10 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -249,7 +249,7 @@
  *	FrameDumpPath=/tmp # The path to dump frames that fail comparison checks
  *
  *	&num; Device selection filter
- *	Device=pci:vendor=8086,card=0;vgem:
+ *	Device=pci:vendor=8086,card=0;sys:/sys/devices/platform/vgem
  *
  *	&num; The following section is used for configuring the Device Under Test.
  *	&num; It is not mandatory and allows overriding default values.
@@ -685,7 +685,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 		   "  --skip-crc-compare\n"
 		   "  --help-description\n"
 		   "  --describe\n"
-		   "  --device filter\n"
+		   "  --device filters\n"
 		   "  --version\n"
 		   "  --help|-h\n");
 	if (help_str)
@@ -778,7 +778,7 @@ static void common_init_config(void)
 		igt_set_autoresume_delay(ret);
 
 	/* Adding filters, order .igtrc, IGT_DEVICE, --device filter */
-	if (igt_device_is_filter_set())
+	if (igt_device_filter_count() > 0)
 		igt_debug("Notice: using --device filters:\n");
 	else {
 		if (igt_rc_device) {
@@ -793,14 +793,16 @@ static void common_init_config(void)
 					  "Common::Device:\n");
 		}
 		if (igt_rc_device) {
-			igt_device_filter_set(igt_rc_device);
+			igt_device_filter_add(igt_rc_device);
 			free(igt_rc_device);
 			igt_rc_device = NULL;
 		}
 	}
 
-	if (igt_device_is_filter_set())
-		igt_debug("[%s]\n", igt_device_filter_get());
+	if (igt_device_filter_count() > 0) {
+		for (int i = 0; i < igt_device_filter_count(); i++)
+			igt_debug("[%s]\n", igt_device_filter_get(i));
+	}
 }
 
 static void common_init_env(void)
@@ -999,7 +1001,7 @@ static int common_init(int *argc, char **argv,
 				free(igt_rc_device);
 				igt_rc_device = NULL;
 			}
-			igt_device_filter_set(optarg);
+			igt_device_filter_add(optarg);
 			break;
 		case OPT_VERSION:
 			print_version();
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 30a9704a..601d6fb0 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -1014,16 +1014,21 @@ void igt_device_print_filter_types(void)
 	}
 }
 
-static char *device_filter;
+struct device_filter {
+	char filter[NAME_MAX];
+	struct igt_list_head link;
+};
+
+static IGT_LIST_HEAD(device_filters);
 
 /**
- * igt_device_is_filter_set
+ * igt_device_filter_count
  *
- * Returns whether we have a filter set.
+ * Returns number of filters collected in the filter list.
  */
-bool igt_device_is_filter_set(void)
+int igt_device_filter_count(void)
 {
-	return device_filter != NULL;
+	return igt_list_length(&device_filters);
 }
 
 /* Check does filter is valid. It checks:
@@ -1054,43 +1059,79 @@ static bool is_filter_valid(const char *fstr)
 }
 
 /**
- * igt_device_filter_set
- * @filter: filter that should be set globally
+ * igt_device_filter_add
+ * @filters: filter(s) to be stored in filter array
+ *
+ * Function allows passing single or more filters within one string. This is
+ * for CI when it can extract filter from environment variable (and it must
+ * be single string). So if @filter contains semicolon ';' it treats
+ * each part as separate filter and adds to the filter array.
+ *
+ * Returns number of filters added to filter array. Can be greater than
+ * 1 if @filters contains more than one filter separated by semicolon.
  */
-void igt_device_filter_set(const char *filter)
+int igt_device_filter_add(const char *filters)
 {
-	if (!is_filter_valid(filter)) {
-		igt_warn("Invalid filter: %s\n", filter);
-		return;
+	char *dup, *dup_orig, *filter;
+	int count = 0;
+
+	dup = strdup(filters);
+	dup_orig = dup;
+
+	while ((filter = strsep(&dup, ";"))) {
+		bool is_valid = is_filter_valid(filter);
+		igt_warn_on(!is_valid);
+		if (is_valid) {
+			struct device_filter *df = malloc(sizeof(*df));
+			strncpy(df->filter, filter, sizeof(df->filter)-1);
+			igt_list_add_tail(&df->link, &device_filters);
+			count++;
+		}
 	}
 
-	if (device_filter != NULL)
-		free(device_filter);
+	free(dup_orig);
 
-	device_filter = strdup(filter);
+	return count;
 }
 
 /**
- * igt_device_filter_free
+ * igt_device_filter_free_all
  *
- * Free the filter that we store internally, effectively unsetting it.
+ * Free all filters within array.
  */
-void igt_device_filter_free(void)
+void igt_device_filter_free_all(void)
 {
-	if (device_filter != NULL)
-		free(device_filter);
+	struct device_filter *filter, *tmp;
 
-	device_filter = NULL;
+	igt_list_for_each_entry_safe(filter, tmp, &device_filters, link) {
+		igt_list_del(&filter->link);
+		free(filter);
+	}
 }
 
 /**
  * igt_device_filter_get
+ * @num: Number of filter from filter array
  *
- * Returns filter string or NULL if not set
+ * Returns filter string or NULL if @num is out of range of filter array.
  */
-const char *igt_device_filter_get(void)
+const char *igt_device_filter_get(int num)
 {
-	return device_filter;
+	struct device_filter *filter;
+	int i = 0;
+
+	if (num < 0)
+		return NULL;
+
+
+	igt_list_for_each_entry(filter, &device_filters, link) {
+		if (i == num)
+			return filter->filter;
+		i++;
+	}
+
+
+	return NULL;
 }
 
 static bool igt_device_filter_apply(const char *fstr)
diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
index 44c99dec..24eafe62 100644
--- a/lib/igt_device_scan.h
+++ b/lib/igt_device_scan.h
@@ -50,10 +50,10 @@ void igt_device_print_filter_types(void);
  * IGT can store/retrieve filters passed by user using '--device' args.
  */
 
-bool igt_device_is_filter_set(void);
-void igt_device_filter_set(const char *filter);
-void igt_device_filter_free(void);
-const char *igt_device_filter_get(void);
+int igt_device_filter_count(void);
+int igt_device_filter_add(const char *filter);
+void igt_device_filter_free_all(void);
+const char *igt_device_filter_get(int num);
 
 /* Use filter to match the device and fill card structure */
 bool igt_device_card_match(const char *filter, struct igt_device_card *card);
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index f9cfc8c3..ded53fd5 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -167,7 +167,8 @@ static void set_filter_from_device(int fd)
 	strncat(path, "/device", PATH_MAX - strlen(path));
 	igt_assert(realpath(path, dst));
 
-	igt_device_filter_set(filter);
+	igt_device_filter_free_all();
+	igt_device_filter_add(filter);
 }
 
 /* Subtests */
-- 
2.25.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another
  2020-04-29 15:49 [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices Arkadiusz Hiler
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters Arkadiusz Hiler
@ 2020-04-29 15:49 ` Arkadiusz Hiler
  2020-04-30  9:01   ` Petri Latvala
  2020-04-29 16:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Test modeseting with imported prime buffer between any two devices Patchwork
  2020-04-29 22:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  3 siblings, 1 reply; 8+ messages in thread
From: Arkadiusz Hiler @ 2020-04-29 15:49 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

__drm_open_driver_another(int idx, ...) is a counterpart to
__drm_open_driver(..) with the following changes:

If device filters are provided the idx-th filter is used and the first
matching device is selected.

Consecutive calls to it, with increasing idx (starting from zero) are
guaranteed to return fd of a different /dev/dri/ node than the previous
calls or -1.

Counterparts to other existing drm_open_*() should be introduced in
similar fashion as the need arises.

kms_prime test is converted to use this new call and dumb buffers
directly.

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 lib/drmtest.c     | 163 +++++++++++++++++++++++++++++++++++++++-------
 lib/drmtest.h     |   1 +
 tests/kms_prime.c | 107 ++++++++++++++++++------------
 3 files changed, 208 insertions(+), 63 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 7b2fd337..538fcf65 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -246,7 +246,51 @@ err:
 	return -1;
 }
 
-static int __search_and_open(const char *base, int offset, unsigned int chipset)
+static struct {
+	int fd;
+	struct stat stat;
+}_opened_fds[64];
+
+static int _opened_fds_count;
+
+static void _set_opened_fd(int idx, int fd)
+{
+	assert(idx < ARRAY_SIZE(_opened_fds));
+	assert(idx <= _opened_fds_count);
+
+	_opened_fds[idx].fd = fd;
+
+	assert(fstat(fd, &_opened_fds[idx].stat) == 0);
+
+	_opened_fds_count = idx+1;
+}
+
+static bool _is_already_opened(const char *path, int as_idx)
+{
+	struct stat new;
+
+	assert(as_idx < ARRAY_SIZE(_opened_fds));
+	assert(as_idx <= _opened_fds_count);
+
+	/*
+	 * we cannot even stat the device, so it's of no use - let's claim it's
+	 * already opened
+	 */
+	if (stat(path, &new) != 0)
+		return true;
+
+	for (int i = 0; i < as_idx; ++i) {
+		/* did we cross filesystem boundary? */
+		assert(_opened_fds[i].stat.st_dev == new.st_dev);
+
+		if (_opened_fds[i].stat.st_ino == new.st_ino)
+			return true;
+	}
+
+	return false;
+}
+
+static int __search_and_open(const char *base, int offset, unsigned int chipset, int as_idx)
 {
 	const char *forced;
 
@@ -259,6 +303,10 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset)
 		int fd;
 
 		sprintf(name, "%s%u", base, i + offset);
+
+		if (_is_already_opened(name, as_idx))
+			continue;
+
 		fd = open_device(name, chipset);
 		if (fd != -1)
 			return fd;
@@ -283,17 +331,17 @@ static void __try_modprobe(unsigned int chipset)
 	pthread_mutex_unlock(&mutex);
 }
 
-static int __open_driver(const char *base, int offset, unsigned int chipset)
+static int __open_driver(const char *base, int offset, unsigned int chipset, int as_idx)
 {
 	int fd;
 
-	fd = __search_and_open(base, offset, chipset);
+	fd = __search_and_open(base, offset, chipset, as_idx);
 	if (fd != -1)
 		return fd;
 
 	__try_modprobe(chipset);
 
-	return __search_and_open(base, offset, chipset);
+	return __search_and_open(base, offset, chipset, as_idx);
 }
 
 static int __open_driver_exact(const char *name, unsigned int chipset)
@@ -320,13 +368,13 @@ static int __open_driver_exact(const char *name, unsigned int chipset)
  * True if card according to the added filter was found,
  * false othwerwise.
  */
-static bool __get_the_first_card(struct igt_device_card *card)
+static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)
 {
 	const char *filter;
 
-	if (igt_device_filter_count() > 0) {
-		filter = igt_device_filter_get(0);
-		igt_info("Looking for devices to open using filter: %s\n", filter);
+	if (igt_device_filter_count() > idx) {
+		filter = igt_device_filter_get(idx);
+		igt_info("Looking for devices to open using filter %d: %s\n", idx, filter);
 
 		if (igt_device_card_match(filter, card)) {
 			igt_info("Filter matched %s | %s\n", card->card, card->render);
@@ -339,6 +387,87 @@ static bool __get_the_first_card(struct igt_device_card *card)
 	return false;
 }
 
+/**
+ * __drm_open_driver_another:
+ * @idx: index of the device you are opening
+ * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
+ *
+ * This function is intended to be used instead of drm_open_driver() for tests
+ * that are opening multiple /dev/dri/card* nodes, usually for the purpose of
+ * multi-GPU testing.
+ *
+ * This function opens device in the following order:
+ *
+ * 1. when --device arguments are present:
+ *   * device scanning is executed,
+ *   * idx-th filter (starting with 0, filters are semicolon separated) is used
+ *   * if there is no idx-th filter, goto 2
+ *   * first device maching the filter is selected
+ *   * if it's already opened (for indexes = 0..idx-1) we fail with -1
+ *   * otherwise open the device and return the fd
+ *
+ * 2. compatibility mode - open the first DRM device we can find that is not
+ *    already opened for indexes 0..idx-1, searching up to 16 device nodes
+ *
+ * The test is reponsible to test the interaction between devices in both
+ * directions if applicable.
+ *
+ * Example:
+ *
+ * |[<!-- language="c" -->
+ * igt_subtest_with_dynamic("basic") {
+ * 	int first_fd = -1;
+ * 	int second_fd = -1;
+ *
+ * 	first_fd = __drm_open_driver_another(0, DRIVER_ANY);
+ * 	igt_require(first_fd >= 0);
+ *
+ * 	second_fd = __drm_open_driver_another(1, DRIVER_ANY);
+ * 	igt_require(second_fd >= 0);
+ *
+ * 	if (can_do_foo(first_fd, second_fd))
+ * 		igt_dynamic("first-to-second")
+ * 			test_basic_from_to(first_fd, second_fd);
+ *
+ * 	if (can_do_foo(second_fd, first_fd))
+ * 		igt_dynamic("second-to-first")
+ * 			test_basic_from_to(second_fd, first_fd);
+ *
+ * 	close(first_fd);
+ * 	close(second_fd);
+ * }
+ * ]|
+ *
+ * Returns:
+ * An open DRM fd or -1 on error
+ */
+int __drm_open_driver_another(int idx, int chipset)
+{
+	int fd = -1;
+	if (igt_device_filter_count() > idx) {
+		bool found;
+		struct igt_device_card card;
+
+		found = __get_card_for_nth_filter(idx, &card);
+
+		if (!found || !strlen(card.card))
+			igt_warn("No card matches the filter!\n");
+		else if (_is_already_opened(card.card, idx))
+			igt_warn("card maching filter %d is already opened\n", idx);
+		else
+			fd = __open_driver_exact(card.card, chipset);
+
+	} else {
+		/* no filter for device idx, let's open whatever is available */
+		fd = __open_driver("/dev/dri/card", 0, chipset, idx);
+	}
+
+	if (fd >= 0)
+		_set_opened_fd(idx, fd);
+
+	return fd;
+}
+
 /**
  * __drm_open_driver:
  * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
@@ -354,19 +483,7 @@ static bool __get_the_first_card(struct igt_device_card *card)
  */
 int __drm_open_driver(int chipset)
 {
-	if (igt_device_filter_count() > 0) {
-		bool found;
-		struct igt_device_card card;
-
-		found = __get_the_first_card(&card);
-
-		if (!found || !strlen(card.card))
-			return -1;
-
-		return __open_driver_exact(card.card, chipset);
-	}
-
-	return __open_driver("/dev/dri/card", 0, chipset);
+	return __drm_open_driver_another(0, chipset);
 }
 
 int __drm_open_driver_render(int chipset)
@@ -375,7 +492,7 @@ int __drm_open_driver_render(int chipset)
 		bool found;
 		struct igt_device_card card;
 
-		found = __get_the_first_card(&card);
+		found = __get_card_for_nth_filter(0, &card);
 
 		if (!found || !strlen(card.render))
 			return -1;
@@ -383,7 +500,7 @@ int __drm_open_driver_render(int chipset)
 		return __open_driver_exact(card.render, chipset);
 	}
 
-	return __open_driver("/dev/dri/renderD", 128, chipset);
+	return __open_driver("/dev/dri/renderD", 128, chipset, 0);
 }
 
 static int at_exit_drm_fd = -1;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 632c616b..d5f0fc25 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -90,6 +90,7 @@ void __set_forced_driver(const char *name);
 int drm_open_driver(int chipset);
 int drm_open_driver_master(int chipset);
 int drm_open_driver_render(int chipset);
+int __drm_open_driver_another(int idx, int chipset);
 int __drm_open_driver(int chipset);
 int __drm_open_driver_render(int chipset);
 
diff --git a/tests/kms_prime.c b/tests/kms_prime.c
index 3241c514..8cb2ca2a 100644
--- a/tests/kms_prime.c
+++ b/tests/kms_prime.c
@@ -22,12 +22,19 @@
  */
 
 #include "igt.h"
-#include "igt_vgem.h"
+#include "igt_device.h"
 
 #include <sys/ioctl.h>
 #include <sys/poll.h>
 #include <time.h>
 
+struct dumb_bo {
+	uint32_t handle;
+	uint32_t width, height;
+	uint32_t bpp, pitch;
+	uint64_t size;
+};
+
 struct crc_info {
 	igt_crc_t crc;
 	char *str;
@@ -67,23 +74,24 @@ static bool has_prime_export(int fd)
 }
 
 static igt_output_t *setup_display(int importer_fd, igt_display_t *display,
-				   enum pipe pipe)
+				   enum pipe *pipe)
 {
 	igt_output_t *output;
+	bool found = false;
 
-	igt_display_require(display, importer_fd);
-	igt_skip_on(pipe >= display->n_pipes);
-	output = igt_get_single_output_for_pipe(display, pipe);
+	for_each_pipe_with_valid_output(display, *pipe, output) {
+		found = true;
+		break;
+	}
 
-	igt_require_f(output, "No connector found for pipe %s\n",
-		      kmstest_pipe_name(pipe));
+	igt_require_f(found, "No valid connector/pipe found\n");
 
 	igt_display_reset(display);
-	igt_output_set_pipe(output, pipe);
+	igt_output_set_pipe(output, *pipe);
 	return output;
 }
 
-static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
+static void prepare_scratch(int exporter_fd, struct dumb_bo *scratch,
 			    drmModeModeInfo *mode, uint32_t color)
 {
 	uint32_t *ptr;
@@ -91,16 +99,27 @@ static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
 	scratch->width = mode->hdisplay;
 	scratch->height = mode->vdisplay;
 	scratch->bpp = 32;
-	vgem_create(exporter_fd, scratch);
 
-	ptr = vgem_mmap(exporter_fd, scratch, PROT_WRITE);
+	scratch->handle = kmstest_dumb_create(exporter_fd,
+			scratch->width,
+			scratch->height,
+			scratch->bpp,
+			&scratch->pitch,
+			&scratch->size);
+
+
+	ptr = kmstest_dumb_map_buffer(exporter_fd,
+				      scratch->handle,
+				      scratch->size,
+				      PROT_WRITE);
+
 	for (size_t idx = 0; idx < scratch->size / sizeof(*ptr); ++idx)
 		ptr[idx] = color;
 
 	munmap(ptr, scratch->size);
 }
 
-static void prepare_fb(int importer_fd, struct vgem_bo *scratch, struct igt_fb *fb)
+static void prepare_fb(int importer_fd, struct dumb_bo *scratch, struct igt_fb *fb)
 {
 	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
 	enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
@@ -126,6 +145,7 @@ static void import_fb(int importer_fd, struct igt_fb *fb,
 			    DRM_FORMAT_XRGB8888,
 			    handles, pitches, offsets,
 			    &fb->fb_id, 0);
+
 	igt_assert(ret == 0);
 }
 
@@ -162,19 +182,19 @@ static void test_crc(int exporter_fd, int importer_fd)
 	igt_display_t display;
 	igt_output_t *output;
 	igt_pipe_crc_t *pipe_crc;
-	enum pipe pipe = PIPE_A;
+	enum pipe pipe;
 	struct igt_fb fb;
 	int dmabuf_fd;
-	struct vgem_bo scratch = {}; /* despite the name, it suits for any
-				      * gem-compatible device
-				      * TODO: rename
-				      */
+	struct dumb_bo scratch = {};
+	bool crc_equal;
 	int i, j;
 	drmModeModeInfo *mode;
 
-	bool crc_equal = false;
+	igt_device_set_master(importer_fd);
+	igt_require_pipe_crc(importer_fd);
+	igt_display_require(&display, importer_fd);
 
-	output = setup_display(importer_fd, &display, pipe);
+	output = setup_display(importer_fd, &display, &pipe);
 
 	mode = igt_output_get_mode(output);
 	pipe_crc = igt_pipe_crc_new(importer_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
@@ -188,6 +208,7 @@ static void test_crc(int exporter_fd, int importer_fd)
 		import_fb(importer_fd, &fb, dmabuf_fd, scratch.pitch);
 		close(dmabuf_fd);
 
+
 		colors[i].prime_crc.name = "prime";
 		collect_crc_for_fb(importer_fd, &fb, &display, output,
 				   pipe_crc, colors[i].color, &colors[i].prime_crc);
@@ -228,29 +249,35 @@ static void test_crc(int exporter_fd, int importer_fd)
 	igt_display_fini(&display);
 }
 
-static void run_test_crc(int export_chipset, int import_chipset)
-{
-	int importer_fd = -1;
-	int exporter_fd = -1;
-
-	exporter_fd = drm_open_driver(export_chipset);
-	importer_fd = drm_open_driver_master(import_chipset);
-
-	igt_require(has_prime_export(exporter_fd));
-	igt_require(has_prime_import(importer_fd));
-	igt_require_pipe_crc(importer_fd);
-
-	test_crc(exporter_fd, importer_fd);
-	close(importer_fd);
-	close(exporter_fd);
-}
-
 igt_main
 {
-	igt_fixture {
+	igt_fixture
 		kmstest_set_vt_graphics_mode();
+
+	igt_describe("Make a dumb color buffer, export to another device and"
+		     " compare the CRCs with a buffer native to that device");
+	igt_subtest_with_dynamic("basic-crc") {
+		int first_fd = -1;
+		int second_fd = -1;
+
+		/* ANY = anything that is not VGEM */
+		first_fd = __drm_open_driver_another(0, DRIVER_ANY | DRIVER_VGEM);
+		igt_require(first_fd >= 0);
+
+		second_fd = __drm_open_driver_another(1, DRIVER_ANY | DRIVER_VGEM);
+		igt_require(second_fd >= 0);
+
+		if (has_prime_export(first_fd) &&
+		    has_prime_import(second_fd))
+			igt_dynamic("first-to-second")
+				test_crc(first_fd, second_fd);
+
+		if (has_prime_import(first_fd) &&
+		    has_prime_export(second_fd))
+			igt_dynamic("second-to-first")
+				test_crc(second_fd, first_fd);
+
+		close(first_fd);
+		close(second_fd);
 	}
-	igt_describe("Make a dumb buffer inside vgem, fill it, export to another device and compare the CRC");
-	igt_subtest("basic-crc")
-		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
 }
-- 
2.25.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.BAT: success for Test modeseting with imported prime buffer between any two devices
  2020-04-29 15:49 [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices Arkadiusz Hiler
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters Arkadiusz Hiler
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another Arkadiusz Hiler
@ 2020-04-29 16:32 ` Patchwork
  2020-04-29 22:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  3 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2020-04-29 16:32 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

== Series Details ==

Series: Test modeseting with imported prime buffer between any two devices
URL   : https://patchwork.freedesktop.org/series/76734/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8392 -> IGTPW_4517
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

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

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

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

### IGT changes ###

#### Possible fixes ####

  * igt@i915_selftest@live@workarounds:
    - fi-bwr-2160:        [INCOMPLETE][1] ([i915#489]) -> [PASS][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/fi-bwr-2160/igt@i915_selftest@live@workarounds.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/fi-bwr-2160/igt@i915_selftest@live@workarounds.html

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

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


Participating hosts (47 -> 41)
------------------------------

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


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

  * CI: CI-20190529 -> None
  * IGT: IGT_5614 -> IGTPW_4517

  CI-20190529: 20190529
  CI_DRM_8392: c5ceaac881b4dc4eca6473abeb27342663c898d3 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4517: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/index.html
  IGT_5614: d095827add11d4e8158b87683971ee659749d9a4 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* [igt-dev] ✗ Fi.CI.IGT: failure for Test modeseting with imported prime buffer between any two devices
  2020-04-29 15:49 [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices Arkadiusz Hiler
                   ` (2 preceding siblings ...)
  2020-04-29 16:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Test modeseting with imported prime buffer between any two devices Patchwork
@ 2020-04-29 22:31 ` Patchwork
  3 siblings, 0 replies; 8+ messages in thread
From: Patchwork @ 2020-04-29 22:31 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

== Series Details ==

Series: Test modeseting with imported prime buffer between any two devices
URL   : https://patchwork.freedesktop.org/series/76734/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8392_full -> IGTPW_4517_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with IGTPW_4517_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_4517_full, 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/IGTPW_4517/index.html

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

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

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@gt_pm:
    - shard-apl:          [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl8/igt@i915_selftest@live@gt_pm.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl6/igt@i915_selftest@live@gt_pm.html

  * {igt@kms_prime@basic-crc@first-to-second} (NEW):
    - shard-iclb:         NOTRUN -> [SKIP][3]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb3/igt@kms_prime@basic-crc@first-to-second.html
    - shard-tglb:         NOTRUN -> [SKIP][4]
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-tglb7/igt@kms_prime@basic-crc@first-to-second.html

  
New tests
---------

  New tests have been introduced between CI_DRM_8392_full and IGTPW_4517_full:

### New IGT tests (2) ###

  * igt@kms_prime@basic-crc@first-to-second:
    - Statuses : 7 skip(s)
    - Exec time: [0.0, 0.00] s

  * igt@kms_prime@basic-crc@second-to-first:
    - Statuses : 7 pass(s)
    - Exec time: [0.71, 1.32] s

  

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

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

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s3:
    - shard-apl:          [PASS][5] -> [DMESG-WARN][6] ([i915#180])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl2/igt@gem_exec_suspend@basic-s3.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl2/igt@gem_exec_suspend@basic-s3.html

  * igt@i915_pm_rps@min-max-config-loaded:
    - shard-iclb:         [PASS][7] -> [FAIL][8] ([i915#370])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb4/igt@i915_pm_rps@min-max-config-loaded.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb2/igt@i915_pm_rps@min-max-config-loaded.html

  * igt@kms_color@pipe-a-legacy-gamma:
    - shard-glk:          [PASS][9] -> [FAIL][10] ([fdo#108145] / [i915#71])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-glk4/igt@kms_color@pipe-a-legacy-gamma.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-glk5/igt@kms_color@pipe-a-legacy-gamma.html

  * igt@kms_cursor_crc@pipe-b-cursor-128x42-sliding:
    - shard-kbl:          [PASS][11] -> [FAIL][12] ([i915#54])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl2/igt@kms_cursor_crc@pipe-b-cursor-128x42-sliding.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl1/igt@kms_cursor_crc@pipe-b-cursor-128x42-sliding.html
    - shard-apl:          [PASS][13] -> [FAIL][14] ([i915#54])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl4/igt@kms_cursor_crc@pipe-b-cursor-128x42-sliding.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl3/igt@kms_cursor_crc@pipe-b-cursor-128x42-sliding.html

  * igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic:
    - shard-glk:          [PASS][15] -> [FAIL][16] ([i915#72])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-glk5/igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-glk6/igt@kms_cursor_legacy@2x-long-flip-vs-cursor-atomic.html

  * igt@kms_cursor_legacy@pipe-b-torture-bo:
    - shard-iclb:         [PASS][17] -> [DMESG-WARN][18] ([i915#128])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb1/igt@kms_cursor_legacy@pipe-b-torture-bo.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb7/igt@kms_cursor_legacy@pipe-b-torture-bo.html

  * igt@kms_draw_crc@draw-method-rgb565-render-ytiled:
    - shard-glk:          [PASS][19] -> [FAIL][20] ([i915#52] / [i915#54]) +2 similar issues
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-glk6/igt@kms_draw_crc@draw-method-rgb565-render-ytiled.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-glk7/igt@kms_draw_crc@draw-method-rgb565-render-ytiled.html

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes:
    - shard-kbl:          [PASS][21] -> [DMESG-WARN][22] ([i915#180]) +1 similar issue
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl7/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl4/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes.html

  * igt@kms_plane_cursor@pipe-a-viewport-size-128:
    - shard-apl:          [PASS][23] -> [FAIL][24] ([i915#1559] / [i915#95])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl1/igt@kms_plane_cursor@pipe-a-viewport-size-128.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl6/igt@kms_plane_cursor@pipe-a-viewport-size-128.html
    - shard-kbl:          [PASS][25] -> [FAIL][26] ([i915#1559] / [i915#93] / [i915#95])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl2/igt@kms_plane_cursor@pipe-a-viewport-size-128.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl7/igt@kms_plane_cursor@pipe-a-viewport-size-128.html

  * igt@kms_psr@psr2_cursor_plane_move:
    - shard-iclb:         [PASS][27] -> [SKIP][28] ([fdo#109441]) +1 similar issue
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb2/igt@kms_psr@psr2_cursor_plane_move.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb8/igt@kms_psr@psr2_cursor_plane_move.html

  * igt@kms_setmode@basic:
    - shard-kbl:          [PASS][29] -> [FAIL][30] ([i915#31])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl1/igt@kms_setmode@basic.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl7/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-c-ts-continuation-suspend:
    - shard-glk:          [PASS][31] -> [INCOMPLETE][32] ([i915#58] / [k.org#198133])
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-glk7/igt@kms_vblank@pipe-c-ts-continuation-suspend.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-glk2/igt@kms_vblank@pipe-c-ts-continuation-suspend.html
    - shard-hsw:          [PASS][33] -> [INCOMPLETE][34] ([i915#61])
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-hsw1/igt@kms_vblank@pipe-c-ts-continuation-suspend.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-hsw4/igt@kms_vblank@pipe-c-ts-continuation-suspend.html

  
#### Possible fixes ####

  * igt@gem_exec_params@invalid-bsd-ring:
    - shard-iclb:         [SKIP][35] ([fdo#109276]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb6/igt@gem_exec_params@invalid-bsd-ring.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb1/igt@gem_exec_params@invalid-bsd-ring.html

  * igt@gen9_exec_parse@allowed-single:
    - shard-kbl:          [DMESG-WARN][37] ([i915#1436] / [i915#716]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl3/igt@gen9_exec_parse@allowed-single.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl4/igt@gen9_exec_parse@allowed-single.html

  * igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen:
    - shard-kbl:          [FAIL][39] ([i915#54] / [i915#93] / [i915#95]) -> [PASS][40] +2 similar issues
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen.html

  * igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen:
    - shard-apl:          [FAIL][41] ([i915#54] / [i915#95]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl8/igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl7/igt@kms_cursor_crc@pipe-a-cursor-128x42-offscreen.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-kbl:          [DMESG-WARN][43] ([i915#165] / [i915#180]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl7/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl1/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic:
    - shard-kbl:          [FAIL][45] ([i915#1566] / [i915#93] / [i915#95]) -> [PASS][46]
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl3/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl4/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html

  * igt@kms_draw_crc@draw-method-rgb565-render-untiled:
    - shard-glk:          [FAIL][47] ([i915#52] / [i915#54]) -> [PASS][48] +2 similar issues
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-glk1/igt@kms_draw_crc@draw-method-rgb565-render-untiled.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-glk1/igt@kms_draw_crc@draw-method-rgb565-render-untiled.html

  * igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled:
    - shard-kbl:          [FAIL][49] ([i915#177] / [i915#52] / [i915#54] / [i915#93] / [i915#95]) -> [PASS][50] +1 similar issue
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl1/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl2/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
    - shard-apl:          [FAIL][51] ([i915#52] / [i915#54] / [i915#95]) -> [PASS][52] +1 similar issue
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl4/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl8/igt@kms_draw_crc@draw-method-xrgb8888-mmap-cpu-untiled.html

  * igt@kms_draw_crc@draw-method-xrgb8888-mmap-wc-untiled:
    - shard-kbl:          [FAIL][53] ([fdo#108145] / [i915#177] / [i915#52] / [i915#54] / [i915#93] / [i915#95]) -> [PASS][54]
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl7/igt@kms_draw_crc@draw-method-xrgb8888-mmap-wc-untiled.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl4/igt@kms_draw_crc@draw-method-xrgb8888-mmap-wc-untiled.html
    - shard-apl:          [FAIL][55] ([fdo#108145] / [i915#52] / [i915#54] / [i915#95]) -> [PASS][56]
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl6/igt@kms_draw_crc@draw-method-xrgb8888-mmap-wc-untiled.html
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl8/igt@kms_draw_crc@draw-method-xrgb8888-mmap-wc-untiled.html

  * {igt@kms_flip@flip-vs-suspend@c-dp1}:
    - shard-kbl:          [DMESG-WARN][57] ([i915#180]) -> [PASS][58] +4 similar issues
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl7/igt@kms_flip@flip-vs-suspend@c-dp1.html
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl7/igt@kms_flip@flip-vs-suspend@c-dp1.html

  * igt@kms_flip_tiling@flip-changes-tiling-y:
    - shard-kbl:          [FAIL][59] ([i915#699] / [i915#93] / [i915#95]) -> [PASS][60]
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl3/igt@kms_flip_tiling@flip-changes-tiling-y.html
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl3/igt@kms_flip_tiling@flip-changes-tiling-y.html

  * igt@kms_hdr@bpc-switch-suspend:
    - shard-apl:          [DMESG-WARN][61] ([i915#180]) -> [PASS][62] +2 similar issues
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl2/igt@kms_hdr@bpc-switch-suspend.html
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl8/igt@kms_hdr@bpc-switch-suspend.html

  * igt@kms_plane_cursor@pipe-a-viewport-size-64:
    - shard-kbl:          [FAIL][63] ([i915#1559] / [i915#93] / [i915#95]) -> [PASS][64]
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl1/igt@kms_plane_cursor@pipe-a-viewport-size-64.html
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl2/igt@kms_plane_cursor@pipe-a-viewport-size-64.html
    - shard-apl:          [FAIL][65] ([i915#1559] / [i915#95]) -> [PASS][66]
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl2/igt@kms_plane_cursor@pipe-a-viewport-size-64.html
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl1/igt@kms_plane_cursor@pipe-a-viewport-size-64.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [SKIP][67] ([fdo#109441]) -> [PASS][68] +1 similar issue
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb1/igt@kms_psr@psr2_primary_mmap_cpu.html
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@perf@polling:
    - shard-tglb:         [SKIP][69] ([i915#405]) -> [PASS][70]
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-tglb6/igt@perf@polling.html
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-tglb8/igt@perf@polling.html
    - shard-apl:          [SKIP][71] ([fdo#109271]) -> [PASS][72]
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl8/igt@perf@polling.html
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl7/igt@perf@polling.html
    - shard-kbl:          [SKIP][73] ([fdo#109271]) -> [PASS][74]
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl3/igt@perf@polling.html
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl7/igt@perf@polling.html
    - shard-hsw:          [SKIP][75] ([fdo#109271]) -> [PASS][76]
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-hsw4/igt@perf@polling.html
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-hsw2/igt@perf@polling.html
    - shard-iclb:         [SKIP][77] ([i915#405]) -> [PASS][78]
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-iclb6/igt@perf@polling.html
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-iclb1/igt@perf@polling.html

  
#### Warnings ####

  * igt@i915_pm_dc@dc6-psr:
    - shard-snb:          [INCOMPLETE][79] ([i915#82]) -> [SKIP][80] ([fdo#109271])
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-snb5/igt@i915_pm_dc@dc6-psr.html
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-snb4/igt@i915_pm_dc@dc6-psr.html

  * igt@kms_fbcon_fbt@fbc-suspend:
    - shard-apl:          [FAIL][81] ([i915#95]) -> [FAIL][82] ([i915#1525])
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl6/igt@kms_fbcon_fbt@fbc-suspend.html
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl2/igt@kms_fbcon_fbt@fbc-suspend.html
    - shard-kbl:          [FAIL][83] ([i915#93] / [i915#95]) -> [FAIL][84] ([i915#64])
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl7/igt@kms_fbcon_fbt@fbc-suspend.html
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl4/igt@kms_fbcon_fbt@fbc-suspend.html

  * igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb:
    - shard-apl:          [FAIL][85] ([fdo#108145] / [i915#265]) -> [FAIL][86] ([fdo#108145] / [i915#265] / [i915#95])
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-apl7/igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb.html
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-apl7/igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb.html
    - shard-kbl:          [FAIL][87] ([fdo#108145] / [i915#265]) -> [FAIL][88] ([fdo#108145] / [i915#265] / [i915#93] / [i915#95])
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8392/shard-kbl2/igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb.html
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/shard-kbl7/igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb.html

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

  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [i915#128]: https://gitlab.freedesktop.org/drm/intel/issues/128
  [i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
  [i915#1525]: https://gitlab.freedesktop.org/drm/intel/issues/1525
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#1559]: https://gitlab.freedesktop.org/drm/intel/issues/1559
  [i915#1566]: https://gitlab.freedesktop.org/drm/intel/issues/1566
  [i915#165]: https://gitlab.freedesktop.org/drm/intel/issues/165
  [i915#177]: https://gitlab.freedesktop.org/drm/intel/issues/177
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
  [i915#31]: https://gitlab.freedesktop.org/drm/intel/issues/31
  [i915#370]: https://gitlab.freedesktop.org/drm/intel/issues/370
  [i915#405]: https://gitlab.freedesktop.org/drm/intel/issues/405
  [i915#46]: https://gitlab.freedesktop.org/drm/intel/issues/46
  [i915#52]: https://gitlab.freedesktop.org/drm/intel/issues/52
  [i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
  [i915#58]: https://gitlab.freedesktop.org/drm/intel/issues/58
  [i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
  [i915#64]: https://gitlab.freedesktop.org/drm/intel/issues/64
  [i915#699]: https://gitlab.freedesktop.org/drm/intel/issues/699
  [i915#71]: https://gitlab.freedesktop.org/drm/intel/issues/71
  [i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
  [i915#72]: https://gitlab.freedesktop.org/drm/intel/issues/72
  [i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
  [i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (10 -> 8)
------------------------------

  Missing    (2): pig-skl-6260u pig-glk-j5005 


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

  * CI: CI-20190529 -> None
  * IGT: IGT_5614 -> IGTPW_4517
  * Piglit: piglit_4509 -> None

  CI-20190529: 20190529
  CI_DRM_8392: c5ceaac881b4dc4eca6473abeb27342663c898d3 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4517: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4517/index.html
  IGT_5614: d095827add11d4e8158b87683971ee659749d9a4 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

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

* Re: [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters Arkadiusz Hiler
@ 2020-04-30  8:42   ` Petri Latvala
  0 siblings, 0 replies; 8+ messages in thread
From: Petri Latvala @ 2020-04-30  8:42 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

On Wed, Apr 29, 2020 at 06:49:01PM +0300, Arkadiusz Hiler wrote:
> This patch brings back support for multiple filters that was in the
> original series by Zbyszek.
> 
> We can now take multiple, semicolon separated filters. Right now the
> tests are using only the first filter.
> 
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
>  lib/drmtest.c          |  8 ++--
>  lib/igt_core.c         | 16 ++++----
>  lib/igt_device_scan.c  | 87 +++++++++++++++++++++++++++++++-----------
>  lib/igt_device_scan.h  |  8 ++--
>  tests/core_hotunplug.c |  3 +-
>  5 files changed, 83 insertions(+), 39 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 1fc39925..7b2fd337 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -324,8 +324,8 @@ static bool __get_the_first_card(struct igt_device_card *card)
>  {
>  	const char *filter;
>  
> -	if (igt_device_is_filter_set()) {
> -		filter = igt_device_filter_get();
> +	if (igt_device_filter_count() > 0) {
> +		filter = igt_device_filter_get(0);
>  		igt_info("Looking for devices to open using filter: %s\n", filter);
>  
>  		if (igt_device_card_match(filter, card)) {
> @@ -354,7 +354,7 @@ static bool __get_the_first_card(struct igt_device_card *card)
>   */
>  int __drm_open_driver(int chipset)
>  {
> -	if (igt_device_is_filter_set()) {
> +	if (igt_device_filter_count() > 0) {
>  		bool found;
>  		struct igt_device_card card;
>  
> @@ -371,7 +371,7 @@ int __drm_open_driver(int chipset)
>  
>  int __drm_open_driver_render(int chipset)
>  {
> -	if (igt_device_is_filter_set()) {
> +	if (igt_device_filter_count() > 0) {
>  		bool found;
>  		struct igt_device_card card;
>  
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 3f7b9f68..44705d10 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -249,7 +249,7 @@
>   *	FrameDumpPath=/tmp # The path to dump frames that fail comparison checks
>   *
>   *	&num; Device selection filter
> - *	Device=pci:vendor=8086,card=0;vgem:
> + *	Device=pci:vendor=8086,card=0;sys:/sys/devices/platform/vgem
>   *
>   *	&num; The following section is used for configuring the Device Under Test.
>   *	&num; It is not mandatory and allows overriding default values.
> @@ -685,7 +685,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>  		   "  --skip-crc-compare\n"
>  		   "  --help-description\n"
>  		   "  --describe\n"
> -		   "  --device filter\n"
> +		   "  --device filters\n"
>  		   "  --version\n"
>  		   "  --help|-h\n");
>  	if (help_str)
> @@ -778,7 +778,7 @@ static void common_init_config(void)
>  		igt_set_autoresume_delay(ret);
>  
>  	/* Adding filters, order .igtrc, IGT_DEVICE, --device filter */
> -	if (igt_device_is_filter_set())
> +	if (igt_device_filter_count() > 0)
>  		igt_debug("Notice: using --device filters:\n");
>  	else {
>  		if (igt_rc_device) {
> @@ -793,14 +793,16 @@ static void common_init_config(void)
>  					  "Common::Device:\n");
>  		}
>  		if (igt_rc_device) {
> -			igt_device_filter_set(igt_rc_device);
> +			igt_device_filter_add(igt_rc_device);
>  			free(igt_rc_device);
>  			igt_rc_device = NULL;
>  		}
>  	}
>  
> -	if (igt_device_is_filter_set())
> -		igt_debug("[%s]\n", igt_device_filter_get());
> +	if (igt_device_filter_count() > 0) {
> +		for (int i = 0; i < igt_device_filter_count(); i++)
> +			igt_debug("[%s]\n", igt_device_filter_get(i));
> +	}

The if check can be dropped here, the for condition already takes care
of it.

Did we have unit tests for filters handling somewhere? I mean the list
stuff, not the application, latter is harder to unit test.


Reviewed-by: Petri Latvala <petri.latvala@intel.com>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another
  2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another Arkadiusz Hiler
@ 2020-04-30  9:01   ` Petri Latvala
  2020-04-30  9:29     ` Arkadiusz Hiler
  0 siblings, 1 reply; 8+ messages in thread
From: Petri Latvala @ 2020-04-30  9:01 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

On Wed, Apr 29, 2020 at 06:49:02PM +0300, Arkadiusz Hiler wrote:
> __drm_open_driver_another(int idx, ...) is a counterpart to
> __drm_open_driver(..) with the following changes:
> 
> If device filters are provided the idx-th filter is used and the first
> matching device is selected.
> 
> Consecutive calls to it, with increasing idx (starting from zero) are
> guaranteed to return fd of a different /dev/dri/ node than the previous
> calls or -1.
> 
> Counterparts to other existing drm_open_*() should be introduced in
> similar fashion as the need arises.
> 
> kms_prime test is converted to use this new call and dumb buffers
> directly.

If there's going to be new revisions of this series, can the kms_prime
changes be split to a separate patch?

> 
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Mika Kahola <mika.kahola@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> ---
>  lib/drmtest.c     | 163 +++++++++++++++++++++++++++++++++++++++-------
>  lib/drmtest.h     |   1 +
>  tests/kms_prime.c | 107 ++++++++++++++++++------------
>  3 files changed, 208 insertions(+), 63 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 7b2fd337..538fcf65 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -246,7 +246,51 @@ err:
>  	return -1;
>  }
>  
> -static int __search_and_open(const char *base, int offset, unsigned int chipset)
> +static struct {
> +	int fd;
> +	struct stat stat;
> +}_opened_fds[64];
> +
> +static int _opened_fds_count;
> +
> +static void _set_opened_fd(int idx, int fd)
> +{
> +	assert(idx < ARRAY_SIZE(_opened_fds));
> +	assert(idx <= _opened_fds_count);
> +
> +	_opened_fds[idx].fd = fd;
> +
> +	assert(fstat(fd, &_opened_fds[idx].stat) == 0);
> +
> +	_opened_fds_count = idx+1;
> +}
> +
> +static bool _is_already_opened(const char *path, int as_idx)
> +{
> +	struct stat new;
> +
> +	assert(as_idx < ARRAY_SIZE(_opened_fds));
> +	assert(as_idx <= _opened_fds_count);
> +
> +	/*
> +	 * we cannot even stat the device, so it's of no use - let's claim it's
> +	 * already opened
> +	 */
> +	if (stat(path, &new) != 0)
> +		return true;
> +
> +	for (int i = 0; i < as_idx; ++i) {
> +		/* did we cross filesystem boundary? */
> +		assert(_opened_fds[i].stat.st_dev == new.st_dev);
> +
> +		if (_opened_fds[i].stat.st_ino == new.st_ino)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
> +static int __search_and_open(const char *base, int offset, unsigned int chipset, int as_idx)
>  {
>  	const char *forced;
>  
> @@ -259,6 +303,10 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset)
>  		int fd;
>  
>  		sprintf(name, "%s%u", base, i + offset);
> +
> +		if (_is_already_opened(name, as_idx))
> +			continue;
> +
>  		fd = open_device(name, chipset);
>  		if (fd != -1)
>  			return fd;
> @@ -283,17 +331,17 @@ static void __try_modprobe(unsigned int chipset)
>  	pthread_mutex_unlock(&mutex);
>  }
>  
> -static int __open_driver(const char *base, int offset, unsigned int chipset)
> +static int __open_driver(const char *base, int offset, unsigned int chipset, int as_idx)
>  {
>  	int fd;
>  
> -	fd = __search_and_open(base, offset, chipset);
> +	fd = __search_and_open(base, offset, chipset, as_idx);
>  	if (fd != -1)
>  		return fd;
>  
>  	__try_modprobe(chipset);
>  
> -	return __search_and_open(base, offset, chipset);
> +	return __search_and_open(base, offset, chipset, as_idx);
>  }
>  
>  static int __open_driver_exact(const char *name, unsigned int chipset)
> @@ -320,13 +368,13 @@ static int __open_driver_exact(const char *name, unsigned int chipset)
>   * True if card according to the added filter was found,
>   * false othwerwise.
>   */
> -static bool __get_the_first_card(struct igt_device_card *card)
> +static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)
>  {
>  	const char *filter;
>  
> -	if (igt_device_filter_count() > 0) {
> -		filter = igt_device_filter_get(0);
> -		igt_info("Looking for devices to open using filter: %s\n", filter);
> +	if (igt_device_filter_count() > idx) {
> +		filter = igt_device_filter_get(idx);
> +		igt_info("Looking for devices to open using filter %d: %s\n", idx, filter);
>  
>  		if (igt_device_card_match(filter, card)) {
>  			igt_info("Filter matched %s | %s\n", card->card, card->render);
> @@ -339,6 +387,87 @@ static bool __get_the_first_card(struct igt_device_card *card)
>  	return false;
>  }
>  
> +/**
> + * __drm_open_driver_another:
> + * @idx: index of the device you are opening
> + * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> + *
> + * This function is intended to be used instead of drm_open_driver() for tests
> + * that are opening multiple /dev/dri/card* nodes, usually for the purpose of
> + * multi-GPU testing.
> + *
> + * This function opens device in the following order:
> + *
> + * 1. when --device arguments are present:
> + *   * device scanning is executed,
> + *   * idx-th filter (starting with 0, filters are semicolon separated) is used
> + *   * if there is no idx-th filter, goto 2
> + *   * first device maching the filter is selected
> + *   * if it's already opened (for indexes = 0..idx-1) we fail with -1
> + *   * otherwise open the device and return the fd
> + *
> + * 2. compatibility mode - open the first DRM device we can find that is not
> + *    already opened for indexes 0..idx-1, searching up to 16 device nodes
> + *
> + * The test is reponsible to test the interaction between devices in both
> + * directions if applicable.
> + *
> + * Example:
> + *
> + * |[<!-- language="c" -->
> + * igt_subtest_with_dynamic("basic") {
> + * 	int first_fd = -1;
> + * 	int second_fd = -1;
> + *
> + * 	first_fd = __drm_open_driver_another(0, DRIVER_ANY);
> + * 	igt_require(first_fd >= 0);
> + *
> + * 	second_fd = __drm_open_driver_another(1, DRIVER_ANY);
> + * 	igt_require(second_fd >= 0);
> + *
> + * 	if (can_do_foo(first_fd, second_fd))
> + * 		igt_dynamic("first-to-second")
> + * 			test_basic_from_to(first_fd, second_fd);
> + *
> + * 	if (can_do_foo(second_fd, first_fd))
> + * 		igt_dynamic("second-to-first")
> + * 			test_basic_from_to(second_fd, first_fd);
> + *
> + * 	close(first_fd);
> + * 	close(second_fd);
> + * }
> + * ]|
> + *
> + * Returns:
> + * An open DRM fd or -1 on error
> + */
> +int __drm_open_driver_another(int idx, int chipset)
> +{
> +	int fd = -1;
> +	if (igt_device_filter_count() > idx) {
> +		bool found;
> +		struct igt_device_card card;
> +
> +		found = __get_card_for_nth_filter(idx, &card);
> +
> +		if (!found || !strlen(card.card))
> +			igt_warn("No card matches the filter!\n");
> +		else if (_is_already_opened(card.card, idx))
> +			igt_warn("card maching filter %d is already opened\n", idx);
> +		else
> +			fd = __open_driver_exact(card.card, chipset);
> +
> +	} else {
> +		/* no filter for device idx, let's open whatever is available */
> +		fd = __open_driver("/dev/dri/card", 0, chipset, idx);
> +	}


Hmm, took me a while to grasp the full flow from drm_open_driver() to
__try_modprobe() and pals and how that's changed with this...

The difference between drm_open_driver() and __drm_open_driver() is
that the latter doesn't install i915-specific atexit() handlers. Do we
need that kind of functionality for _another()?

Is it documented that anyone using device filters will need to
modprobe themselves if they target a driver that we normally modprobe?


> +
> +	if (fd >= 0)
> +		_set_opened_fd(idx, fd);
> +
> +	return fd;
> +}
> +
>  /**
>   * __drm_open_driver:
>   * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> @@ -354,19 +483,7 @@ static bool __get_the_first_card(struct igt_device_card *card)
>   */
>  int __drm_open_driver(int chipset)
>  {
> -	if (igt_device_filter_count() > 0) {
> -		bool found;
> -		struct igt_device_card card;
> -
> -		found = __get_the_first_card(&card);
> -
> -		if (!found || !strlen(card.card))
> -			return -1;
> -
> -		return __open_driver_exact(card.card, chipset);
> -	}
> -
> -	return __open_driver("/dev/dri/card", 0, chipset);
> +	return __drm_open_driver_another(0, chipset);
>  }
>  
>  int __drm_open_driver_render(int chipset)
> @@ -375,7 +492,7 @@ int __drm_open_driver_render(int chipset)
>  		bool found;
>  		struct igt_device_card card;
>  
> -		found = __get_the_first_card(&card);
> +		found = __get_card_for_nth_filter(0, &card);
>  
>  		if (!found || !strlen(card.render))
>  			return -1;
> @@ -383,7 +500,7 @@ int __drm_open_driver_render(int chipset)
>  		return __open_driver_exact(card.render, chipset);
>  	}
>  
> -	return __open_driver("/dev/dri/renderD", 128, chipset);
> +	return __open_driver("/dev/dri/renderD", 128, chipset, 0);
>  }
>  
>  static int at_exit_drm_fd = -1;
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 632c616b..d5f0fc25 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -90,6 +90,7 @@ void __set_forced_driver(const char *name);
>  int drm_open_driver(int chipset);
>  int drm_open_driver_master(int chipset);
>  int drm_open_driver_render(int chipset);
> +int __drm_open_driver_another(int idx, int chipset);
>  int __drm_open_driver(int chipset);
>  int __drm_open_driver_render(int chipset);
>  
> diff --git a/tests/kms_prime.c b/tests/kms_prime.c
> index 3241c514..8cb2ca2a 100644
> --- a/tests/kms_prime.c
> +++ b/tests/kms_prime.c
> @@ -22,12 +22,19 @@
>   */
>  
>  #include "igt.h"
> -#include "igt_vgem.h"
> +#include "igt_device.h"
>  
>  #include <sys/ioctl.h>
>  #include <sys/poll.h>
>  #include <time.h>
>  
> +struct dumb_bo {
> +	uint32_t handle;
> +	uint32_t width, height;
> +	uint32_t bpp, pitch;
> +	uint64_t size;
> +};
> +
>  struct crc_info {
>  	igt_crc_t crc;
>  	char *str;
> @@ -67,23 +74,24 @@ static bool has_prime_export(int fd)
>  }
>  
>  static igt_output_t *setup_display(int importer_fd, igt_display_t *display,
> -				   enum pipe pipe)
> +				   enum pipe *pipe)
>  {
>  	igt_output_t *output;
> +	bool found = false;
>  
> -	igt_display_require(display, importer_fd);
> -	igt_skip_on(pipe >= display->n_pipes);
> -	output = igt_get_single_output_for_pipe(display, pipe);
> +	for_each_pipe_with_valid_output(display, *pipe, output) {
> +		found = true;
> +		break;
> +	}
>  
> -	igt_require_f(output, "No connector found for pipe %s\n",
> -		      kmstest_pipe_name(pipe));
> +	igt_require_f(found, "No valid connector/pipe found\n");
>  
>  	igt_display_reset(display);
> -	igt_output_set_pipe(output, pipe);
> +	igt_output_set_pipe(output, *pipe);
>  	return output;
>  }
>  
> -static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
> +static void prepare_scratch(int exporter_fd, struct dumb_bo *scratch,
>  			    drmModeModeInfo *mode, uint32_t color)
>  {
>  	uint32_t *ptr;
> @@ -91,16 +99,27 @@ static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
>  	scratch->width = mode->hdisplay;
>  	scratch->height = mode->vdisplay;
>  	scratch->bpp = 32;
> -	vgem_create(exporter_fd, scratch);
>  
> -	ptr = vgem_mmap(exporter_fd, scratch, PROT_WRITE);
> +	scratch->handle = kmstest_dumb_create(exporter_fd,
> +			scratch->width,
> +			scratch->height,
> +			scratch->bpp,
> +			&scratch->pitch,
> +			&scratch->size);
> +
> +
> +	ptr = kmstest_dumb_map_buffer(exporter_fd,
> +				      scratch->handle,
> +				      scratch->size,
> +				      PROT_WRITE);
> +
>  	for (size_t idx = 0; idx < scratch->size / sizeof(*ptr); ++idx)
>  		ptr[idx] = color;
>  
>  	munmap(ptr, scratch->size);
>  }
>  
> -static void prepare_fb(int importer_fd, struct vgem_bo *scratch, struct igt_fb *fb)
> +static void prepare_fb(int importer_fd, struct dumb_bo *scratch, struct igt_fb *fb)
>  {
>  	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
>  	enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
> @@ -126,6 +145,7 @@ static void import_fb(int importer_fd, struct igt_fb *fb,
>  			    DRM_FORMAT_XRGB8888,
>  			    handles, pitches, offsets,
>  			    &fb->fb_id, 0);
> +
>  	igt_assert(ret == 0);
>  }
>  
> @@ -162,19 +182,19 @@ static void test_crc(int exporter_fd, int importer_fd)
>  	igt_display_t display;
>  	igt_output_t *output;
>  	igt_pipe_crc_t *pipe_crc;
> -	enum pipe pipe = PIPE_A;
> +	enum pipe pipe;
>  	struct igt_fb fb;
>  	int dmabuf_fd;
> -	struct vgem_bo scratch = {}; /* despite the name, it suits for any
> -				      * gem-compatible device
> -				      * TODO: rename
> -				      */
> +	struct dumb_bo scratch = {};
> +	bool crc_equal;
>  	int i, j;
>  	drmModeModeInfo *mode;
>  
> -	bool crc_equal = false;
> +	igt_device_set_master(importer_fd);
> +	igt_require_pipe_crc(importer_fd);
> +	igt_display_require(&display, importer_fd);
>  
> -	output = setup_display(importer_fd, &display, pipe);
> +	output = setup_display(importer_fd, &display, &pipe);
>  
>  	mode = igt_output_get_mode(output);
>  	pipe_crc = igt_pipe_crc_new(importer_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
> @@ -188,6 +208,7 @@ static void test_crc(int exporter_fd, int importer_fd)
>  		import_fb(importer_fd, &fb, dmabuf_fd, scratch.pitch);
>  		close(dmabuf_fd);
>  
> +
>  		colors[i].prime_crc.name = "prime";
>  		collect_crc_for_fb(importer_fd, &fb, &display, output,
>  				   pipe_crc, colors[i].color, &colors[i].prime_crc);
> @@ -228,29 +249,35 @@ static void test_crc(int exporter_fd, int importer_fd)
>  	igt_display_fini(&display);
>  }
>  
> -static void run_test_crc(int export_chipset, int import_chipset)
> -{
> -	int importer_fd = -1;
> -	int exporter_fd = -1;
> -
> -	exporter_fd = drm_open_driver(export_chipset);
> -	importer_fd = drm_open_driver_master(import_chipset);
> -
> -	igt_require(has_prime_export(exporter_fd));
> -	igt_require(has_prime_import(importer_fd));
> -	igt_require_pipe_crc(importer_fd);
> -
> -	test_crc(exporter_fd, importer_fd);
> -	close(importer_fd);
> -	close(exporter_fd);
> -}
> -
>  igt_main
>  {
> -	igt_fixture {
> +	igt_fixture
>  		kmstest_set_vt_graphics_mode();
> +
> +	igt_describe("Make a dumb color buffer, export to another device and"
> +		     " compare the CRCs with a buffer native to that device");
> +	igt_subtest_with_dynamic("basic-crc") {
> +		int first_fd = -1;
> +		int second_fd = -1;
> +
> +		/* ANY = anything that is not VGEM */
> +		first_fd = __drm_open_driver_another(0, DRIVER_ANY | DRIVER_VGEM);
> +		igt_require(first_fd >= 0);
> +
> +		second_fd = __drm_open_driver_another(1, DRIVER_ANY | DRIVER_VGEM);
> +		igt_require(second_fd >= 0);

For people not using filters, we can get some predictability for this
by only using DRIVER_VGEM for the second_fd, can't we?



-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another
  2020-04-30  9:01   ` Petri Latvala
@ 2020-04-30  9:29     ` Arkadiusz Hiler
  0 siblings, 0 replies; 8+ messages in thread
From: Arkadiusz Hiler @ 2020-04-30  9:29 UTC (permalink / raw)
  To: Petri Latvala; +Cc: igt-dev

On Thu, Apr 30, 2020 at 12:01:48PM +0300, Petri Latvala wrote:
> On Wed, Apr 29, 2020 at 06:49:02PM +0300, Arkadiusz Hiler wrote:
> > __drm_open_driver_another(int idx, ...) is a counterpart to
> > __drm_open_driver(..) with the following changes:
> > 
> > If device filters are provided the idx-th filter is used and the first
> > matching device is selected.
> > 
> > Consecutive calls to it, with increasing idx (starting from zero) are
> > guaranteed to return fd of a different /dev/dri/ node than the previous
> > calls or -1.
> > 
> > Counterparts to other existing drm_open_*() should be introduced in
> > similar fashion as the need arises.
> > 
> > kms_prime test is converted to use this new call and dumb buffers
> > directly.
> 
> If there's going to be new revisions of this series, can the kms_prime
> changes be split to a separate patch?

yep

> > Cc: Petri Latvala <petri.latvala@intel.com>
> > Cc: Mika Kahola <mika.kahola@intel.com>
> > Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > ---
> >  lib/drmtest.c     | 163 +++++++++++++++++++++++++++++++++++++++-------
> >  lib/drmtest.h     |   1 +
> >  tests/kms_prime.c | 107 ++++++++++++++++++------------
> >  3 files changed, 208 insertions(+), 63 deletions(-)
> > 
> > diff --git a/lib/drmtest.c b/lib/drmtest.c
> > index 7b2fd337..538fcf65 100644
> > --- a/lib/drmtest.c
> > +++ b/lib/drmtest.c
> > @@ -339,6 +387,87 @@ static bool __get_the_first_card(struct igt_device_card *card)
> >  	return false;
> >  }
> >  
> > +/**
> > + * __drm_open_driver_another:
> > + * @idx: index of the device you are opening
> > + * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> > + *
> > + * This function is intended to be used instead of drm_open_driver() for tests
> > + * that are opening multiple /dev/dri/card* nodes, usually for the purpose of
> > + * multi-GPU testing.
> > + *
> > + * This function opens device in the following order:
> > + *
> > + * 1. when --device arguments are present:
> > + *   * device scanning is executed,
> > + *   * idx-th filter (starting with 0, filters are semicolon separated) is used
> > + *   * if there is no idx-th filter, goto 2
> > + *   * first device maching the filter is selected
> > + *   * if it's already opened (for indexes = 0..idx-1) we fail with -1
> > + *   * otherwise open the device and return the fd
> > + *
> > + * 2. compatibility mode - open the first DRM device we can find that is not
> > + *    already opened for indexes 0..idx-1, searching up to 16 device nodes
> > + *
> > + * The test is reponsible to test the interaction between devices in both
> > + * directions if applicable.
> > + *
> > + * Example:
> > + *
> > + * |[<!-- language="c" -->
> > + * igt_subtest_with_dynamic("basic") {
> > + * 	int first_fd = -1;
> > + * 	int second_fd = -1;
> > + *
> > + * 	first_fd = __drm_open_driver_another(0, DRIVER_ANY);
> > + * 	igt_require(first_fd >= 0);
> > + *
> > + * 	second_fd = __drm_open_driver_another(1, DRIVER_ANY);
> > + * 	igt_require(second_fd >= 0);
> > + *
> > + * 	if (can_do_foo(first_fd, second_fd))
> > + * 		igt_dynamic("first-to-second")
> > + * 			test_basic_from_to(first_fd, second_fd);
> > + *
> > + * 	if (can_do_foo(second_fd, first_fd))
> > + * 		igt_dynamic("second-to-first")
> > + * 			test_basic_from_to(second_fd, first_fd);
> > + *
> > + * 	close(first_fd);
> > + * 	close(second_fd);
> > + * }
> > + * ]|
> > + *
> > + * Returns:
> > + * An open DRM fd or -1 on error
> > + */
> > +int __drm_open_driver_another(int idx, int chipset)
> > +{
> > +	int fd = -1;
> > +	if (igt_device_filter_count() > idx) {
> > +		bool found;
> > +		struct igt_device_card card;
> > +
> > +		found = __get_card_for_nth_filter(idx, &card);
> > +
> > +		if (!found || !strlen(card.card))
> > +			igt_warn("No card matches the filter!\n");
> > +		else if (_is_already_opened(card.card, idx))
> > +			igt_warn("card maching filter %d is already opened\n", idx);
> > +		else
> > +			fd = __open_driver_exact(card.card, chipset);
> > +
> > +	} else {
> > +		/* no filter for device idx, let's open whatever is available */
> > +		fd = __open_driver("/dev/dri/card", 0, chipset, idx);
> > +	}
> 
> 
> Hmm, took me a while to grasp the full flow from drm_open_driver() to
> __try_modprobe() and pals and how that's changed with this...
> 
> The difference between drm_open_driver() and __drm_open_driver() is
> that the latter doesn't install i915-specific atexit() handlers. Do we
> need that kind of functionality for _another()?

And skips if fd < 0.

Similar atexit() handler would be necessary for tests that use
_another() with any workload submission, so I would say, yeah, we would
eventually need it and it makes sense to have it as the default one.

It's not needed for this particular test though, so I haven't bothered
to create it yet.

> Is it documented that anyone using device filters will need to
> modprobe themselves if they target a driver that we normally modprobe?

Good catch, let's add:

 found = __get_card_for_nth_filter(idx, &card);
+
+if (!found) {
+	__try_modprobe(chipset);
+	found = __get_card_for_nth_filter(idx, &card);
+}

> > diff --git a/tests/kms_prime.c b/tests/kms_prime.c
> > index 3241c514..8cb2ca2a 100644
> > --- a/tests/kms_prime.c
> > +++ b/tests/kms_prime.c
> > @@ -228,29 +249,35 @@ static void test_crc(int exporter_fd, int importer_fd)
> >  	igt_display_fini(&display);
> >  }
> >  
> > -static void run_test_crc(int export_chipset, int import_chipset)
> > -{
> > -	int importer_fd = -1;
> > -	int exporter_fd = -1;
> > -
> > -	exporter_fd = drm_open_driver(export_chipset);
> > -	importer_fd = drm_open_driver_master(import_chipset);
> > -
> > -	igt_require(has_prime_export(exporter_fd));
> > -	igt_require(has_prime_import(importer_fd));
> > -	igt_require_pipe_crc(importer_fd);
> > -
> > -	test_crc(exporter_fd, importer_fd);
> > -	close(importer_fd);
> > -	close(exporter_fd);
> > -}
> > -
> >  igt_main
> >  {
> > -	igt_fixture {
> > +	igt_fixture
> >  		kmstest_set_vt_graphics_mode();
> > +
> > +	igt_describe("Make a dumb color buffer, export to another device and"
> > +		     " compare the CRCs with a buffer native to that device");
> > +	igt_subtest_with_dynamic("basic-crc") {
> > +		int first_fd = -1;
> > +		int second_fd = -1;
> > +
> > +		/* ANY = anything that is not VGEM */
> > +		first_fd = __drm_open_driver_another(0, DRIVER_ANY | DRIVER_VGEM);
> > +		igt_require(first_fd >= 0);
> > +
> > +		second_fd = __drm_open_driver_another(1, DRIVER_ANY | DRIVER_VGEM);
> > +		igt_require(second_fd >= 0);
> 
> For people not using filters, we can get some predictability for this
> by only using DRIVER_VGEM for the second_fd, can't we?

This would force strict ordering on filters - if you want to use vgem it
would always need to be the second one. I would like to avoid that.

-- 
Cheers,
Arek
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2020-04-30  9:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 15:49 [igt-dev] [PATCH i-g-t 0/2] Test modeseting with imported prime buffer between any two devices Arkadiusz Hiler
2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters Arkadiusz Hiler
2020-04-30  8:42   ` Petri Latvala
2020-04-29 15:49 ` [igt-dev] [PATCH i-g-t 2/2] lib/drmtest: Introduce __drm_open_driver_another Arkadiusz Hiler
2020-04-30  9:01   ` Petri Latvala
2020-04-30  9:29     ` Arkadiusz Hiler
2020-04-29 16:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Test modeseting with imported prime buffer between any two devices Patchwork
2020-04-29 22:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.