All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH 1/2] lib: expose fb_init
@ 2019-07-12 14:16 Oleg Vasilev
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Oleg Vasilev @ 2019-07-12 14:16 UTC (permalink / raw)
  To: igt-dev

Make it public.

Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
---
 lib/igt_fb.c | 38 ++++++++++++++++++--------------------
 lib/igt_fb.h |  4 ++++
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 5dc74a00..bad3eeca 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -485,12 +485,10 @@ static int fb_num_planes(const struct igt_fb *fb)
 		return format->num_planes;
 }
 
-static void fb_init(struct igt_fb *fb,
-		    int fd, int width, int height,
-		    uint32_t drm_format,
-		    uint64_t modifier,
-		    enum igt_color_encoding color_encoding,
-		    enum igt_color_range color_range)
+void igt_init_fb(struct igt_fb *fb, int fd, int width, int height,
+		 uint32_t drm_format, uint64_t modifier,
+		 enum igt_color_encoding color_encoding,
+		 enum igt_color_range color_range)
 {
 	const struct format_desc_struct *f = lookup_drm_format(drm_format);
 
@@ -627,8 +625,8 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64
 {
 	struct igt_fb fb;
 
-	fb_init(&fb, fd, width, height, drm_format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(&fb, fd, width, height, drm_format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	fb.size = calc_fb_size(&fb);
 
@@ -855,8 +853,8 @@ void igt_create_bo_for_fb(int fd, int width, int height,
 			  uint32_t format, uint64_t modifier,
 			  struct igt_fb *fb /* out */)
 {
-	fb_init(fb, fd, width, height, format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(fb, fd, width, height, format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 	create_bo_for_fb(fb);
 }
 
@@ -885,8 +883,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,
 {
 	struct igt_fb fb;
 
-	fb_init(&fb, fd, width, height, format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(&fb, fd, width, height, format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	for (int i = 0; i < fb.num_planes; i++)
 		fb.strides[i] = stride;
@@ -1441,8 +1439,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 {
 	uint32_t flags = 0;
 
-	fb_init(fb, fd, width, height, format, modifier,
-		color_encoding, color_range);
+	igt_init_fb(fb, fd, width, height, format, modifier,
+		    color_encoding, color_range);
 
 	for (int i = 0; i < fb->num_planes; i++)
 		fb->strides[i] = bo_stride;
@@ -1974,9 +1972,9 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
 	 * destination, tiling it at the same time.
 	 */
 
-	fb_init(&linear->fb, fb->fd, fb->width, fb->height,
-		fb->drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
-		fb->color_encoding, fb->color_range);
+	igt_init_fb(&linear->fb, fb->fd, fb->width, fb->height,
+		    fb->drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
+		    fb->color_encoding, fb->color_range);
 
 	create_bo_for_fb(&linear->fb);
 
@@ -2130,9 +2128,9 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 
 	igt_assert(shadow);
 
-	fb_init(shadow, fd, width, height,
-		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(shadow, fd, width, height,
+		    drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * (shadow->plane_bpp[0] / 8), 16);
 	shadow->size = ALIGN((uint64_t)shadow->strides[0] * height,
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index e19cc5d4..69132b41 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -117,6 +117,10 @@ void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
 			  unsigned *width_ret, unsigned *height_ret);
 void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t modifier,
 		      uint64_t *size_ret, unsigned *stride_ret);
+void igt_init_fb(struct igt_fb *fb, int fd, int width, int height,
+		 uint32_t drm_format, uint64_t modifier,
+		 enum igt_color_encoding color_encoding,
+		 enum igt_color_range color_range);
 unsigned int
 igt_create_fb_with_bo_size(int fd, int width, int height,
 			   uint32_t format, uint64_t modifier,
-- 
2.22.0

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

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

* [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
@ 2019-07-12 14:16 ` Oleg Vasilev
  2019-07-12 14:20   ` Chris Wilson
                     ` (4 more replies)
  2019-07-12 15:45 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init Patchwork
                   ` (5 subsequent siblings)
  6 siblings, 5 replies; 20+ messages in thread
From: Oleg Vasilev @ 2019-07-12 14:16 UTC (permalink / raw)
  To: igt-dev; +Cc: Daniel Vetter

Current, we have different sets of prime tests:
 - vgem+i915
 - amdgpu+i915
 - nouveau+i915

Those tests use vendor-specific ioctls, therefore, not interchangeable.
The idea is to create a set of tests which are expected to work on any
prime-compatible driver. It can be run with any combination of
exporter+importer, while those devices have respective prime
capabilities.

Since vgem can be used as both exporter and importer, and there aren't
any generic kms features which vgem doesn't support, it is sufficient
to test DRIVER_ANY+DRIVER_VKMS.

The first test is simple:
1. Exporter creates a dumb FB and fills it with a plain color
2. FB is transferred to the importer
3. Importer modesets and computes pipe CRC
4. Importer draws the same color through cairo and compares CRC

The initial motivation comes from the need to test prime support in
vkms.

Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
---
 tests/meson.build     |   1 +
 tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c

diff --git a/tests/meson.build b/tests/meson.build
index 34a74025..1c938e95 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -76,6 +76,7 @@ test_progs = [
 	'prime_self_import',
 	'prime_udl',
 	'prime_vgem',
+	'prime_generic',
 	'syncobj_basic',
 	'syncobj_wait',
 	'template',
diff --git a/tests/prime_generic.c b/tests/prime_generic.c
new file mode 100644
index 00000000..f273a4f6
--- /dev/null
+++ b/tests/prime_generic.c
@@ -0,0 +1,250 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_vgem.h"
+
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <time.h>
+
+struct crc_info {
+	igt_crc_t crc;
+	char *str;
+	const char *name;
+};
+
+static struct {
+	double r, g, b;
+	uint32_t color;
+	struct crc_info prime_crc, direct_crc;
+} colors[3] = {
+	{ .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000},
+	{ .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff},
+	{ .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000},
+};
+
+IGT_TEST_DESCRIPTION("Generic tests, working with any prime device");
+
+static bool has_prime_import(int fd)
+{
+	uint64_t value;
+
+	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
+		return false;
+
+	return value & DRM_PRIME_CAP_IMPORT;
+}
+
+static bool has_prime_export(int fd)
+{
+	uint64_t value;
+
+	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
+		return false;
+
+	return value & DRM_PRIME_CAP_EXPORT;
+}
+
+static void setup_display(int importer, igt_display_t *display, igt_output_t **output,
+			  enum pipe pipe)
+{
+	igt_display_require(display, importer);
+	igt_skip_on(pipe >= display->n_pipes);
+	*output = igt_get_single_output_for_pipe(display, pipe);
+	igt_require_f(*output, "No connector found for pipe %s\n",
+		      kmstest_pipe_name(pipe));
+
+	igt_display_reset(display);
+	igt_output_set_pipe(*output, pipe);
+}
+
+static void prepare_scratch(int exporter, struct vgem_bo *scratch,
+			    drmModeModeInfo *mode, uint32_t color)
+{
+	int i;
+	uint32_t *ptr;
+
+	scratch->width = mode->hdisplay;
+	scratch->height = mode->vdisplay;
+	scratch->bpp = 32;
+	vgem_create(exporter, scratch);
+
+	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
+	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
+		ptr[i] = color;
+
+	munmap(ptr, scratch->size);
+}
+
+static void prepare_fb(int importer, struct vgem_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;
+
+	igt_init_fb(fb, importer, scratch->width, scratch->height,
+		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+		    color_encoding, color_range);
+}
+
+static void import_fb(int importer, struct igt_fb *fb,
+		      int dmabuf_fd, uint32_t pitch)
+{
+	uint32_t offsets[4], pitches[4], handles[4];
+	int ret;
+
+	fb->gem_handle = prime_fd_to_handle(importer, dmabuf_fd);
+
+	handles[0] = fb->gem_handle;
+	pitches[0] = pitch;
+	offsets[0] = 0;
+
+	ret = drmModeAddFB2(importer, fb->width, fb->height,
+			    DRM_FORMAT_XRGB8888,
+			    handles, pitches, offsets,
+			    &fb->fb_id, 0);
+	igt_assert(ret == 0);
+}
+
+static void set_fb(struct igt_fb *fb,
+		   igt_display_t *display,
+		   igt_output_t *output)
+{
+	igt_plane_t *primary;
+	int ret;
+
+	primary = igt_output_get_plane(output, 0);
+	igt_plane_set_fb(primary, fb);
+	ret = igt_display_commit(display);
+
+	igt_assert(ret == 0);
+}
+
+static void collect_crc(int importer, struct igt_fb *fb, igt_display_t *display,
+			igt_output_t *output, igt_pipe_crc_t *pipe_crc,
+			uint32_t color, struct crc_info *info)
+{
+	set_fb(fb, display, output);
+	igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
+	info->str = igt_crc_to_string(&info->crc);
+	igt_debug("CRC through '%s' method for %#08x is %s\n",
+		  info->name, color, info->str);
+	igt_remove_fb(importer, fb);
+}
+
+static void test_crc(int exporter, int importer)
+{
+	igt_display_t display;
+	igt_output_t *output;
+	igt_pipe_crc_t *pipe_crc;
+	enum pipe pipe = PIPE_A;
+	struct igt_fb fb;
+	int dmabuf_fd;
+	struct vgem_bo scratch; /* despite the name, it suits for any
+				 * gem-compatible device
+				 * TODO: rename
+				 */
+	int i, j;
+	drmModeModeInfo *mode;
+
+	bool crc_equal = false;
+
+	setup_display(importer, &display, &output, pipe);
+
+	mode = igt_output_get_mode(output);
+	pipe_crc = igt_pipe_crc_new(importer, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		prepare_scratch(exporter, &scratch, mode, colors[i].color);
+		dmabuf_fd = prime_handle_to_fd(exporter, scratch.handle);
+		gem_close(exporter, scratch.handle);
+
+		prepare_fb(importer, &scratch, &fb);
+		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
+		close(dmabuf_fd);
+
+		colors[i].prime_crc.name = "prime";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color, &colors[i].prime_crc);
+
+		igt_create_color_fb(importer,
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    colors[i].r, colors[i].g, colors[i].b,
+				    &fb);
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color, &colors[i].direct_crc);
+	}
+	igt_pipe_crc_free(pipe_crc);
+
+	igt_debug("CRC table:\n");
+	igt_debug("Color\t\tPrime\t\tDirect\n");
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
+			  colors[i].prime_crc.str, colors[i].direct_crc.str);
+		free(colors[i].prime_crc.str);
+		free(colors[i].direct_crc.str);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		for (j = 0; j < ARRAY_SIZE(colors); j++) {
+			if (i == j) {
+				igt_assert_crc_equal(&colors[i].prime_crc.crc,
+						     &colors[j].direct_crc.crc);
+				continue;
+			}
+			crc_equal = igt_check_crc_equal(&colors[i].prime_crc.crc,
+							&colors[j].direct_crc.crc);
+			igt_assert_f(!crc_equal, "CRC should be different");
+		}
+	}
+	igt_display_fini(&display);
+}
+
+static void run_test_crc(int export_chipset, int import_chipset)
+{
+	int importer = -1;
+	int exporter = -1;
+
+	exporter = drm_open_driver(export_chipset);
+	importer = drm_open_driver_master(import_chipset);
+
+	igt_require(has_prime_export(exporter));
+	igt_require(has_prime_import(importer));
+	igt_require_pipe_crc(importer);
+
+	test_crc(exporter, importer);
+	close(importer);
+	close(exporter);
+}
+
+igt_main
+{
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+	}
+	igt_subtest("crc")
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}
-- 
2.22.0

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

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
@ 2019-07-12 14:20   ` Chris Wilson
  2019-07-31  9:45   ` Vasilev, Oleg
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-07-12 14:20 UTC (permalink / raw)
  To: Oleg Vasilev, igt-dev; +Cc: Daniel Vetter

Quoting Oleg Vasilev (2019-07-12 15:16:18)
> Current, we have different sets of prime tests:
>  - vgem+i915
>  - amdgpu+i915
>  - nouveau+i915
> 
> Those tests use vendor-specific ioctls, therefore, not interchangeable.
> The idea is to create a set of tests which are expected to work on any
> prime-compatible driver. It can be run with any combination of
> exporter+importer, while those devices have respective prime
> capabilities.
> 
> Since vgem can be used as both exporter and importer, and there aren't
> any generic kms features which vgem doesn't support, it is sufficient
> to test DRIVER_ANY+DRIVER_VKMS.
> 
> The first test is simple:
> 1. Exporter creates a dumb FB and fills it with a plain color
> 2. FB is transferred to the importer
> 3. Importer modesets and computes pipe CRC
> 4. Importer draws the same color through cairo and compares CRC
> 
> The initial motivation comes from the need to test prime support in
> vkms.
> 
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
> ---
>  tests/meson.build     |   1 +
>  tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 251 insertions(+)
>  create mode 100644 tests/prime_generic.c
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 34a74025..1c938e95 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -76,6 +76,7 @@ test_progs = [
>         'prime_self_import',
>         'prime_udl',
>         'prime_vgem',
> +       'prime_generic',

Shouldn't this be kms_prime? A bunch of generic kms tests with the focus
on using prime imports?
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
@ 2019-07-12 15:45 ` Patchwork
  2019-07-12 17:07 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-07-12 15:45 UTC (permalink / raw)
  To: Oleg Vasilev; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init
URL   : https://patchwork.freedesktop.org/series/63653/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6474 -> IGTPW_3266
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

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

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

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

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_contexts:
    - fi-skl-iommu:       [PASS][1] -> [INCOMPLETE][2] ([fdo#111050])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/fi-skl-iommu/igt@i915_selftest@live_contexts.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-skl-iommu/igt@i915_selftest@live_contexts.html

  * igt@kms_chamelium@dp-crc-fast:
    - fi-cml-u2:          [PASS][3] -> [FAIL][4] ([fdo#110627])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html

  
#### Possible fixes ####

  * igt@gem_exec_suspend@basic-s3:
    - fi-apl-guc:         [DMESG-WARN][5] ([fdo#108566]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/fi-apl-guc/igt@gem_exec_suspend@basic-s3.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-apl-guc/igt@gem_exec_suspend@basic-s3.html

  * igt@kms_chamelium@hdmi-edid-read:
    - {fi-icl-u4}:        [FAIL][7] ([fdo#111045] / [fdo#111046 ]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/fi-icl-u4/igt@kms_chamelium@hdmi-edid-read.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-icl-u4/igt@kms_chamelium@hdmi-edid-read.html

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

  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#110627]: https://bugs.freedesktop.org/show_bug.cgi?id=110627
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111046 ]: https://bugs.freedesktop.org/show_bug.cgi?id=111046 
  [fdo#111050]: https://bugs.freedesktop.org/show_bug.cgi?id=111050


Participating hosts (54 -> 47)
------------------------------

  Additional (1): fi-pnv-d510 
  Missing    (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


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

  * IGT: IGT_5095 -> IGTPW_3266

  CI_DRM_6474: 0140ee44b0e52427496bcc7dddba0f0d7ee15f56 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_3266: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/
  IGT_5095: 549e1cdc064c0491a9c4509f42d826ae0e752a07 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@prime_generic@crc

== Logs ==

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

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

* [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
  2019-07-12 15:45 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init Patchwork
@ 2019-07-12 17:07 ` Patchwork
  2019-07-14  4:16 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-07-12 17:07 UTC (permalink / raw)
  To: Oleg Vasilev; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init
URL   : https://patchwork.freedesktop.org/series/63653/
State : warning

== Summary ==

Pipeline status: FAILED.

See https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/48419 for more details.

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/48419
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] lib: expose fb_init
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
                   ` (2 preceding siblings ...)
  2019-07-12 17:07 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
@ 2019-07-14  4:16 ` Patchwork
  2019-08-16 14:56 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init (rev3) Patchwork
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-07-14  4:16 UTC (permalink / raw)
  To: Oleg Vasilev; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init
URL   : https://patchwork.freedesktop.org/series/63653/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6474_full -> IGTPW_3266_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

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

New tests
---------

  New tests have been introduced between CI_DRM_6474_full and IGTPW_3266_full:

### New IGT tests (1) ###

  * igt@prime_generic@crc:
    - Statuses : 4 pass(s)
    - Exec time: [0.66, 1.20] s

  

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

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

### IGT changes ###

#### Issues hit ####

  * igt@gem_close@many-handles-one-vma:
    - shard-glk:          [PASS][1] -> [INCOMPLETE][2] ([fdo#103359] / [k.org#198133])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-glk2/igt@gem_close@many-handles-one-vma.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-glk2/igt@gem_close@many-handles-one-vma.html

  * igt@i915_pm_rpm@i2c:
    - shard-hsw:          [PASS][3] -> [FAIL][4] ([fdo#104097])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-hsw2/igt@i915_pm_rpm@i2c.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw4/igt@i915_pm_rpm@i2c.html

  * igt@kms_busy@basic-modeset-b:
    - shard-hsw:          [PASS][5] -> [INCOMPLETE][6] ([fdo#103540])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-hsw2/igt@kms_busy@basic-modeset-b.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw8/igt@kms_busy@basic-modeset-b.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw:
    - shard-iclb:         [PASS][7] -> [FAIL][8] ([fdo#103167]) +2 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb4/igt@kms_frontbuffer_tracking@fbcpsr-1p-pri-indfb-multidraw.html

  * igt@kms_psr@psr2_cursor_mmap_cpu:
    - shard-iclb:         [PASS][9] -> [SKIP][10] ([fdo#109441]) +2 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb5/igt@kms_psr@psr2_cursor_mmap_cpu.html

  * igt@kms_setmode@basic:
    - shard-apl:          [PASS][11] -> [FAIL][12] ([fdo#99912])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-apl1/igt@kms_setmode@basic.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl2/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-a-ts-continuation-suspend:
    - shard-apl:          [PASS][13] -> [DMESG-WARN][14] ([fdo#108566]) +2 similar issues
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-apl8/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl2/igt@kms_vblank@pipe-a-ts-continuation-suspend.html

  
#### Possible fixes ####

  * igt@gem_eio@in-flight-suspend:
    - shard-apl:          [DMESG-WARN][15] ([fdo#108566]) -> [PASS][16] +3 similar issues
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-apl6/igt@gem_eio@in-flight-suspend.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl3/igt@gem_eio@in-flight-suspend.html

  * igt@gem_exec_parallel@basic:
    - shard-snb:          [INCOMPLETE][17] ([fdo#105411]) -> [PASS][18]
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-snb6/igt@gem_exec_parallel@basic.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-snb7/igt@gem_exec_parallel@basic.html

  * igt@i915_pm_rc6_residency@rc6-accuracy:
    - shard-kbl:          [SKIP][19] ([fdo#109271]) -> [PASS][20]
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-kbl2/igt@i915_pm_rc6_residency@rc6-accuracy.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-kbl3/igt@i915_pm_rc6_residency@rc6-accuracy.html

  * igt@kms_cursor_crc@pipe-a-cursor-128x128-random:
    - shard-kbl:          [FAIL][21] ([fdo#103232]) -> [PASS][22] +1 similar issue
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-128x128-random.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-128x128-random.html
    - shard-apl:          [FAIL][23] ([fdo#103232]) -> [PASS][24] +1 similar issue
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-apl4/igt@kms_cursor_crc@pipe-a-cursor-128x128-random.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl1/igt@kms_cursor_crc@pipe-a-cursor-128x128-random.html

  * igt@kms_flip@2x-modeset-vs-vblank-race-interruptible:
    - shard-glk:          [FAIL][25] ([fdo#103060]) -> [PASS][26]
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-glk3/igt@kms_flip@2x-modeset-vs-vblank-race-interruptible.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-glk7/igt@kms_flip@2x-modeset-vs-vblank-race-interruptible.html

  * igt@kms_flip@flip-vs-modeset-vs-hang-interruptible:
    - shard-hsw:          [INCOMPLETE][27] ([fdo#103540]) -> [PASS][28] +1 similar issue
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-hsw8/igt@kms_flip@flip-vs-modeset-vs-hang-interruptible.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw5/igt@kms_flip@flip-vs-modeset-vs-hang-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
    - shard-apl:          [FAIL][29] ([fdo#103167]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-apl4/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html
    - shard-kbl:          [FAIL][31] ([fdo#103167]) -> [PASS][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-kbl2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-kbl7/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbc-1p-rte:
    - shard-iclb:         [FAIL][33] ([fdo#103167] / [fdo#110378]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb5/igt@kms_frontbuffer_tracking@fbc-1p-rte.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb8/igt@kms_frontbuffer_tracking@fbc-1p-rte.html

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-mmap-cpu:
    - shard-glk:          [FAIL][35] ([fdo#103167]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-glk7/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-mmap-cpu.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-glk1/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-cur-indfb-draw-mmap-cpu.html

  * igt@kms_frontbuffer_tracking@fbcpsr-stridechange:
    - shard-iclb:         [FAIL][37] ([fdo#103167]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-stridechange.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb1/igt@kms_frontbuffer_tracking@fbcpsr-stridechange.html

  * igt@kms_plane_cursor@pipe-a-primary-size-256:
    - shard-iclb:         [INCOMPLETE][39] ([fdo#107713]) -> [PASS][40]
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb1/igt@kms_plane_cursor@pipe-a-primary-size-256.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb6/igt@kms_plane_cursor@pipe-a-primary-size-256.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-iclb:         [FAIL][41] ([fdo#103166]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb4/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb8/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr@psr2_primary_mmap_gtt:
    - shard-iclb:         [SKIP][43] ([fdo#109441]) -> [PASS][44] +1 similar issue
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb7/igt@kms_psr@psr2_primary_mmap_gtt.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb2/igt@kms_psr@psr2_primary_mmap_gtt.html

  
#### Warnings ####

  * igt@i915_pm_rc6_residency@media-rc6-accuracy:
    - shard-iclb:         [SKIP][45] ([fdo#110933]) -> [SKIP][46] ([fdo#109289])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6474/shard-iclb8/igt@i915_pm_rc6_residency@media-rc6-accuracy.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb4/igt@i915_pm_rc6_residency@media-rc6-accuracy.html

  
  [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#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
  [fdo#104097]: https://bugs.freedesktop.org/show_bug.cgi?id=104097
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#110378]: https://bugs.freedesktop.org/show_bug.cgi?id=110378
  [fdo#110933]: https://bugs.freedesktop.org/show_bug.cgi?id=110933
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (10 -> 6)
------------------------------

  Missing    (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005 


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

  * IGT: IGT_5095 -> IGTPW_3266
  * Piglit: piglit_4509 -> None

  CI_DRM_6474: 0140ee44b0e52427496bcc7dddba0f0d7ee15f56 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_3266: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/
  IGT_5095: 549e1cdc064c0491a9c4509f42d826ae0e752a07 @ 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_3266/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
  2019-07-12 14:20   ` Chris Wilson
@ 2019-07-31  9:45   ` Vasilev, Oleg
  2019-08-02 14:38   ` Daniel Vetter
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Vasilev, Oleg @ 2019-07-31  9:45 UTC (permalink / raw)
  To: igt-dev; +Cc: daniel


[-- Attachment #1.1: Type: text/plain, Size: 9927 bytes --]

Hi,

Can I get more review for this series?

Oleg

On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> Current, we have different sets of prime tests:
>  - vgem+i915
>  - amdgpu+i915
>  - nouveau+i915
> 
> Those tests use vendor-specific ioctls, therefore, not
> interchangeable.
> The idea is to create a set of tests which are expected to work on
> any
> prime-compatible driver. It can be run with any combination of
> exporter+importer, while those devices have respective prime
> capabilities.
> 
> Since vgem can be used as both exporter and importer, and there
> aren't
> any generic kms features which vgem doesn't support, it is sufficient
> to test DRIVER_ANY+DRIVER_VKMS.
> 
> The first test is simple:
> 1. Exporter creates a dumb FB and fills it with a plain color
> 2. FB is transferred to the importer
> 3. Importer modesets and computes pipe CRC
> 4. Importer draws the same color through cairo and compares CRC
> 
> The initial motivation comes from the need to test prime support in
> vkms.
> 
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
> ---
>  tests/meson.build     |   1 +
>  tests/prime_generic.c | 250
> ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 251 insertions(+)
>  create mode 100644 tests/prime_generic.c
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 34a74025..1c938e95 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -76,6 +76,7 @@ test_progs = [
>  	'prime_self_import',
>  	'prime_udl',
>  	'prime_vgem',
> +	'prime_generic',
>  	'syncobj_basic',
>  	'syncobj_wait',
>  	'template',
> diff --git a/tests/prime_generic.c b/tests/prime_generic.c
> new file mode 100644
> index 00000000..f273a4f6
> --- /dev/null
> +++ b/tests/prime_generic.c
> @@ -0,0 +1,250 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> obtaining a
> + * copy of this software and associated documentation files (the
> "Software"),
> + * to deal in the Software without restriction, including without
> limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom
> the
> + * Software is furnished to do so, subject to the following
> conditions:
> + *
> + * The above copyright notice and this permission notice (including
> the next
> + * paragraph) shall be included in all copies or substantial
> portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO
> EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vgem.h"
> +
> +#include <sys/ioctl.h>
> +#include <sys/poll.h>
> +#include <time.h>
> +
> +struct crc_info {
> +	igt_crc_t crc;
> +	char *str;
> +	const char *name;
> +};
> +
> +static struct {
> +	double r, g, b;
> +	uint32_t color;
> +	struct crc_info prime_crc, direct_crc;
> +} colors[3] = {
> +	{ .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000},
> +	{ .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff},
> +	{ .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000},
> +};
> +
> +IGT_TEST_DESCRIPTION("Generic tests, working with any prime
> device");
> +
> +static bool has_prime_import(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_IMPORT;
> +}
> +
> +static bool has_prime_export(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_EXPORT;
> +}
> +
> +static void setup_display(int importer, igt_display_t *display,
> igt_output_t **output,
> +			  enum pipe pipe)
> +{
> +	igt_display_require(display, importer);
> +	igt_skip_on(pipe >= display->n_pipes);
> +	*output = igt_get_single_output_for_pipe(display, pipe);
> +	igt_require_f(*output, "No connector found for pipe %s\n",
> +		      kmstest_pipe_name(pipe));
> +
> +	igt_display_reset(display);
> +	igt_output_set_pipe(*output, pipe);
> +}
> +
> +static void prepare_scratch(int exporter, struct vgem_bo *scratch,
> +			    drmModeModeInfo *mode, uint32_t color)
> +{
> +	int i;
> +	uint32_t *ptr;
> +
> +	scratch->width = mode->hdisplay;
> +	scratch->height = mode->vdisplay;
> +	scratch->bpp = 32;
> +	vgem_create(exporter, scratch);
> +
> +	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
> +	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> +		ptr[i] = color;
> +
> +	munmap(ptr, scratch->size);
> +}
> +
> +static void prepare_fb(int importer, struct vgem_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;
> +
> +	igt_init_fb(fb, importer, scratch->width, scratch->height,
> +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +		    color_encoding, color_range);
> +}
> +
> +static void import_fb(int importer, struct igt_fb *fb,
> +		      int dmabuf_fd, uint32_t pitch)
> +{
> +	uint32_t offsets[4], pitches[4], handles[4];
> +	int ret;
> +
> +	fb->gem_handle = prime_fd_to_handle(importer, dmabuf_fd);
> +
> +	handles[0] = fb->gem_handle;
> +	pitches[0] = pitch;
> +	offsets[0] = 0;
> +
> +	ret = drmModeAddFB2(importer, fb->width, fb->height,
> +			    DRM_FORMAT_XRGB8888,
> +			    handles, pitches, offsets,
> +			    &fb->fb_id, 0);
> +	igt_assert(ret == 0);
> +}
> +
> +static void set_fb(struct igt_fb *fb,
> +		   igt_display_t *display,
> +		   igt_output_t *output)
> +{
> +	igt_plane_t *primary;
> +	int ret;
> +
> +	primary = igt_output_get_plane(output, 0);
> +	igt_plane_set_fb(primary, fb);
> +	ret = igt_display_commit(display);
> +
> +	igt_assert(ret == 0);
> +}
> +
> +static void collect_crc(int importer, struct igt_fb *fb,
> igt_display_t *display,
> +			igt_output_t *output, igt_pipe_crc_t *pipe_crc,
> +			uint32_t color, struct crc_info *info)
> +{
> +	set_fb(fb, display, output);
> +	igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
> +	info->str = igt_crc_to_string(&info->crc);
> +	igt_debug("CRC through '%s' method for %#08x is %s\n",
> +		  info->name, color, info->str);
> +	igt_remove_fb(importer, fb);
> +}
> +
> +static void test_crc(int exporter, int importer)
> +{
> +	igt_display_t display;
> +	igt_output_t *output;
> +	igt_pipe_crc_t *pipe_crc;
> +	enum pipe pipe = PIPE_A;
> +	struct igt_fb fb;
> +	int dmabuf_fd;
> +	struct vgem_bo scratch; /* despite the name, it suits for any
> +				 * gem-compatible device
> +				 * TODO: rename
> +				 */
> +	int i, j;
> +	drmModeModeInfo *mode;
> +
> +	bool crc_equal = false;
> +
> +	setup_display(importer, &display, &output, pipe);
> +
> +	mode = igt_output_get_mode(output);
> +	pipe_crc = igt_pipe_crc_new(importer, pipe,
> INTEL_PIPE_CRC_SOURCE_AUTO);
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		prepare_scratch(exporter, &scratch, mode,
> colors[i].color);
> +		dmabuf_fd = prime_handle_to_fd(exporter,
> scratch.handle);
> +		gem_close(exporter, scratch.handle);
> +
> +		prepare_fb(importer, &scratch, &fb);
> +		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
> +		close(dmabuf_fd);
> +
> +		colors[i].prime_crc.name = "prime";
> +		collect_crc(importer, &fb, &display, output,
> +			    pipe_crc, colors[i].color,
> &colors[i].prime_crc);
> +
> +		igt_create_color_fb(importer,
> +				    mode->hdisplay, mode->vdisplay,
> +				    DRM_FORMAT_XRGB8888,
> LOCAL_DRM_FORMAT_MOD_NONE,
> +				    colors[i].r, colors[i].g,
> colors[i].b,
> +				    &fb);
> +
> +		colors[i].direct_crc.name = "direct";
> +		collect_crc(importer, &fb, &display, output,
> +			    pipe_crc, colors[i].color,
> &colors[i].direct_crc);
> +	}
> +	igt_pipe_crc_free(pipe_crc);
> +
> +	igt_debug("CRC table:\n");
> +	igt_debug("Color\t\tPrime\t\tDirect\n");
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> +			  colors[i].prime_crc.str,
> colors[i].direct_crc.str);
> +		free(colors[i].prime_crc.str);
> +		free(colors[i].direct_crc.str);
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		for (j = 0; j < ARRAY_SIZE(colors); j++) {
> +			if (i == j) {
> +				igt_assert_crc_equal(&colors[i].prime_c
> rc.crc,
> +						     &colors[j].direct_
> crc.crc);
> +				continue;
> +			}
> +			crc_equal =
> igt_check_crc_equal(&colors[i].prime_crc.crc,
> +							&colors[j].dire
> ct_crc.crc);
> +			igt_assert_f(!crc_equal, "CRC should be
> different");
> +		}
> +	}
> +	igt_display_fini(&display);
> +}
> +
> +static void run_test_crc(int export_chipset, int import_chipset)
> +{
> +	int importer = -1;
> +	int exporter = -1;
> +
> +	exporter = drm_open_driver(export_chipset);
> +	importer = drm_open_driver_master(import_chipset);
> +
> +	igt_require(has_prime_export(exporter));
> +	igt_require(has_prime_import(importer));
> +	igt_require_pipe_crc(importer);
> +
> +	test_crc(exporter, importer);
> +	close(importer);
> +	close(exporter);
> +}
> +
> +igt_main
> +{
> +	igt_fixture {
> +		kmstest_set_vt_graphics_mode();
> +	}
> +	igt_subtest("crc")
> +		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> +}

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3261 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

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

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
  2019-07-12 14:20   ` Chris Wilson
  2019-07-31  9:45   ` Vasilev, Oleg
@ 2019-08-02 14:38   ` Daniel Vetter
  2019-08-16 10:07   ` Ser, Simon
  2019-08-16 14:21   ` [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
  4 siblings, 0 replies; 20+ messages in thread
From: Daniel Vetter @ 2019-08-02 14:38 UTC (permalink / raw)
  To: Oleg Vasilev; +Cc: IGT development

On Fri, Jul 12, 2019 at 4:16 PM Oleg Vasilev <oleg.vasilev@intel.com> wrote:
>
> Current, we have different sets of prime tests:
>  - vgem+i915
>  - amdgpu+i915
>  - nouveau+i915
>
> Those tests use vendor-specific ioctls, therefore, not interchangeable.
> The idea is to create a set of tests which are expected to work on any
> prime-compatible driver. It can be run with any combination of
> exporter+importer, while those devices have respective prime
> capabilities.
>
> Since vgem can be used as both exporter and importer, and there aren't
> any generic kms features which vgem doesn't support, it is sufficient
> to test DRIVER_ANY+DRIVER_VKMS.

I guess you meant ANY + VGEM here?

> The first test is simple:
> 1. Exporter creates a dumb FB and fills it with a plain color
> 2. FB is transferred to the importer
> 3. Importer modesets and computes pipe CRC
> 4. Importer draws the same color through cairo and compares CRC
>
> The initial motivation comes from the need to test prime support in
> vkms.
>
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
> ---
>  tests/meson.build     |   1 +
>  tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++

Also seconded on Chris' suggestion to call this kms_prime.c I think
that fits better.
>  2 files changed, 251 insertions(+)
>  create mode 100644 tests/prime_generic.c
>
> diff --git a/tests/meson.build b/tests/meson.build
> index 34a74025..1c938e95 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -76,6 +76,7 @@ test_progs = [
>         'prime_self_import',
>         'prime_udl',
>         'prime_vgem',
> +       'prime_generic',
>         'syncobj_basic',
>         'syncobj_wait',
>         'template',
> diff --git a/tests/prime_generic.c b/tests/prime_generic.c
> new file mode 100644
> index 00000000..f273a4f6
> --- /dev/null
> +++ b/tests/prime_generic.c
> @@ -0,0 +1,250 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vgem.h"
> +
> +#include <sys/ioctl.h>
> +#include <sys/poll.h>
> +#include <time.h>
> +
> +struct crc_info {
> +       igt_crc_t crc;
> +       char *str;
> +       const char *name;
> +};
> +
> +static struct {
> +       double r, g, b;
> +       uint32_t color;
> +       struct crc_info prime_crc, direct_crc;
> +} colors[3] = {
> +       { .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000},
> +       { .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff},
> +       { .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000},
> +};
> +
> +IGT_TEST_DESCRIPTION("Generic tests, working with any prime device");
> +
> +static bool has_prime_import(int fd)
> +{
> +       uint64_t value;
> +
> +       if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +               return false;
> +
> +       return value & DRM_PRIME_CAP_IMPORT;
> +}
> +
> +static bool has_prime_export(int fd)
> +{
> +       uint64_t value;
> +
> +       if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +               return false;
> +
> +       return value & DRM_PRIME_CAP_EXPORT;
> +}
> +
> +static void setup_display(int importer, igt_display_t *display, igt_output_t **output,
> +                         enum pipe pipe)
> +{
> +       igt_display_require(display, importer);
> +       igt_skip_on(pipe >= display->n_pipes);
> +       *output = igt_get_single_output_for_pipe(display, pipe);
> +       igt_require_f(*output, "No connector found for pipe %s\n",
> +                     kmstest_pipe_name(pipe));
> +
> +       igt_display_reset(display);
> +       igt_output_set_pipe(*output, pipe);
> +}
> +
> +static void prepare_scratch(int exporter, struct vgem_bo *scratch,
> +                           drmModeModeInfo *mode, uint32_t color)
> +{
> +       int i;
> +       uint32_t *ptr;
> +
> +       scratch->width = mode->hdisplay;
> +       scratch->height = mode->vdisplay;
> +       scratch->bpp = 32;
> +       vgem_create(exporter, scratch);
> +
> +       ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
> +       for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> +               ptr[i] = color;
> +
> +       munmap(ptr, scratch->size);
> +}
> +
> +static void prepare_fb(int importer, struct vgem_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;
> +
> +       igt_init_fb(fb, importer, scratch->width, scratch->height,
> +                   DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +                   color_encoding, color_range);
> +}
> +
> +static void import_fb(int importer, struct igt_fb *fb,
> +                     int dmabuf_fd, uint32_t pitch)
> +{
> +       uint32_t offsets[4], pitches[4], handles[4];
> +       int ret;
> +
> +       fb->gem_handle = prime_fd_to_handle(importer, dmabuf_fd);
> +
> +       handles[0] = fb->gem_handle;
> +       pitches[0] = pitch;
> +       offsets[0] = 0;
> +
> +       ret = drmModeAddFB2(importer, fb->width, fb->height,
> +                           DRM_FORMAT_XRGB8888,
> +                           handles, pitches, offsets,
> +                           &fb->fb_id, 0);
> +       igt_assert(ret == 0);
> +}
> +
> +static void set_fb(struct igt_fb *fb,
> +                  igt_display_t *display,
> +                  igt_output_t *output)
> +{
> +       igt_plane_t *primary;
> +       int ret;
> +
> +       primary = igt_output_get_plane(output, 0);
> +       igt_plane_set_fb(primary, fb);
> +       ret = igt_display_commit(display);
> +
> +       igt_assert(ret == 0);
> +}
> +
> +static void collect_crc(int importer, struct igt_fb *fb, igt_display_t *display,
> +                       igt_output_t *output, igt_pipe_crc_t *pipe_crc,
> +                       uint32_t color, struct crc_info *info)
> +{
> +       set_fb(fb, display, output);
> +       igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
> +       info->str = igt_crc_to_string(&info->crc);
> +       igt_debug("CRC through '%s' method for %#08x is %s\n",
> +                 info->name, color, info->str);
> +       igt_remove_fb(importer, fb);
> +}
> +
> +static void test_crc(int exporter, int importer)

Not sure threading importer/exporter through makes sense anymore,
since it's just ANY + VGEM. It'd drop these.

Otherwise lgtm, has my ack, but I guess would be good if you can get
someone to do a detailed review. Like Simon or maybe someone else.

Cheers, Daniel

> +{
> +       igt_display_t display;
> +       igt_output_t *output;
> +       igt_pipe_crc_t *pipe_crc;
> +       enum pipe pipe = PIPE_A;
> +       struct igt_fb fb;
> +       int dmabuf_fd;
> +       struct vgem_bo scratch; /* despite the name, it suits for any
> +                                * gem-compatible device
> +                                * TODO: rename
> +                                */
> +       int i, j;
> +       drmModeModeInfo *mode;
> +
> +       bool crc_equal = false;
> +
> +       setup_display(importer, &display, &output, pipe);
> +
> +       mode = igt_output_get_mode(output);
> +       pipe_crc = igt_pipe_crc_new(importer, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
> +
> +       for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +               prepare_scratch(exporter, &scratch, mode, colors[i].color);
> +               dmabuf_fd = prime_handle_to_fd(exporter, scratch.handle);
> +               gem_close(exporter, scratch.handle);
> +
> +               prepare_fb(importer, &scratch, &fb);
> +               import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
> +               close(dmabuf_fd);
> +
> +               colors[i].prime_crc.name = "prime";
> +               collect_crc(importer, &fb, &display, output,
> +                           pipe_crc, colors[i].color, &colors[i].prime_crc);
> +
> +               igt_create_color_fb(importer,
> +                                   mode->hdisplay, mode->vdisplay,
> +                                   DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +                                   colors[i].r, colors[i].g, colors[i].b,
> +                                   &fb);
> +
> +               colors[i].direct_crc.name = "direct";
> +               collect_crc(importer, &fb, &display, output,
> +                           pipe_crc, colors[i].color, &colors[i].direct_crc);
> +       }
> +       igt_pipe_crc_free(pipe_crc);
> +
> +       igt_debug("CRC table:\n");
> +       igt_debug("Color\t\tPrime\t\tDirect\n");
> +       for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +               igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> +                         colors[i].prime_crc.str, colors[i].direct_crc.str);
> +               free(colors[i].prime_crc.str);
> +               free(colors[i].direct_crc.str);
> +       }
> +
> +       for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +               for (j = 0; j < ARRAY_SIZE(colors); j++) {
> +                       if (i == j) {
> +                               igt_assert_crc_equal(&colors[i].prime_crc.crc,
> +                                                    &colors[j].direct_crc.crc);
> +                               continue;
> +                       }
> +                       crc_equal = igt_check_crc_equal(&colors[i].prime_crc.crc,
> +                                                       &colors[j].direct_crc.crc);
> +                       igt_assert_f(!crc_equal, "CRC should be different");
> +               }
> +       }
> +       igt_display_fini(&display);
> +}
> +
> +static void run_test_crc(int export_chipset, int import_chipset)
> +{
> +       int importer = -1;
> +       int exporter = -1;
> +
> +       exporter = drm_open_driver(export_chipset);
> +       importer = drm_open_driver_master(import_chipset);
> +
> +       igt_require(has_prime_export(exporter));
> +       igt_require(has_prime_import(importer));
> +       igt_require_pipe_crc(importer);
> +
> +       test_crc(exporter, importer);
> +       close(importer);
> +       close(exporter);
> +}
> +
> +igt_main
> +{
> +       igt_fixture {
> +               kmstest_set_vt_graphics_mode();
> +       }
> +       igt_subtest("crc")
> +               run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> +}
> --
> 2.22.0
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
                     ` (2 preceding siblings ...)
  2019-08-02 14:38   ` Daniel Vetter
@ 2019-08-16 10:07   ` Ser, Simon
  2019-08-16 10:13     ` Chris Wilson
  2019-08-16 14:21     ` Vasilev, Oleg
  2019-08-16 14:21   ` [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
  4 siblings, 2 replies; 20+ messages in thread
From: Ser, Simon @ 2019-08-16 10:07 UTC (permalink / raw)
  To: Vasilev, Oleg, igt-dev; +Cc: daniel

Hi,

Overall this looks good. Here are a few comments.

I agree with Chris and Daniel regarding naming.

On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> Current, we have different sets of prime tests:
>  - vgem+i915
>  - amdgpu+i915
>  - nouveau+i915
> 
> Those tests use vendor-specific ioctls, therefore, not interchangeable.
> The idea is to create a set of tests which are expected to work on any
> prime-compatible driver. It can be run with any combination of
> exporter+importer, while those devices have respective prime
> capabilities.
> 
> Since vgem can be used as both exporter and importer, and there aren't
> any generic kms features which vgem doesn't support, it is sufficient
> to test DRIVER_ANY+DRIVER_VKMS.
> 
> The first test is simple:
> 1. Exporter creates a dumb FB and fills it with a plain color
> 2. FB is transferred to the importer
> 3. Importer modesets and computes pipe CRC
> 4. Importer draws the same color through cairo and compares CRC
> 
> The initial motivation comes from the need to test prime support in
> vkms.
> 
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
> ---
>  tests/meson.build     |   1 +
>  tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 251 insertions(+)
>  create mode 100644 tests/prime_generic.c
> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 34a74025..1c938e95 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -76,6 +76,7 @@ test_progs = [
>  	'prime_self_import',
>  	'prime_udl',
>  	'prime_vgem',
> +	'prime_generic',
>  	'syncobj_basic',
>  	'syncobj_wait',
>  	'template',
> diff --git a/tests/prime_generic.c b/tests/prime_generic.c
> new file mode 100644
> index 00000000..f273a4f6
> --- /dev/null
> +++ b/tests/prime_generic.c
> @@ -0,0 +1,250 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vgem.h"
> +
> +#include <sys/ioctl.h>
> +#include <sys/poll.h>
> +#include <time.h>
> +
> +struct crc_info {
> +	igt_crc_t crc;
> +	char *str;
> +	const char *name;
> +};
> +
> +static struct {
> +	double r, g, b;
> +	uint32_t color;
> +	struct crc_info prime_crc, direct_crc;
> +} colors[3] = {
> +	{ .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000},
> +	{ .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff},
> +	{ .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000},

Style nit: add spaces before `}` too.

> +};
> +
> +IGT_TEST_DESCRIPTION("Generic tests, working with any prime device");

Maybe make it clear it's about KMS and prime?

> +static bool has_prime_import(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_IMPORT;

This returns a non-zero value when import is supported, but doesn't
return true. This can lead to strange bugs.

It's common to use !! to convert to a bool.

> +}
> +
> +static bool has_prime_export(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_EXPORT;

Ditto

> +}
> +
> +static void setup_display(int importer, igt_display_t *display, igt_output_t **output,

We can return the igt_output_t * instead of using an argument.

It's also probably a good idea to rename importer to e.g. importer_fd,
it's not immediately obvious this variable represents a file
descriptor.

> +			  enum pipe pipe)
> +{
> +	igt_display_require(display, importer);
> +	igt_skip_on(pipe >= display->n_pipes);
> +	*output = igt_get_single_output_for_pipe(display, pipe);
> +	igt_require_f(*output, "No connector found for pipe %s\n",
> +		      kmstest_pipe_name(pipe));
> +
> +	igt_display_reset(display);
> +	igt_output_set_pipe(*output, pipe);
> +}
> +
> +static void prepare_scratch(int exporter, struct vgem_bo *scratch,
> +			    drmModeModeInfo *mode, uint32_t color)
> +{
> +	int i;

Nit: strictly speaking, this should be size_t

> +	uint32_t *ptr;
> +
> +	scratch->width = mode->hdisplay;
> +	scratch->height = mode->vdisplay;
> +	scratch->bpp = 32;
> +	vgem_create(exporter, scratch);

The return value should be checked.

> +	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);

Ditto, we should check that ptr != NULL.

> +	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> +		ptr[i] = color;
> +
> +	munmap(ptr, scratch->size);
> +}
> +
> +static void prepare_fb(int importer, struct vgem_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;
> +
> +	igt_init_fb(fb, importer, scratch->width, scratch->height,
> +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +		    color_encoding, color_range);

Maybe we could populate fb->strides[0] here, so that we don't need to
pass it around in import_fb.

> +}
> +
> +static void import_fb(int importer, struct igt_fb *fb,
> +		      int dmabuf_fd, uint32_t pitch)
> +{
> +	uint32_t offsets[4], pitches[4], handles[4];

It's safer to zero-initialize these.

> +	int ret;
> +
> +	fb->gem_handle = prime_fd_to_handle(importer, dmabuf_fd);
> +
> +	handles[0] = fb->gem_handle;
> +	pitches[0] = pitch;
> +	offsets[0] = 0;
> +
> +	ret = drmModeAddFB2(importer, fb->width, fb->height,
> +			    DRM_FORMAT_XRGB8888,
> +			    handles, pitches, offsets,
> +			    &fb->fb_id, 0);
> +	igt_assert(ret == 0);
> +}
> +
> +static void set_fb(struct igt_fb *fb,
> +		   igt_display_t *display,
> +		   igt_output_t *output)
> +{
> +	igt_plane_t *primary;
> +	int ret;
> +
> +	primary = igt_output_get_plane(output, 0);

This assumes the first plane is a primary one. Actually requesting the
primary plane is safer:

    primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
    igt_assert(primary);

> +	igt_plane_set_fb(primary, fb);
> +	ret = igt_display_commit(display);
> +
> +	igt_assert(ret == 0);
> +}
> +
> +static void collect_crc(int importer, struct igt_fb *fb, igt_display_t *display,
> +			igt_output_t *output, igt_pipe_crc_t *pipe_crc,
> +			uint32_t color, struct crc_info *info)
> +{
> +	set_fb(fb, display, output);
> +	igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
> +	info->str = igt_crc_to_string(&info->crc);
> +	igt_debug("CRC through '%s' method for %#08x is %s\n",
> +		  info->name, color, info->str);
> +	igt_remove_fb(importer, fb);
> +}
> +
> +static void test_crc(int exporter, int importer)
> +{
> +	igt_display_t display;
> +	igt_output_t *output;
> +	igt_pipe_crc_t *pipe_crc;
> +	enum pipe pipe = PIPE_A;
> +	struct igt_fb fb;
> +	int dmabuf_fd;
> +	struct vgem_bo scratch; /* despite the name, it suits for any
> +				 * gem-compatible device
> +				 * TODO: rename
> +				 */

Can we initialize this to zero (= {0})? Since fields are populated
incrementally, it seems a little dangerous to use uninitialized memory.

> +	int i, j;
> +	drmModeModeInfo *mode;
> +
> +	bool crc_equal = false;
> +
> +	setup_display(importer, &display, &output, pipe);
> +
> +	mode = igt_output_get_mode(output);
> +	pipe_crc = igt_pipe_crc_new(importer, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		prepare_scratch(exporter, &scratch, mode, colors[i].color);
> +		dmabuf_fd = prime_handle_to_fd(exporter, scratch.handle);

We should check dmabuf_fd >= 0.

> +		gem_close(exporter, scratch.handle);
> +
> +		prepare_fb(importer, &scratch, &fb);
> +		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);

We should release this FB after we're done.

> +		close(dmabuf_fd);
> +
> +		colors[i].prime_crc.name = "prime";
> +		collect_crc(importer, &fb, &display, output,
> +			    pipe_crc, colors[i].color, &colors[i].prime_crc);
> +
> +		igt_create_color_fb(importer,
> +				    mode->hdisplay, mode->vdisplay,
> +				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +				    colors[i].r, colors[i].g, colors[i].b,
> +				    &fb);

Ditto, we should release this FB after we're done.

> +
> +		colors[i].direct_crc.name = "direct";
> +		collect_crc(importer, &fb, &display, output,
> +			    pipe_crc, colors[i].color, &colors[i].direct_crc);
> +	}
> +	igt_pipe_crc_free(pipe_crc);
> +
> +	igt_debug("CRC table:\n");
> +	igt_debug("Color\t\tPrime\t\tDirect\n");
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> +			  colors[i].prime_crc.str, colors[i].direct_crc.str);
> +		free(colors[i].prime_crc.str);
> +		free(colors[i].direct_crc.str);
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		for (j = 0; j < ARRAY_SIZE(colors); j++) {
> +			if (i == j) {
> +				igt_assert_crc_equal(&colors[i].prime_crc.crc,
> +						     &colors[j].direct_crc.crc);
> +				continue;
> +			}
> +			crc_equal = igt_check_crc_equal(&colors[i].prime_crc.crc,
> +							&colors[j].direct_crc.crc);
> +			igt_assert_f(!crc_equal, "CRC should be different");
> +		}
> +	}
> +	igt_display_fini(&display);
> +}
> +
> +static void run_test_crc(int export_chipset, int import_chipset)
> +{
> +	int importer = -1;
> +	int exporter = -1;
> +
> +	exporter = drm_open_driver(export_chipset);
> +	importer = drm_open_driver_master(import_chipset);
> +
> +	igt_require(has_prime_export(exporter));
> +	igt_require(has_prime_import(importer));
> +	igt_require_pipe_crc(importer);
> +
> +	test_crc(exporter, importer);
> +	close(importer);
> +	close(exporter);
> +}
> +
> +igt_main
> +{
> +	igt_fixture {
> +		kmstest_set_vt_graphics_mode();

Is this really needed?

> +	}
> +	igt_subtest("crc")

Please add a subtest description. See:
https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Core.html#igt-describe

> +		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> +}
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-08-16 10:07   ` Ser, Simon
@ 2019-08-16 10:13     ` Chris Wilson
  2019-08-16 10:35       ` Ser, Simon
  2019-08-16 14:21     ` Vasilev, Oleg
  1 sibling, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-08-16 10:13 UTC (permalink / raw)
  To: Ser, Simon, Vasilev, Oleg, igt-dev; +Cc: daniel

Quoting Ser, Simon (2019-08-16 11:07:56)
> On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> > +static bool has_prime_import(int fd)
> > +{
> > +     uint64_t value;
> > +
> > +     if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> > +             return false;
> > +
> > +     return value & DRM_PRIME_CAP_IMPORT;
> 
> This returns a non-zero value when import is supported, but doesn't
> return true. This can lead to strange bugs.
> 
> It's common to use !! to convert to a bool.

But not required when embracing stdbool as it defined in the spec for
the implicit cast.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-08-16 10:13     ` Chris Wilson
@ 2019-08-16 10:35       ` Ser, Simon
  0 siblings, 0 replies; 20+ messages in thread
From: Ser, Simon @ 2019-08-16 10:35 UTC (permalink / raw)
  To: Vasilev, Oleg, igt-dev, chris; +Cc: daniel

On Fri, 2019-08-16 at 11:13 +0100, Chris Wilson wrote:
> Quoting Ser, Simon (2019-08-16 11:07:56)
> > On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> > > +static bool has_prime_import(int fd)
> > > +{
> > > +     uint64_t value;
> > > +
> > > +     if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> > > +             return false;
> > > +
> > > +     return value & DRM_PRIME_CAP_IMPORT;
> > 
> > This returns a non-zero value when import is supported, but doesn't
> > return true. This can lead to strange bugs.
> > 
> > It's common to use !! to convert to a bool.
> 
> But not required when embracing stdbool as it defined in the spec for
> the implicit cast.

Oh, indeed, I didn't know! Thanks for the heads-up.
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH 1/2] lib: expose fb_init
  2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
                     ` (3 preceding siblings ...)
  2019-08-16 10:07   ` Ser, Simon
@ 2019-08-16 14:21   ` Oleg Vasilev
  2019-08-16 14:21     ` [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests Oleg Vasilev
  4 siblings, 1 reply; 20+ messages in thread
From: Oleg Vasilev @ 2019-08-16 14:21 UTC (permalink / raw)
  To: igt-dev; +Cc: Simon Ser

Make it public.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Simon Ser <daniel@ffwll.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
---
 lib/igt_fb.c | 38 ++++++++++++++++++--------------------
 lib/igt_fb.h |  4 ++++
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 5dc74a00..bad3eeca 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -485,12 +485,10 @@ static int fb_num_planes(const struct igt_fb *fb)
 		return format->num_planes;
 }
 
-static void fb_init(struct igt_fb *fb,
-		    int fd, int width, int height,
-		    uint32_t drm_format,
-		    uint64_t modifier,
-		    enum igt_color_encoding color_encoding,
-		    enum igt_color_range color_range)
+void igt_init_fb(struct igt_fb *fb, int fd, int width, int height,
+		 uint32_t drm_format, uint64_t modifier,
+		 enum igt_color_encoding color_encoding,
+		 enum igt_color_range color_range)
 {
 	const struct format_desc_struct *f = lookup_drm_format(drm_format);
 
@@ -627,8 +625,8 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64
 {
 	struct igt_fb fb;
 
-	fb_init(&fb, fd, width, height, drm_format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(&fb, fd, width, height, drm_format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	fb.size = calc_fb_size(&fb);
 
@@ -855,8 +853,8 @@ void igt_create_bo_for_fb(int fd, int width, int height,
 			  uint32_t format, uint64_t modifier,
 			  struct igt_fb *fb /* out */)
 {
-	fb_init(fb, fd, width, height, format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(fb, fd, width, height, format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 	create_bo_for_fb(fb);
 }
 
@@ -885,8 +883,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height,
 {
 	struct igt_fb fb;
 
-	fb_init(&fb, fd, width, height, format, modifier,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(&fb, fd, width, height, format, modifier,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	for (int i = 0; i < fb.num_planes; i++)
 		fb.strides[i] = stride;
@@ -1441,8 +1439,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
 {
 	uint32_t flags = 0;
 
-	fb_init(fb, fd, width, height, format, modifier,
-		color_encoding, color_range);
+	igt_init_fb(fb, fd, width, height, format, modifier,
+		    color_encoding, color_range);
 
 	for (int i = 0; i < fb->num_planes; i++)
 		fb->strides[i] = bo_stride;
@@ -1974,9 +1972,9 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
 	 * destination, tiling it at the same time.
 	 */
 
-	fb_init(&linear->fb, fb->fd, fb->width, fb->height,
-		fb->drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
-		fb->color_encoding, fb->color_range);
+	igt_init_fb(&linear->fb, fb->fd, fb->width, fb->height,
+		    fb->drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
+		    fb->color_encoding, fb->color_range);
 
 	create_bo_for_fb(&linear->fb);
 
@@ -2130,9 +2128,9 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 
 	igt_assert(shadow);
 
-	fb_init(shadow, fd, width, height,
-		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
-		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
+	igt_init_fb(shadow, fd, width, height,
+		    drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
+		    IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * (shadow->plane_bpp[0] / 8), 16);
 	shadow->size = ALIGN((uint64_t)shadow->strides[0] * height,
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index e19cc5d4..69132b41 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -117,6 +117,10 @@ void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
 			  unsigned *width_ret, unsigned *height_ret);
 void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t modifier,
 		      uint64_t *size_ret, unsigned *stride_ret);
+void igt_init_fb(struct igt_fb *fb, int fd, int width, int height,
+		 uint32_t drm_format, uint64_t modifier,
+		 enum igt_color_encoding color_encoding,
+		 enum igt_color_range color_range);
 unsigned int
 igt_create_fb_with_bo_size(int fd, int width, int height,
 			   uint32_t format, uint64_t modifier,
-- 
2.22.0

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

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

* [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests
  2019-08-16 14:21   ` [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
@ 2019-08-16 14:21     ` Oleg Vasilev
  2019-08-19  9:50       ` Ser, Simon
  0 siblings, 1 reply; 20+ messages in thread
From: Oleg Vasilev @ 2019-08-16 14:21 UTC (permalink / raw)
  To: igt-dev; +Cc: Daniel Vetter

Currently, there are different sets of prime tests:
 - vgem + i915
 - amdgpu + i915
 - nouveau + i915

The idea is to create a set of tests which are expected to work on any
prime-compatible driver. It can be run with any combination of
exporter + importer, while those devices have respective prime
capabilities. In order to be vendor-agnostic, tests should use generic
KMS API.

Since vgem can be used as both exporter and importer, and there aren't
any generic kms features which vgem doesn't support, it is sufficient
to test vgem as exporter with any other KMS driver.

The first test is simple:
1. Exporter creates a dumb FB and fills it with a plain color
2. FB is transferred to the importer
3. Importer modesets and computes pipe CRC
4. Importer draws the same color through cairo and compares CRC

The initial motivation comes from the need to test prime support in
vkms.

V2:
 - Chris: rename the file
 - Simon: memory hygiene, codestyle

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Simon Ser <daniel@ffwll.ch>
Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>
---
 tests/kms_prime.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |   1 +
 2 files changed, 255 insertions(+)
 create mode 100644 tests/kms_prime.c

diff --git a/tests/kms_prime.c b/tests/kms_prime.c
new file mode 100644
index 00000000..17599573
--- /dev/null
+++ b/tests/kms_prime.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_vgem.h"
+
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <time.h>
+
+struct crc_info {
+	igt_crc_t crc;
+	char *str;
+	const char *name;
+};
+
+static struct {
+	double r, g, b;
+	uint32_t color;
+	struct crc_info prime_crc, direct_crc;
+} colors[3] = {
+	{ .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000 },
+	{ .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff },
+	{ .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000 },
+};
+
+IGT_TEST_DESCRIPTION("Prime tests, focusing on KMS side");
+
+static bool has_prime_import(int fd)
+{
+	uint64_t value;
+
+	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
+		return false;
+
+	return value & DRM_PRIME_CAP_IMPORT;
+}
+
+static bool has_prime_export(int fd)
+{
+	uint64_t value;
+
+	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
+		return false;
+
+	return value & DRM_PRIME_CAP_EXPORT;
+}
+
+static igt_output_t *setup_display(int importer_fd, igt_display_t *display,
+				   enum pipe pipe)
+{
+	igt_display_require(display, importer_fd);
+	igt_skip_on(pipe >= display->n_pipes);
+	igt_output_t *output = igt_get_single_output_for_pipe(display, pipe);
+
+	igt_require_f(output, "No connector found for pipe %s\n",
+		      kmstest_pipe_name(pipe));
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+	return output;
+}
+
+static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
+			    drmModeModeInfo *mode, uint32_t color)
+{
+	uint32_t *ptr;
+
+	scratch->width = mode->hdisplay;
+	scratch->height = mode->vdisplay;
+	scratch->bpp = 32;
+	vgem_create(exporter_fd, scratch);
+
+	ptr = vgem_mmap(exporter_fd, scratch, 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)
+{
+	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
+
+	igt_init_fb(fb, importer_fd, scratch->width, scratch->height,
+		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+		    color_encoding, color_range);
+}
+
+static void import_fb(int importer_fd, struct igt_fb *fb,
+		      int dmabuf_fd, uint32_t pitch)
+{
+	uint32_t offsets[4] = {}, pitches[4] = {}, handles[4] = {};
+	int ret;
+
+	fb->gem_handle = prime_fd_to_handle(importer_fd, dmabuf_fd);
+
+	handles[0] = fb->gem_handle;
+	pitches[0] = pitch;
+	offsets[0] = 0;
+
+	ret = drmModeAddFB2(importer_fd, fb->width, fb->height,
+			    DRM_FORMAT_XRGB8888,
+			    handles, pitches, offsets,
+			    &fb->fb_id, 0);
+	igt_assert(ret == 0);
+}
+
+static void set_fb(struct igt_fb *fb,
+		   igt_display_t *display,
+		   igt_output_t *output)
+{
+	igt_plane_t *primary;
+	int ret;
+
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary);
+
+	igt_plane_set_fb(primary, fb);
+	ret = igt_display_commit(display);
+
+	igt_assert(ret == 0);
+}
+
+static void collect_crc_for_fb(int importer_fd, struct igt_fb *fb, igt_display_t *display,
+			       igt_output_t *output, igt_pipe_crc_t *pipe_crc,
+			       uint32_t color, struct crc_info *info)
+{
+	set_fb(fb, display, output);
+	igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
+	info->str = igt_crc_to_string(&info->crc);
+	igt_debug("CRC through '%s' method for %#08x is %s\n",
+		  info->name, color, info->str);
+	igt_remove_fb(importer_fd, fb);
+}
+
+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;
+	struct igt_fb fb;
+	int dmabuf_fd;
+	struct vgem_bo scratch = {}; /* despite the name, it suits for any
+				      * gem-compatible device
+				      * TODO: rename
+				      */
+	int i, j;
+	drmModeModeInfo *mode;
+
+	bool crc_equal = false;
+
+	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);
+
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		prepare_scratch(exporter_fd, &scratch, mode, colors[i].color);
+		dmabuf_fd = prime_handle_to_fd(exporter_fd, scratch.handle);
+		gem_close(exporter_fd, scratch.handle);
+
+		prepare_fb(importer_fd, &scratch, &fb);
+		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);
+
+		igt_create_color_fb(importer_fd,
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    colors[i].r, colors[i].g, colors[i].b,
+				    &fb);
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc_for_fb(importer_fd, &fb, &display, output,
+				   pipe_crc, colors[i].color, &colors[i].direct_crc);
+	}
+	igt_pipe_crc_free(pipe_crc);
+
+	igt_debug("CRC table:\n");
+	igt_debug("Color\t\tPrime\t\tDirect\n");
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
+			  colors[i].prime_crc.str, colors[i].direct_crc.str);
+		free(colors[i].prime_crc.str);
+		free(colors[i].direct_crc.str);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		for (j = 0; j < ARRAY_SIZE(colors); j++) {
+			if (i == j) {
+				igt_assert_crc_equal(&colors[i].prime_crc.crc,
+						     &colors[j].direct_crc.crc);
+				continue;
+			}
+			crc_equal = igt_check_crc_equal(&colors[i].prime_crc.crc,
+							&colors[j].direct_crc.crc);
+			igt_assert_f(!crc_equal, "CRC should be different");
+		}
+	}
+	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 {
+		kmstest_set_vt_graphics_mode();
+	}
+	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);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 34a74025..201d72e0 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -48,6 +48,7 @@ test_progs = [
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
+	'kms_prime',
 	'kms_prop_blob',
 	'kms_properties',
 	'kms_psr',
-- 
2.22.0

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

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-08-16 10:07   ` Ser, Simon
  2019-08-16 10:13     ` Chris Wilson
@ 2019-08-16 14:21     ` Vasilev, Oleg
  2019-08-16 14:33       ` Ser, Simon
  1 sibling, 1 reply; 20+ messages in thread
From: Vasilev, Oleg @ 2019-08-16 14:21 UTC (permalink / raw)
  To: igt-dev, Ser, Simon; +Cc: daniel


[-- Attachment #1.1: Type: text/plain, Size: 3747 bytes --]

On Fri, 2019-08-16 at 11:07 +0100, Ser, Simon wrote:
> Hi,
> 
> Overall this looks good. Here are a few comments.
> 
> I agree with Chris and Daniel regarding naming.
> 
> On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> > +static bool has_prime_import(int fd)
> > +{
> > +	uint64_t value;
> > +
> > +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> > +		return false;
> > +
> > +	return value & DRM_PRIME_CAP_IMPORT;
> 
> This returns a non-zero value when import is supported, but doesn't
> return true. This can lead to strange bugs.
> 
> It's common to use !! to convert to a bool.

Hi,

As discussed, this should be still a valid stdbool.

> > +	vgem_create(exporter, scratch);
> 
> The return value should be checked.

Actually, it is already checked inside the function. AFAIU, in IGT
helpers usually call their __underscored siblings and assert return
value.
 
> 
> > +	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
> 
> Ditto, we should check that ptr != NULL.

Same.

> 
> > +	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> > +		ptr[i] = color;
> > +
> > +	munmap(ptr, scratch->size);
> > +}
> > +
> > +static void prepare_fb(int importer, struct vgem_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;
> > +
> > +	igt_init_fb(fb, importer, scratch->width, scratch->height,
> > +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> > +		    color_encoding, color_range);
> 
> Maybe we could populate fb->strides[0] here, so that we don't need to
> pass it around in import_fb.
> 
> > +}
> > 
> > +		dmabuf_fd = prime_handle_to_fd(exporter,
> > scratch.handle);
> 
> We should check dmabuf_fd >= 0.

Same, it is asserted internally.

> > +		gem_close(exporter, scratch.handle);
> > +
> > +		prepare_fb(importer, &scratch, &fb);
> > +		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
> 
> We should release this FB after we're done.

You mean remove fb? It is done in collect_crc, which I renamed to
collect_crc_for_fb to make it more clear.

> > +		close(dmabuf_fd);
> > +
> > +		colors[i].prime_crc.name = "prime";
> > +		collect_crc(importer, &fb, &display, output,
> > +			    pipe_crc, colors[i].color,
> > &colors[i].prime_crc);
> > +
> > +		igt_create_color_fb(importer,
> > +				    mode->hdisplay, mode->vdisplay,
> > +				    DRM_FORMAT_XRGB8888,
> > LOCAL_DRM_FORMAT_MOD_NONE,
> > +				    colors[i].r, colors[i].g,
> > colors[i].b,
> > +				    &fb);
> 
> Ditto, we should release this FB after we're done.

Same

> 
> > +
> > +		colors[i].direct_crc.name = "direct";
> > +		collect_crc(importer, &fb, &display, output,
> > +			    pipe_crc, colors[i].color,
> > &colors[i].direct_crc);
> > +	}
> > +	igt_pipe_crc_free(pipe_crc);
> > +
> > +	igt_debug("CRC table:\n");
> > +	igt_debug("Color\t\tPrime\t\tDirect\n");
> > +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> > +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> > +			  colors[i].prime_crc.str,
> > colors[i].direct_crc.str);
> > +		free(colors[i].prime_crc.str);
> > +		free(colors[i].direct_crc.str);
> > +	}
...
> > +
> > +igt_main
> > +{
> > +	igt_fixture {
> > +		kmstest_set_vt_graphics_mode();
> 
> Is this really needed?

Yeah, it is necessary for every KMS test.

The rest is fixed, thanks for the review. New version is sent.

Oleg

> 
> > +	}
> > +	igt_subtest("crc")
> 
> Please add a subtest description. See:
> https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Core.html#igt-describe
> 
> > +		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> > +}

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3261 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

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

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-08-16 14:21     ` Vasilev, Oleg
@ 2019-08-16 14:33       ` Ser, Simon
  2019-08-16 14:39         ` Ser, Simon
  0 siblings, 1 reply; 20+ messages in thread
From: Ser, Simon @ 2019-08-16 14:33 UTC (permalink / raw)
  To: Vasilev, Oleg, igt-dev; +Cc: daniel

On Fri, 2019-08-16 at 15:21 +0100, Vasilev, Oleg wrote:
> On Fri, 2019-08-16 at 11:07 +0100, Ser, Simon wrote:
> > Hi,
> > 
> > Overall this looks good. Here are a few comments.
> > 
> > I agree with Chris and Daniel regarding naming.
> > 
> > On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> > > +static bool has_prime_import(int fd)
> > > +{
> > > +	uint64_t value;
> > > +
> > > +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> > > +		return false;
> > > +
> > > +	return value & DRM_PRIME_CAP_IMPORT;
> > 
> > This returns a non-zero value when import is supported, but doesn't
> > return true. This can lead to strange bugs.
> > 
> > It's common to use !! to convert to a bool.
> 
> Hi,
> 
> As discussed, this should be still a valid stdbool.
> 
> > > +	vgem_create(exporter, scratch);
> > 
> > The return value should be checked.
> 
> Actually, it is already checked inside the function. AFAIU, in IGT
> helpers usually call their __underscored siblings and assert return
> value.

Looking at the source code, nope:

    if (drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg))
        return -errno;

> > > +	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
> > 
> > Ditto, we should check that ptr != NULL.
> 
> Same.

Ditto

> > > +	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> > > +		ptr[i] = color;
> > > +
> > > +	munmap(ptr, scratch->size);
> > > +}
> > > +
> > > +static void prepare_fb(int importer, struct vgem_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;
> > > +
> > > +	igt_init_fb(fb, importer, scratch->width, scratch->height,
> > > +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> > > +		    color_encoding, color_range);
> > 
> > Maybe we could populate fb->strides[0] here, so that we don't need to
> > pass it around in import_fb.
> > 
> > > +}
> > > 
> > > +		dmabuf_fd = prime_handle_to_fd(exporter,
> > > scratch.handle);
> > 
> > We should check dmabuf_fd >= 0.
> 
> Same, it is asserted internally.

This one is checked, indeed.

> > > +		gem_close(exporter, scratch.handle);
> > > +
> > > +		prepare_fb(importer, &scratch, &fb);
> > > +		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
> > 
> > We should release this FB after we're done.
> 
> You mean remove fb? It is done in collect_crc, which I renamed to
> collect_crc_for_fb to make it more clear.

Ah, right.

> > > +		close(dmabuf_fd);
> > > +
> > > +		colors[i].prime_crc.name = "prime";
> > > +		collect_crc(importer, &fb, &display, output,
> > > +			    pipe_crc, colors[i].color,
> > > &colors[i].prime_crc);
> > > +
> > > +		igt_create_color_fb(importer,
> > > +				    mode->hdisplay, mode->vdisplay,
> > > +				    DRM_FORMAT_XRGB8888,
> > > LOCAL_DRM_FORMAT_MOD_NONE,
> > > +				    colors[i].r, colors[i].g,
> > > colors[i].b,
> > > +				    &fb);
> > 
> > Ditto, we should release this FB after we're done.
> 
> Same
> 
> > > +
> > > +		colors[i].direct_crc.name = "direct";
> > > +		collect_crc(importer, &fb, &display, output,
> > > +			    pipe_crc, colors[i].color,
> > > &colors[i].direct_crc);
> > > +	}
> > > +	igt_pipe_crc_free(pipe_crc);
> > > +
> > > +	igt_debug("CRC table:\n");
> > > +	igt_debug("Color\t\tPrime\t\tDirect\n");
> > > +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> > > +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> > > +			  colors[i].prime_crc.str,
> > > colors[i].direct_crc.str);
> > > +		free(colors[i].prime_crc.str);
> > > +		free(colors[i].direct_crc.str);
> > > +	}
> ...
> > > +
> > > +igt_main
> > > +{
> > > +	igt_fixture {
> > > +		kmstest_set_vt_graphics_mode();
> > 
> > Is this really needed?
> 
> Yeah, it is necessary for every KMS test.

Oh, right, the function documentation is helpful.

> The rest is fixed, thanks for the review. New version is sent.

Thanks!

> Oleg
> 
> > > +	}
> > > +	igt_subtest("crc")
> > 
> > Please add a subtest description. See:
> > https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Core.html#igt-describe
> > 
> > > +		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> > > +}
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests
  2019-08-16 14:33       ` Ser, Simon
@ 2019-08-16 14:39         ` Ser, Simon
  0 siblings, 0 replies; 20+ messages in thread
From: Ser, Simon @ 2019-08-16 14:39 UTC (permalink / raw)
  To: Vasilev, Oleg, igt-dev; +Cc: daniel

On Fri, 2019-08-16 at 14:33 +0000, Ser, Simon wrote:
> On Fri, 2019-08-16 at 15:21 +0100, Vasilev, Oleg wrote:
> > On Fri, 2019-08-16 at 11:07 +0100, Ser, Simon wrote:
> > > Hi,
> > > 
> > > Overall this looks good. Here are a few comments.
> > > 
> > > I agree with Chris and Daniel regarding naming.
> > > 
> > > On Fri, 2019-07-12 at 17:16 +0300, Oleg Vasilev wrote:
> > > > +static bool has_prime_import(int fd)
> > > > +{
> > > > +	uint64_t value;
> > > > +
> > > > +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> > > > +		return false;
> > > > +
> > > > +	return value & DRM_PRIME_CAP_IMPORT;
> > > 
> > > This returns a non-zero value when import is supported, but doesn't
> > > return true. This can lead to strange bugs.
> > > 
> > > It's common to use !! to convert to a bool.
> > 
> > Hi,
> > 
> > As discussed, this should be still a valid stdbool.
> > 
> > > > +	vgem_create(exporter, scratch);
> > > 
> > > The return value should be checked.
> > 
> > Actually, it is already checked inside the function. AFAIU, in IGT
> > helpers usually call their __underscored siblings and assert return
> > value.
> 
> Looking at the source code, nope:
> 
>     if (drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg))
>         return -errno;

Bleh, I read too fast, and mixed everything up. You are right.

> > > > +	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);
> > > 
> > > Ditto, we should check that ptr != NULL.
> > 
> > Same.
> 
> Ditto

Same!

> > > > +	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
> > > > +		ptr[i] = color;
> > > > +
> > > > +	munmap(ptr, scratch->size);
> > > > +}
> > > > +
> > > > +static void prepare_fb(int importer, struct vgem_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;
> > > > +
> > > > +	igt_init_fb(fb, importer, scratch->width, scratch->height,
> > > > +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> > > > +		    color_encoding, color_range);
> > > 
> > > Maybe we could populate fb->strides[0] here, so that we don't need to
> > > pass it around in import_fb.
> > > 
> > > > +}
> > > > 
> > > > +		dmabuf_fd = prime_handle_to_fd(exporter,
> > > > scratch.handle);
> > > 
> > > We should check dmabuf_fd >= 0.
> > 
> > Same, it is asserted internally.
> 
> This one is checked, indeed.
> 
> > > > +		gem_close(exporter, scratch.handle);
> > > > +
> > > > +		prepare_fb(importer, &scratch, &fb);
> > > > +		import_fb(importer, &fb, dmabuf_fd, scratch.pitch);
> > > 
> > > We should release this FB after we're done.
> > 
> > You mean remove fb? It is done in collect_crc, which I renamed to
> > collect_crc_for_fb to make it more clear.
> 
> Ah, right.
> 
> > > > +		close(dmabuf_fd);
> > > > +
> > > > +		colors[i].prime_crc.name = "prime";
> > > > +		collect_crc(importer, &fb, &display, output,
> > > > +			    pipe_crc, colors[i].color,
> > > > &colors[i].prime_crc);
> > > > +
> > > > +		igt_create_color_fb(importer,
> > > > +				    mode->hdisplay, mode->vdisplay,
> > > > +				    DRM_FORMAT_XRGB8888,
> > > > LOCAL_DRM_FORMAT_MOD_NONE,
> > > > +				    colors[i].r, colors[i].g,
> > > > colors[i].b,
> > > > +				    &fb);
> > > 
> > > Ditto, we should release this FB after we're done.
> > 
> > Same
> > 
> > > > +
> > > > +		colors[i].direct_crc.name = "direct";
> > > > +		collect_crc(importer, &fb, &display, output,
> > > > +			    pipe_crc, colors[i].color,
> > > > &colors[i].direct_crc);
> > > > +	}
> > > > +	igt_pipe_crc_free(pipe_crc);
> > > > +
> > > > +	igt_debug("CRC table:\n");
> > > > +	igt_debug("Color\t\tPrime\t\tDirect\n");
> > > > +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> > > > +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> > > > +			  colors[i].prime_crc.str,
> > > > colors[i].direct_crc.str);
> > > > +		free(colors[i].prime_crc.str);
> > > > +		free(colors[i].direct_crc.str);
> > > > +	}
> > ...
> > > > +
> > > > +igt_main
> > > > +{
> > > > +	igt_fixture {
> > > > +		kmstest_set_vt_graphics_mode();
> > > 
> > > Is this really needed?
> > 
> > Yeah, it is necessary for every KMS test.
> 
> Oh, right, the function documentation is helpful.
> 
> > The rest is fixed, thanks for the review. New version is sent.
> 
> Thanks!
> 
> > Oleg
> > 
> > > > +	}
> > > > +	igt_subtest("crc")
> > > 
> > > Please add a subtest description. See:
> > > https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Core.html#igt-describe
> > > 
> > > > +		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
> > > > +}
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init (rev3)
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
                   ` (3 preceding siblings ...)
  2019-07-14  4:16 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
@ 2019-08-16 14:56 ` Patchwork
  2019-08-16 15:02 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
  2019-08-17  6:57 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-16 14:56 UTC (permalink / raw)
  To: Vasilev, Oleg; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init (rev3)
URL   : https://patchwork.freedesktop.org/series/63653/
State : warning

== Summary ==

Pipeline status: FAILED.

See https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/56859 for more details.

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/56859
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init (rev3)
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
                   ` (4 preceding siblings ...)
  2019-08-16 14:56 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init (rev3) Patchwork
@ 2019-08-16 15:02 ` Patchwork
  2019-08-17  6:57 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-16 15:02 UTC (permalink / raw)
  To: Vasilev, Oleg; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init (rev3)
URL   : https://patchwork.freedesktop.org/series/63653/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6718 -> IGTPW_3358
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/63653/revisions/3/mbox/

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

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

### IGT changes ###

#### Issues hit ####

  * igt@gem_cpu_reloc@basic:
    - fi-icl-u3:          [PASS][1] -> [DMESG-WARN][2] ([fdo#107724])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/fi-icl-u3/igt@gem_cpu_reloc@basic.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/fi-icl-u3/igt@gem_cpu_reloc@basic.html

  * igt@gem_ctx_switch@legacy-render:
    - fi-cml-u2:          [PASS][3] -> [INCOMPLETE][4] ([fdo#110566])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/fi-cml-u2/igt@gem_ctx_switch@legacy-render.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/fi-cml-u2/igt@gem_ctx_switch@legacy-render.html

  
#### Possible fixes ####

  * igt@i915_selftest@live_execlists:
    - fi-skl-gvtdvm:      [DMESG-FAIL][5] ([fdo#111108]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/fi-skl-gvtdvm/igt@i915_selftest@live_execlists.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/fi-skl-gvtdvm/igt@i915_selftest@live_execlists.html

  
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#110566]: https://bugs.freedesktop.org/show_bug.cgi?id=110566
  [fdo#111108]: https://bugs.freedesktop.org/show_bug.cgi?id=111108


Participating hosts (54 -> 46)
------------------------------

  Missing    (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


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

  * CI: CI-20190529 -> None
  * IGT: IGT_5138 -> IGTPW_3358

  CI-20190529: 20190529
  CI_DRM_6718: b6d542cb2fbbc69487b1e83634395439a8fafa94 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_3358: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/
  IGT_5138: b9abe0bf6c478c4f6cac56bff286d6926ad8c0ab @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@kms_prime@basic-crc

== Logs ==

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

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

* [igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] lib: expose fb_init (rev3)
  2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
                   ` (5 preceding siblings ...)
  2019-08-16 15:02 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
@ 2019-08-17  6:57 ` Patchwork
  6 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-17  6:57 UTC (permalink / raw)
  To: Vasilev, Oleg; +Cc: igt-dev

== Series Details ==

Series: series starting with [1/2] lib: expose fb_init (rev3)
URL   : https://patchwork.freedesktop.org/series/63653/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6718_full -> IGTPW_3358_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/63653/revisions/3/mbox/

New tests
---------

  New tests have been introduced between CI_DRM_6718_full and IGTPW_3358_full:

### New IGT tests (1) ###

  * igt@kms_prime@basic-crc:
    - Statuses : 6 pass(s)
    - Exec time: [0.79, 1.28] s

  

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

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

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_blt@cold-max:
    - shard-apl:          [PASS][1] -> [INCOMPLETE][2] ([fdo#103927]) +2 similar issues
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-apl1/igt@gem_exec_blt@cold-max.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl5/igt@gem_exec_blt@cold-max.html

  * igt@gem_exec_schedule@preempt-bsd1:
    - shard-iclb:         [PASS][3] -> [SKIP][4] ([fdo#109276]) +19 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb1/igt@gem_exec_schedule@preempt-bsd1.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb5/igt@gem_exec_schedule@preempt-bsd1.html

  * igt@gem_exec_schedule@preemptive-hang-bsd:
    - shard-iclb:         [PASS][5] -> [SKIP][6] ([fdo#111325]) +1 similar issue
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb8/igt@gem_exec_schedule@preemptive-hang-bsd.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@gem_exec_schedule@preemptive-hang-bsd.html

  * igt@i915_pm_rc6_residency@rc6-accuracy:
    - shard-snb:          [PASS][7] -> [SKIP][8] ([fdo#109271])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-snb4/igt@i915_pm_rc6_residency@rc6-accuracy.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-snb1/igt@i915_pm_rc6_residency@rc6-accuracy.html

  * igt@i915_suspend@fence-restore-tiled2untiled:
    - shard-apl:          [PASS][9] -> [DMESG-WARN][10] ([fdo#108566]) +2 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-apl7/igt@i915_suspend@fence-restore-tiled2untiled.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl3/igt@i915_suspend@fence-restore-tiled2untiled.html

  * igt@kms_atomic_interruptible@legacy-setmode:
    - shard-iclb:         [PASS][11] -> [INCOMPLETE][12] ([fdo#107713])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb8/igt@kms_atomic_interruptible@legacy-setmode.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb7/igt@kms_atomic_interruptible@legacy-setmode.html

  * igt@kms_cursor_legacy@cursor-vs-flip-atomic:
    - shard-hsw:          [PASS][13] -> [FAIL][14] ([fdo#103355])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-hsw5/igt@kms_cursor_legacy@cursor-vs-flip-atomic.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-hsw4/igt@kms_cursor_legacy@cursor-vs-flip-atomic.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-glk:          [PASS][15] -> [FAIL][16] ([fdo#105363])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-glk2/igt@kms_flip@flip-vs-expired-vblank.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-glk9/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_frontbuffer_tracking@fbc-stridechange:
    - shard-iclb:         [PASS][17] -> [FAIL][18] ([fdo#103167]) +2 similar issues
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb8/igt@kms_frontbuffer_tracking@fbc-stridechange.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb7/igt@kms_frontbuffer_tracking@fbc-stridechange.html

  * igt@kms_psr@psr2_sprite_mmap_gtt:
    - shard-iclb:         [PASS][19] -> [SKIP][20] ([fdo#109441]) +1 similar issue
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb7/igt@kms_psr@psr2_sprite_mmap_gtt.html

  
#### Possible fixes ####

  * igt@gem_ctx_shared@exec-single-timeline-bsd:
    - shard-iclb:         [SKIP][21] ([fdo#110841]) -> [PASS][22]
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb4/igt@gem_ctx_shared@exec-single-timeline-bsd.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb3/igt@gem_ctx_shared@exec-single-timeline-bsd.html

  * igt@gem_exec_schedule@independent-bsd:
    - shard-iclb:         [SKIP][23] ([fdo#111325]) -> [PASS][24] +3 similar issues
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb1/igt@gem_exec_schedule@independent-bsd.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb8/igt@gem_exec_schedule@independent-bsd.html

  * igt@gem_exec_schedule@preempt-other-bsd1:
    - shard-iclb:         [SKIP][25] ([fdo#109276]) -> [PASS][26] +16 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb8/igt@gem_exec_schedule@preempt-other-bsd1.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@gem_exec_schedule@preempt-other-bsd1.html

  * igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy:
    - shard-hsw:          [FAIL][27] ([fdo#105767]) -> [PASS][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-hsw4/igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-hsw5/igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy.html

  * igt@kms_flip@flip-vs-suspend-interruptible:
    - shard-glk:          [INCOMPLETE][29] ([fdo#103359] / [k.org#198133]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-glk2/igt@kms_flip@flip-vs-suspend-interruptible.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-glk6/igt@kms_flip@flip-vs-suspend-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-move:
    - shard-iclb:         [FAIL][31] ([fdo#103167]) -> [PASS][32] +4 similar issues
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-move.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-move.html

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-render:
    - shard-glk:          [FAIL][33] ([fdo#103167]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-glk6/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-render.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-glk1/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-render.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-iclb:         [FAIL][35] ([fdo#103166]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb1/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb3/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr2_su@page_flip:
    - shard-iclb:         [SKIP][37] ([fdo#109642] / [fdo#111068]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb3/igt@kms_psr2_su@page_flip.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@kms_psr2_su@page_flip.html

  * igt@kms_psr@psr2_cursor_mmap_cpu:
    - shard-iclb:         [SKIP][39] ([fdo#109441]) -> [PASS][40] +1 similar issue
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb5/igt@kms_psr@psr2_cursor_mmap_cpu.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html

  * igt@kms_setmode@basic:
    - shard-kbl:          [FAIL][41] ([fdo#99912]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-kbl4/igt@kms_setmode@basic.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-kbl2/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-c-ts-continuation-suspend:
    - shard-apl:          [DMESG-WARN][43] ([fdo#108566]) -> [PASS][44] +2 similar issues
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-apl7/igt@kms_vblank@pipe-c-ts-continuation-suspend.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl3/igt@kms_vblank@pipe-c-ts-continuation-suspend.html

  
#### Warnings ####

  * igt@gem_mocs_settings@mocs-reset-bsd2:
    - shard-iclb:         [SKIP][45] ([fdo#109276]) -> [FAIL][46] ([fdo#111330]) +1 similar issue
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6718/shard-iclb3/igt@gem_mocs_settings@mocs-reset-bsd2.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@gem_mocs_settings@mocs-reset-bsd2.html

  
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [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
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
  [fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (10 -> 6)
------------------------------

  Missing    (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005 


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

  * CI: CI-20190529 -> None
  * IGT: IGT_5138 -> IGTPW_3358
  * Piglit: piglit_4509 -> None

  CI-20190529: 20190529
  CI_DRM_6718: b6d542cb2fbbc69487b1e83634395439a8fafa94 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_3358: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/
  IGT_5138: b9abe0bf6c478c4f6cac56bff286d6926ad8c0ab @ 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_3358/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests
  2019-08-16 14:21     ` [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests Oleg Vasilev
@ 2019-08-19  9:50       ` Ser, Simon
  0 siblings, 0 replies; 20+ messages in thread
From: Ser, Simon @ 2019-08-19  9:50 UTC (permalink / raw)
  To: Vasilev, Oleg, igt-dev; +Cc: daniel

On Fri, 2019-08-16 at 17:21 +0300, Oleg Vasilev wrote:
> Currently, there are different sets of prime tests:
>  - vgem + i915
>  - amdgpu + i915
>  - nouveau + i915
> 
> The idea is to create a set of tests which are expected to work on any
> prime-compatible driver. It can be run with any combination of
> exporter + importer, while those devices have respective prime
> capabilities. In order to be vendor-agnostic, tests should use generic
> KMS API.
> 
> Since vgem can be used as both exporter and importer, and there aren't
> any generic kms features which vgem doesn't support, it is sufficient
> to test vgem as exporter with any other KMS driver.
> 
> The first test is simple:
> 1. Exporter creates a dumb FB and fills it with a plain color
> 2. FB is transferred to the importer
> 3. Importer modesets and computes pipe CRC
> 4. Importer draws the same color through cairo and compares CRC
> 
> The initial motivation comes from the need to test prime support in
> vkms.
> 
> V2:
>  - Chris: rename the file
>  - Simon: memory hygiene, codestyle
> 
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Simon Ser <daniel@ffwll.ch>
> Signed-off-by: Oleg Vasilev <oleg.vasilev@intel.com>

This series is

Reviewed-by: Simon Ser <simon.ser@intel.com>

> ---
>  tests/kms_prime.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build |   1 +
>  2 files changed, 255 insertions(+)
>  create mode 100644 tests/kms_prime.c
> 
> diff --git a/tests/kms_prime.c b/tests/kms_prime.c
> new file mode 100644
> index 00000000..17599573
> --- /dev/null
> +++ b/tests/kms_prime.c
> @@ -0,0 +1,254 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "igt.h"
> +#include "igt_vgem.h"
> +
> +#include <sys/ioctl.h>
> +#include <sys/poll.h>
> +#include <time.h>
> +
> +struct crc_info {
> +	igt_crc_t crc;
> +	char *str;
> +	const char *name;
> +};
> +
> +static struct {
> +	double r, g, b;
> +	uint32_t color;
> +	struct crc_info prime_crc, direct_crc;
> +} colors[3] = {
> +	{ .r = 0.0, .g = 0.0, .b = 0.0, .color = 0xff000000 },
> +	{ .r = 1.0, .g = 1.0, .b = 1.0, .color = 0xffffffff },
> +	{ .r = 1.0, .g = 0.0, .b = 0.0, .color = 0xffff0000 },
> +};
> +
> +IGT_TEST_DESCRIPTION("Prime tests, focusing on KMS side");
> +
> +static bool has_prime_import(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_IMPORT;
> +}
> +
> +static bool has_prime_export(int fd)
> +{
> +	uint64_t value;
> +
> +	if (drmGetCap(fd, DRM_CAP_PRIME, &value))
> +		return false;
> +
> +	return value & DRM_PRIME_CAP_EXPORT;
> +}
> +
> +static igt_output_t *setup_display(int importer_fd, igt_display_t *display,
> +				   enum pipe pipe)
> +{
> +	igt_display_require(display, importer_fd);
> +	igt_skip_on(pipe >= display->n_pipes);
> +	igt_output_t *output = igt_get_single_output_for_pipe(display, pipe);
> +
> +	igt_require_f(output, "No connector found for pipe %s\n",
> +		      kmstest_pipe_name(pipe));
> +
> +	igt_display_reset(display);
> +	igt_output_set_pipe(output, pipe);
> +	return output;
> +}
> +
> +static void prepare_scratch(int exporter_fd, struct vgem_bo *scratch,
> +			    drmModeModeInfo *mode, uint32_t color)
> +{
> +	uint32_t *ptr;
> +
> +	scratch->width = mode->hdisplay;
> +	scratch->height = mode->vdisplay;
> +	scratch->bpp = 32;
> +	vgem_create(exporter_fd, scratch);
> +
> +	ptr = vgem_mmap(exporter_fd, scratch, 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)
> +{
> +	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
> +	enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
> +
> +	igt_init_fb(fb, importer_fd, scratch->width, scratch->height,
> +		    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +		    color_encoding, color_range);
> +}
> +
> +static void import_fb(int importer_fd, struct igt_fb *fb,
> +		      int dmabuf_fd, uint32_t pitch)
> +{
> +	uint32_t offsets[4] = {}, pitches[4] = {}, handles[4] = {};
> +	int ret;
> +
> +	fb->gem_handle = prime_fd_to_handle(importer_fd, dmabuf_fd);
> +
> +	handles[0] = fb->gem_handle;
> +	pitches[0] = pitch;
> +	offsets[0] = 0;
> +
> +	ret = drmModeAddFB2(importer_fd, fb->width, fb->height,
> +			    DRM_FORMAT_XRGB8888,
> +			    handles, pitches, offsets,
> +			    &fb->fb_id, 0);
> +	igt_assert(ret == 0);
> +}
> +
> +static void set_fb(struct igt_fb *fb,
> +		   igt_display_t *display,
> +		   igt_output_t *output)
> +{
> +	igt_plane_t *primary;
> +	int ret;
> +
> +	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +	igt_assert(primary);
> +
> +	igt_plane_set_fb(primary, fb);
> +	ret = igt_display_commit(display);
> +
> +	igt_assert(ret == 0);
> +}
> +
> +static void collect_crc_for_fb(int importer_fd, struct igt_fb *fb, igt_display_t *display,
> +			       igt_output_t *output, igt_pipe_crc_t *pipe_crc,
> +			       uint32_t color, struct crc_info *info)
> +{
> +	set_fb(fb, display, output);
> +	igt_pipe_crc_collect_crc(pipe_crc, &info->crc);
> +	info->str = igt_crc_to_string(&info->crc);
> +	igt_debug("CRC through '%s' method for %#08x is %s\n",
> +		  info->name, color, info->str);
> +	igt_remove_fb(importer_fd, fb);
> +}
> +
> +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;
> +	struct igt_fb fb;
> +	int dmabuf_fd;
> +	struct vgem_bo scratch = {}; /* despite the name, it suits for any
> +				      * gem-compatible device
> +				      * TODO: rename
> +				      */
> +	int i, j;
> +	drmModeModeInfo *mode;
> +
> +	bool crc_equal = false;
> +
> +	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);
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		prepare_scratch(exporter_fd, &scratch, mode, colors[i].color);
> +		dmabuf_fd = prime_handle_to_fd(exporter_fd, scratch.handle);
> +		gem_close(exporter_fd, scratch.handle);
> +
> +		prepare_fb(importer_fd, &scratch, &fb);
> +		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);
> +
> +		igt_create_color_fb(importer_fd,
> +				    mode->hdisplay, mode->vdisplay,
> +				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +				    colors[i].r, colors[i].g, colors[i].b,
> +				    &fb);
> +
> +		colors[i].direct_crc.name = "direct";
> +		collect_crc_for_fb(importer_fd, &fb, &display, output,
> +				   pipe_crc, colors[i].color, &colors[i].direct_crc);
> +	}
> +	igt_pipe_crc_free(pipe_crc);
> +
> +	igt_debug("CRC table:\n");
> +	igt_debug("Color\t\tPrime\t\tDirect\n");
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		igt_debug("%#08x\t%.8s\t%.8s\n", colors[i].color,
> +			  colors[i].prime_crc.str, colors[i].direct_crc.str);
> +		free(colors[i].prime_crc.str);
> +		free(colors[i].direct_crc.str);
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(colors); i++) {
> +		for (j = 0; j < ARRAY_SIZE(colors); j++) {
> +			if (i == j) {
> +				igt_assert_crc_equal(&colors[i].prime_crc.crc,
> +						     &colors[j].direct_crc.crc);
> +				continue;
> +			}
> +			crc_equal = igt_check_crc_equal(&colors[i].prime_crc.crc,
> +							&colors[j].direct_crc.crc);
> +			igt_assert_f(!crc_equal, "CRC should be different");
> +		}
> +	}
> +	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 {
> +		kmstest_set_vt_graphics_mode();
> +	}
> +	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);
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 34a74025..201d72e0 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -48,6 +48,7 @@ test_progs = [
>  	'kms_plane_lowres',
>  	'kms_plane_multiple',
>  	'kms_plane_scaling',
> +	'kms_prime',
>  	'kms_prop_blob',
>  	'kms_properties',
>  	'kms_psr',
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2019-08-19  9:50 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 14:16 [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
2019-07-12 14:16 ` [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests Oleg Vasilev
2019-07-12 14:20   ` Chris Wilson
2019-07-31  9:45   ` Vasilev, Oleg
2019-08-02 14:38   ` Daniel Vetter
2019-08-16 10:07   ` Ser, Simon
2019-08-16 10:13     ` Chris Wilson
2019-08-16 10:35       ` Ser, Simon
2019-08-16 14:21     ` Vasilev, Oleg
2019-08-16 14:33       ` Ser, Simon
2019-08-16 14:39         ` Ser, Simon
2019-08-16 14:21   ` [igt-dev] [PATCH 1/2] lib: expose fb_init Oleg Vasilev
2019-08-16 14:21     ` [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests Oleg Vasilev
2019-08-19  9:50       ` Ser, Simon
2019-07-12 15:45 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init Patchwork
2019-07-12 17:07 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
2019-07-14  4:16 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
2019-08-16 14:56 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init (rev3) Patchwork
2019-08-16 15:02 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2019-08-17  6:57 ` [igt-dev] ✓ Fi.CI.IGT: " 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.