Skip to contentSkip to conversation

lib: expose fb_init

PATCH In review Oleg Vasilev 5 participants 20 messages Jul 12, 2019 – Aug 19, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib: expose fb_init

Make it public.

---
 lib/igt_fb.c | 38 ++++++++++++++++++--------------------
 lib/igt_fb.h |  4 ++++
 2 files changed, 22 insertions(+), 20 deletions(-)
lib/igt_fb.c +18 -20
index 5dc74a00..bad3eeca 100644
@@ -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,
lib/igt_fb.h +4 -0
index e19cc5d4..69132b41 100644
@@ -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,
Signature · 6 lines
2.22.0

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

PATCH 2/2 tests/prime_generic: add vendor-agnostic prime tests

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 <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/meson.build     |   1 +
 tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c
tests/meson.build +1 -0
index 34a74025..1c938e95 100644
@@ -76,6 +76,7 @@ test_progs = [
 	'prime_self_import',
 	'prime_udl',
 	'prime_vgem',
+	'prime_generic',
 	'syncobj_basic',
 	'syncobj_wait',
 	'template',
tests/prime_generic.c new file +250 -0

250 lines not on this page · raw message

Signature · 6 lines
2.22.0

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

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

Quoting Oleg Vasilev (2019-07-12 15:16:18)

Quoted 38 lines

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 <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/meson.build     |   1 +
 tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c
tests/meson.build +0 -0
index 34a74025..1c938e95 100644

tests/meson.build test_progs = [ · line 79

Quoted 4 lines
tests/meson.build +1 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#14 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init

In reply to Oleg Vasilev
== Series Details ==

== 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@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-cml-u2/igt@[email protected]

#### 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@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-apl-guc/igt@[email protected]

* 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@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/fi-icl-u4/igt@[email protected]

{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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#15 lore raw

[igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init

In reply to Oleg Vasilev
== Series Details ==

== 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#16 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] lib: expose fb_init

In reply to Oleg Vasilev
== Series Details ==

== 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@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-glk2/igt@[email protected]

* 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@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw4/igt@[email protected]

* 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@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw8/igt@[email protected]

* 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@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb4/igt@[email protected]

* 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@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl2/igt@[email protected]

* 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@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl2/igt@[email protected]

#### 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@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl3/igt@[email protected]

* 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@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-snb7/igt@[email protected]

* 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@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-kbl3/igt@[email protected]

* 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@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-kbl2/igt@[email protected]
- 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@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-apl1/igt@[email protected]

* 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@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-glk7/igt@[email protected]

* 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@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-hsw5/igt@[email protected]

* 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@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb8/igt@[email protected]

* 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@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb1/igt@[email protected]

* 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@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb6/igt@[email protected]

* 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@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb8/igt@[email protected]

* 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@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3266/shard-iclb4/igt@[email protected]

[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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

In reply to Oleg Vasilev

Hi,

Can I get more review for this series?

Oleg

Quoted 327 lines · Oleg Vasilev

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 <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/meson.build     |   1 +
 tests/prime_generic.c | 250
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c
tests/meson.build +1 -0
index 34a74025..1c938e95 100644
@@ -76,6 +76,7 @@ test_progs = [
 	'prime_self_import',
 	'prime_udl',
 	'prime_vgem',
+	'prime_generic',
 	'syncobj_basic',
 	'syncobj_wait',
 	'template',
tests/prime_generic.c new file +4 -0
new file mode 100644
index 00000000..f273a4f6
@@ -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.
+ */

tests/prime_generic.c new file +25 -0
+
+#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");

tests/prime_generic.c new file +22 -0
+
+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,

tests/prime_generic.c new file +31 -0
+			  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)

tests/prime_generic.c new file +3 -0
+{
+	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range color_range =

IGT_COLOR_YCBCR_LIMITED_RANGE;

tests/prime_generic.c new file +40 -0
+
+	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,

tests/prime_generic.c new file +32 -0
+			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);

tests/prime_generic.c new file +3 -0
+
+	for (i = 0; i < ARRAY_SIZE(colors); i++) {
+		prepare_scratch(exporter, &scratch, mode,

colors[i].color);

tests/prime_generic.c new file +1 -0
+		dmabuf_fd = prime_handle_to_fd(exporter,

scratch.handle);

tests/prime_generic.c new file +9 -0
+		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);

tests/prime_generic.c new file +4 -0
+
+		igt_create_color_fb(importer,
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888,

LOCAL_DRM_FORMAT_MOD_NONE,

tests/prime_generic.c new file +1 -0
+				    colors[i].r, colors[i].g,

colors[i].b,

tests/prime_generic.c new file +5 -0
+				    &fb);
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].direct_crc);

tests/prime_generic.c new file +8 -0
+	}
+	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);

tests/prime_generic.c new file +8 -0
+		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,

tests/prime_generic.c new file +1 -0
+						     &colors[j].direct_

crc.crc);

tests/prime_generic.c new file +3 -0
+				continue;
+			}
+			crc_equal =

igt_check_crc_equal(&colors[i].prime_crc.crc,

tests/prime_generic.c new file +1 -0
+							&colors[j].dire

ct_crc.crc);

tests/prime_generic.c new file +1 -0
+			igt_assert_f(!crc_equal, "CRC should be

different");

tests/prime_generic.c new file +20 -0
+		}
+	}
+	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);

tests/prime_generic.c line 250

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+}
+
+igt_main
+{
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();
+	}
+	igt_subtest("crc")
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}

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

#4 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

In reply to Oleg Vasilev
Quoted 12 lines · Oleg Vasilev

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.

Quoted 3 lines

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?

Quoted 9 lines

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.

Quoted 6 lines
Cc Rodrigo Siqueira <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 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.

Quoted 166 lines
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c
tests/meson.build +1 -0
index 34a74025..1c938e95 100644
@@ -76,6 +76,7 @@ test_progs = [
        'prime_self_import',
        'prime_udl',
        'prime_vgem',
+       'prime_generic',
        'syncobj_basic',
        'syncobj_wait',
        'template',
tests/prime_generic.c new file +145 -0
new file mode 100644
index 00000000..f273a4f6
@@ -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)

tests/prime_generic.c line 155

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+{
+       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

Quoted 98 lines
tests/prime_generic.c new file +95 -1
+{
+       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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#5 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

In reply to Oleg Vasilev

Hi,

Overall this looks good. Here are a few comments.

I agree with Chris and Daniel regarding naming.

Quoted 85 lines · Oleg Vasilev

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 <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 tests/meson.build     |   1 +
 tests/prime_generic.c | 250 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 251 insertions(+)
 create mode 100644 tests/prime_generic.c
tests/meson.build +1 -0
index 34a74025..1c938e95 100644
@@ -76,6 +76,7 @@ test_progs = [
 	'prime_self_import',
 	'prime_udl',
 	'prime_vgem',
+	'prime_generic',
 	'syncobj_basic',
 	'syncobj_wait',
 	'template',
tests/prime_generic.c new file +34 -0
new file mode 100644
index 00000000..f273a4f6
@@ -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;

tests/prime_generic.c line 44

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+};
+
+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.

tests/prime_generic.c line 47

Quoted 3 lines
tests/prime_generic.c new file +3 -0
+};
+
+IGT_TEST_DESCRIPTION("Generic tests, working with any prime device");

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

tests/prime_generic.c line 56

Quoted 8 lines
tests/prime_generic.c new file +8 -0
+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.

tests/prime_generic.c line 66

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+}
+
+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

tests/prime_generic.c line 69

Quoted 3 lines
tests/prime_generic.c new file +3 -0
+}
+
+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.

Quoted 6 lines
tests/prime_generic.c new file +6 -0
+			  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",

tests/prime_generic.c line 85

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+		      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

tests/prime_generic.c line 91

Quoted 6 lines
tests/prime_generic.c new file +6 -0
+	uint32_t *ptr;
+
+	scratch->width = mode->hdisplay;
+	scratch->height = mode->vdisplay;
+	scratch->bpp = 32;
+	vgem_create(exporter, scratch);

The return value should be checked.

tests/prime_generic.c line 93

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);

Ditto, we should check that ptr != NULL.

Quoted 4 lines
tests/prime_generic.c new file +4 -0
+	for (i = 0; i < scratch->size / sizeof(*ptr); ++i)
+		ptr[i] = color;
+
+	munmap(ptr, scratch->size);

tests/prime_generic.c line 107

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+}
+
+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.

tests/prime_generic.c line 113

Quoted 6 lines
tests/prime_generic.c new file +6 -0
+}
+
+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.

Quoted 13 lines
tests/prime_generic.c new file +13 -0
+	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);

tests/prime_generic.c line 136

Quoted 10 lines
tests/prime_generic.c new file +10 -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);
Quoted 20 lines
tests/prime_generic.c new file +20 -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)
+{

tests/prime_generic.c line 166

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+	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.

tests/prime_generic.c line 179

Quoted 13 lines
tests/prime_generic.c new file +13 -0
+	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.

tests/prime_generic.c line 183

Quoted 4 lines
tests/prime_generic.c new file +4 -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.

tests/prime_generic.c line 194

Quoted 11 lines
tests/prime_generic.c new file +11 -0
+		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.

Quoted 42 lines
tests/prime_generic.c new file +42 -0
+
+		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);

tests/prime_generic.c line 246

Quoted 10 lines
tests/prime_generic.c new file +10 -0
+
+	test_crc(exporter, importer);
+	close(importer);
+	close(exporter);
+}
+
+igt_main
+{
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();

Is this really needed?

tests/prime_generic.c line 246

Quoted 2 lines
tests/prime_generic.c new file +2 -0
+	}
+	igt_subtest("crc")

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

tests/prime_generic.c line 250

Quoted 2 lines
tests/prime_generic.c new file +2 -0
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}

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

#6 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

Quoting Ser, Simon (2019-08-16 11:07:56)

Quoted 13 lines · Oleg Vasilev

tests/prime_generic.c line 56

Quoted 8 lines
tests/prime_generic.c new file +8 -0
+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.

Quoted 1 line

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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

Quoted 14 lines · Chris Wilson

Quoting Ser, Simon (2019-08-16 11:07:56)

Quoted 13 lines · Oleg Vasilev

tests/prime_generic.c line 56

Quoted 8 lines
tests/prime_generic.c new file +8 -0
+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.

Quoted 4 lines
Quoted 1 line

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 [email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#11 lore raw

PATCH 1/2 lib: expose fb_init

In reply to Oleg Vasilev

Make it public.

---
 lib/igt_fb.c | 38 ++++++++++++++++++--------------------
 lib/igt_fb.h |  4 ++++
 2 files changed, 22 insertions(+), 20 deletions(-)
lib/igt_fb.c +18 -20
index 5dc74a00..bad3eeca 100644
@@ -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,
lib/igt_fb.h +4 -0
index e19cc5d4..69132b41 100644
@@ -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,
Signature · 6 lines
2.22.0

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

PATCH 2/2 tests/kms_prime: add vendor-agnostic kms prime tests

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

---
 tests/kms_prime.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |   1 +
 2 files changed, 255 insertions(+)
 create mode 100644 tests/kms_prime.c
tests/kms_prime.c new file +254 -0
new file mode 100644
index 00000000..17599573
@@ -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);
+}
tests/meson.build +1 -0
index 34a74025..201d72e0 100644
@@ -48,6 +48,7 @@ test_progs = [
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
+	'kms_prime',
 	'kms_prop_blob',
 	'kms_properties',
 	'kms_psr',
Signature · 6 lines
2.22.0

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

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

In reply to Ser, Simon
Quoted 19 lines · Simon

Hi,

Overall this looks good. Here are a few comments.

I agree with Chris and Daniel regarding naming.

tests/prime_generic.c line 56

Quoted 8 lines · Oleg Vasilev
tests/prime_generic.c new file +8 -0
+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.

Quoted 1 line

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

Hi,

As discussed, this should be still a valid stdbool.

Quoted 3 lines

tests/prime_generic.c line 91

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	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.

Quoted 4 lines

tests/prime_generic.c line 93

Quoted 2 lines
tests/prime_generic.c new file +1 -0
+	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);

Ditto, we should check that ptr != NULL.

Same.

Quoted 21 lines
Quoted 13 lines
tests/prime_generic.c new file +7 -0
+	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)

tests/prime_generic.c new file +3 -0
+{
+	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range color_range =

IGT_COLOR_YCBCR_LIMITED_RANGE;

tests/prime_generic.c line 107

Quoted 4 lines
tests/prime_generic.c new file +4 -0
+
+	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.

Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+}
 
+		dmabuf_fd = prime_handle_to_fd(exporter,

scratch.handle);

We should check dmabuf_fd >= 0.

Same, it is asserted internally.

Quoted 6 lines

tests/prime_generic.c line 183

Quoted 4 lines
tests/prime_generic.c new file +4 -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.

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

Quoted 8 lines
Quoted 8 lines
tests/prime_generic.c new file +5 -0
+		close(dmabuf_fd);
+
+		colors[i].prime_crc.name = "prime";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].prime_crc);

(quoted diff) +2 -0
+
+		igt_create_color_fb(importer,
Quoted 8 lines

tests/prime_generic.c line 194

Quoted 6 lines
(quoted diff) +2 -0
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888,

LOCAL_DRM_FORMAT_MOD_NONE,

(quoted diff) +1 -0
+				    colors[i].r, colors[i].g,

colors[i].b,

tests/prime_generic.c new file +1 -0
+				    &fb);

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

Same

Quoted 18 lines
Quoted 18 lines
tests/prime_generic.c new file +4 -0
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].direct_crc);

tests/prime_generic.c new file +8 -0
+	}
+	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);

tests/prime_generic.c new file +3 -0
+		free(colors[i].prime_crc.str);
+		free(colors[i].direct_crc.str);
+	}

...

Quoted 7 lines

tests/prime_generic.c line 246

Quoted 5 lines
tests/prime_generic.c new file +5 -0
+
+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

Quoted 9 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+	}
+	igt_subtest("crc")

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

tests/prime_generic.c line 250

Quoted 2 lines
tests/prime_generic.c new file +2 -0
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}

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

#9 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

Quoted 26 lines · Oleg
Quoted 19 lines · Simon

Hi,

Overall this looks good. Here are a few comments.

I agree with Chris and Daniel regarding naming.

tests/prime_generic.c line 56

Quoted 8 lines · Oleg Vasilev
tests/prime_generic.c new file +8 -0
+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.

Quoted 1 line

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

Hi,

As discussed, this should be still a valid stdbool.

Quoted 7 lines
Quoted 3 lines

tests/prime_generic.c line 91

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	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;

Quoted 5 lines
Quoted 3 lines

tests/prime_generic.c line 93

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);

Ditto, we should check that ptr != NULL.

Same.

Ditto

Quoted 20 lines
Quoted 20 lines
Quoted 12 lines
tests/prime_generic.c new file +7 -0
+	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)

tests/prime_generic.c new file +3 -0
+{
+	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range color_range =

IGT_COLOR_YCBCR_LIMITED_RANGE;

tests/prime_generic.c line 107

Quoted 4 lines
tests/prime_generic.c new file +4 -0
+
+	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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+}
 
+		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.

Quoted 9 lines
Quoted 6 lines

tests/prime_generic.c line 183

Quoted 4 lines
tests/prime_generic.c new file +4 -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.

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.

Quoted 45 lines
Quoted 8 lines
Quoted 8 lines
tests/prime_generic.c new file +5 -0
+		close(dmabuf_fd);
+
+		colors[i].prime_crc.name = "prime";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].prime_crc);

(quoted diff) +2 -0
+
+		igt_create_color_fb(importer,
Quoted 8 lines

tests/prime_generic.c line 194

Quoted 6 lines
(quoted diff) +2 -0
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888,

LOCAL_DRM_FORMAT_MOD_NONE,

(quoted diff) +1 -0
+				    colors[i].r, colors[i].g,

colors[i].b,

tests/prime_generic.c new file +1 -0
+				    &fb);

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

Same

Quoted 17 lines
Quoted 17 lines
tests/prime_generic.c new file +4 -0
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].direct_crc);

tests/prime_generic.c new file +8 -0
+	}
+	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);

tests/prime_generic.c new file +3 -0
+		free(colors[i].prime_crc.str);
+		free(colors[i].direct_crc.str);
+	}

...

Quoted 7 lines

tests/prime_generic.c line 246

Quoted 5 lines
tests/prime_generic.c new file +5 -0
+
+igt_main
+{
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();

Is this really needed?

Quoted 1 line

Yeah, it is necessary for every KMS test.

Oh, right, the function documentation is helpful.

Quoted 1 line

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

Thanks!

Quoted 10 lines

Oleg

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	}
+	igt_subtest("crc")

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

tests/prime_generic.c line 250

Quoted 2 lines
tests/prime_generic.c new file +2 -0
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}

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

#10 lore raw

Re: [igt-dev] [PATCH 2/2] tests/prime_generic: add vendor-agnostic prime tests

Quoted 31 lines · Simon
Quoted 30 lines · Oleg
Quoted 19 lines · Simon

Hi,

Overall this looks good. Here are a few comments.

I agree with Chris and Daniel regarding naming.

tests/prime_generic.c line 56

Quoted 8 lines · Oleg Vasilev
tests/prime_generic.c new file +8 -0
+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.

Quoted 1 line

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

Hi,

As discussed, this should be still a valid stdbool.

Quoted 3 lines

tests/prime_generic.c line 91

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	vgem_create(exporter, scratch);

The return value should be checked.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

tests/prime_generic.c line 93

Quoted 1 line
tests/prime_generic.c new file +1 -0
+	ptr = vgem_mmap(exporter, scratch, PROT_WRITE);

Ditto, we should check that ptr != NULL.

Same.

Ditto

Same!

Quoted 104 lines
Quoted 20 lines
Quoted 20 lines
Quoted 12 lines
tests/prime_generic.c new file +7 -0
+	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)

tests/prime_generic.c new file +3 -0
+{
+	enum igt_color_encoding color_encoding = IGT_COLOR_YCBCR_BT709;
+	enum igt_color_range color_range =

IGT_COLOR_YCBCR_LIMITED_RANGE;

tests/prime_generic.c line 107

Quoted 4 lines
tests/prime_generic.c new file +4 -0
+
+	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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
(quoted diff) +2 -0
+}
 
+		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.

Quoted 9 lines
Quoted 6 lines

tests/prime_generic.c line 183

Quoted 4 lines
tests/prime_generic.c new file +4 -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.

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.

Quoted 45 lines
Quoted 8 lines
Quoted 8 lines
tests/prime_generic.c new file +5 -0
+		close(dmabuf_fd);
+
+		colors[i].prime_crc.name = "prime";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].prime_crc);

(quoted diff) +2 -0
+
+		igt_create_color_fb(importer,
Quoted 8 lines

tests/prime_generic.c line 194

Quoted 6 lines
(quoted diff) +2 -0
+				    mode->hdisplay, mode->vdisplay,
+				    DRM_FORMAT_XRGB8888,

LOCAL_DRM_FORMAT_MOD_NONE,

(quoted diff) +1 -0
+				    colors[i].r, colors[i].g,

colors[i].b,

tests/prime_generic.c new file +1 -0
+				    &fb);

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

Same

Quoted 17 lines
Quoted 17 lines
tests/prime_generic.c new file +4 -0
+
+		colors[i].direct_crc.name = "direct";
+		collect_crc(importer, &fb, &display, output,
+			    pipe_crc, colors[i].color,

&colors[i].direct_crc);

tests/prime_generic.c new file +8 -0
+	}
+	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);

tests/prime_generic.c new file +3 -0
+		free(colors[i].prime_crc.str);
+		free(colors[i].direct_crc.str);
+	}

...

Quoted 7 lines

tests/prime_generic.c line 246

Quoted 5 lines
tests/prime_generic.c new file +5 -0
+
+igt_main
+{
+	igt_fixture {
+		kmstest_set_vt_graphics_mode();

Is this really needed?

Quoted 1 line

Yeah, it is necessary for every KMS test.

Oh, right, the function documentation is helpful.

Quoted 1 line

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

Thanks!

Quoted 8 lines

Oleg

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	}
+	igt_subtest("crc")

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

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

tests/prime_generic.c line 250

Quoted 2 lines
tests/prime_generic.c new file +2 -0
+		run_test_crc(DRIVER_VGEM, DRIVER_ANY);
+}

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

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

#17 lore raw

[igt-dev] ✗ GitLab.Pipeline: warning for series starting with [1/2] lib: expose fb_init (rev3)

In reply to Oleg Vasilev
== Series Details ==

== 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#18 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] lib: expose fb_init (rev3)

In reply to Oleg Vasilev
== Series Details ==

== 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@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/fi-icl-u3/igt@[email protected]

* 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@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/fi-cml-u2/igt@[email protected]

#### 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#19 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] lib: expose fb_init (rev3)

In reply to Oleg Vasilev
== Series Details ==

== 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@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl5/igt@[email protected]

* 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@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb5/igt@[email protected]

* 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@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@[email protected]

* 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@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-snb1/igt@[email protected]

* 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@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl3/igt@[email protected]

* 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@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb7/igt@[email protected]

* 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@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-hsw4/igt@[email protected]

* 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@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-glk9/igt@[email protected]

* 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@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb7/igt@[email protected]

* 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@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb3/igt@[email protected]

* 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@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb8/igt@[email protected]

* 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@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@[email protected]

* 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@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-hsw5/igt@[email protected]

* 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@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-glk6/igt@[email protected]

* 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@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@[email protected]

* 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@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb3/igt@[email protected]

* 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@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-kbl2/igt@[email protected]

* 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@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-apl3/igt@[email protected]

#### 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@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3358/shard-iclb2/igt@[email protected]

[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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

Re: [igt-dev] [PATCH 2/2] tests/kms_prime: add vendor-agnostic kms prime tests

In reply to Oleg Vasilev
Quoted 28 lines · Oleg Vasilev

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

Quoted 5 lines

This series is

Quoted 271 lines
---
 tests/kms_prime.c | 254 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |   1 +
 2 files changed, 255 insertions(+)
 create mode 100644 tests/kms_prime.c
tests/kms_prime.c new file +254 -0
new file mode 100644
index 00000000..17599573
@@ -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);
+}
tests/meson.build +0 -0
index 34a74025..201d72e0 100644

tests/meson.build test_progs = [ · line 54

Quoted 7 lines
tests/meson.build +1 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev