Skip to contentSkip to conversation

tests/kms_prime: Sharing BO with smem as placement

PATCH New Ramalingam C 2 participants 4 messages Sep 7, 2021 Library code

lore
Share & tools
lore
#0 lore raw

cover tests/kms_prime: Sharing BO with smem as placement

Create the sharing obj with smem as second placement option through gem_create.

Ramalingam C (2):
lib/ioctl_wrappers: wrapper for mmap ptr for gem obj tests/kms_prime: Create the exporting BO with smem placement

 lib/ioctl_wrappers.c | 69 +++++++++++++++++---------------------------
 lib/ioctl_wrappers.h |  1 +
 tests/kms_prime.c    | 22 +++++++-------
 3 files changed, 38 insertions(+), 54 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 lib/ioctl_wrappers: wrapper for mmap ptr for gem obj

Refactoring the code for abstracting a wrapper for the mmaped pointer for a gem object.

---
 lib/ioctl_wrappers.c | 69 +++++++++++++++++---------------------------
 lib/ioctl_wrappers.h |  1 +
 2 files changed, 28 insertions(+), 42 deletions(-)
lib/ioctl_wrappers.c +27 -42
index 09eb3ce7b57b..d585b4f33210 100644
@@ -331,13 +331,13 @@ static bool is_cache_coherent(int fd, uint32_t handle)
 	return gem_get_caching(fd, handle) != I915_CACHING_NONE;
 }
 
-static void mmap_write(int fd, uint32_t handle, uint64_t offset,
-		       const void *buf, uint64_t length)
+void *gem_mmap_ptr(int fd, uint32_t handle, uint64_t offset, uint64_t length,
+		   unsigned prot)
 {
 	void *map = NULL;
 
 	if (!length)
-		return;
+		return map;
 
 	if (gem_has_lmem(fd)) {
 		/*
@@ -346,66 +346,51 @@ static void mmap_write(int fd, uint32_t handle, uint64_t offset,
 		 */
 		map = gem_mmap_offset__fixed(fd, handle, 0,
 					     offset + length,
-					     PROT_READ | PROT_WRITE);
+					     prot);
 		igt_assert_eq(gem_wait(fd, handle, 0), 0);
+		if (map)
+			return map;
 	}
 
-	if (!map && is_cache_coherent(fd, handle)) {
+	if (!map && (prot & PROT_READ ? gem_has_llc(fd) : true ||
+	    is_cache_coherent(fd, handle))) {
 		/* offset arg for mmap functions must be 0 */
 		map = __gem_mmap__cpu_coherent(fd, handle, 0, offset + length,
-					       PROT_READ | PROT_WRITE);
-		if (map)
+					       prot);
+		if (map) {
 			gem_set_domain(fd, handle,
-				       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+				       I915_GEM_DOMAIN_CPU, prot & PROT_WRITE ?
+				       I915_GEM_DOMAIN_CPU : 0);
+			return map;
+		}
 	}
 
 	if (!map) {
 		map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
-					    PROT_READ | PROT_WRITE);
+					    prot);
 		if (!map)
 			map = gem_mmap__wc(fd, handle, 0, offset + length,
-					   PROT_READ | PROT_WRITE);
+					   prot);
 		gem_set_domain(fd, handle,
-			       I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+			       I915_GEM_DOMAIN_WC, prot & PROT_WRITE ?
+			       I915_GEM_DOMAIN_WC : 0);
 	}
 
+	return map;
+}
+
+static void mmap_write(int fd, uint32_t handle, uint64_t offset,
+		       const void *buf, uint64_t length)
+{
+	void *map = gem_mmap_ptr(fd, handle, offset, length, PROT_READ | PROT_WRITE);
+
 	memcpy(map + offset, buf, length);
 	munmap(map, offset + length);
 }
 
 static void mmap_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length)
 {
-	void *map = NULL;
-
-	if (!length)
-		return;
-
-	if (gem_has_lmem(fd)) {
-		/*
-		 * set/get_caching and set_domain are no longer supported on
-		 * discrete, also the only supported mmap mode is FIXED.
-		 */
-		map = gem_mmap_offset__fixed(fd, handle, 0,
-					     offset + length, PROT_READ);
-		igt_assert_eq(gem_wait(fd, handle, 0), 0);
-	}
-
-	if (!map && (gem_has_llc(fd) || is_cache_coherent(fd, handle))) {
-		/* offset arg for mmap functions must be 0 */
-		map = __gem_mmap__cpu_coherent(fd, handle, 0,
-					       offset + length, PROT_READ);
-		if (map)
-			gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
-	}
-
-	if (!map) {
-		map = __gem_mmap_offset__wc(fd, handle, 0, offset + length,
-					    PROT_READ);
-		if (!map)
-			map = gem_mmap__wc(fd, handle, 0, offset + length,
-					   PROT_READ);
-		gem_set_domain(fd, handle, I915_GEM_DOMAIN_WC, 0);
-	}
+	void *map = gem_mmap_ptr(fd, handle, offset, length, PROT_READ);
 
 	igt_memcpy_from_wc(buf, map + offset, length);
 	munmap(map, offset + length);
lib/ioctl_wrappers.h +1 -0
index 9a897fec2386..7284329d67b8 100644
@@ -68,6 +68,7 @@ uint32_t gem_get_caching(int fd, uint32_t handle);
 uint32_t gem_flink(int fd, uint32_t handle);
 uint32_t gem_open(int fd, uint32_t name);
 void gem_close(int fd, uint32_t handle);
+void *gem_mmap_ptr(int fd, uint32_t handle, uint64_t offset, uint64_t length, unsigned prot);
 int __gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint64_t length);
 void gem_write(int fd, uint32_t handle, uint64_t offset,  const void *buf, uint64_t length);
 int __gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 tests/kms_prime: Create the exporting BO with smem placement

In reply to Ramalingam C

On i915, to use the dmabuf, we need the sharing object needs to be migrated to smem. So shared object needs to have the smem as second placement option.

Currently kms_prime sharing the dumb buffer between the devices. But dumb buffer can't have the placements and resides at lmem for the dgfx. Hence to meet the i915 expectation for dgfx, we create the BO using the gem_create with smem as second placement option.

---
 tests/kms_prime.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
tests/kms_prime.c +10 -12
index 2e20c58bc16e..877774249e0f 100644
@@ -100,18 +100,16 @@ static void prepare_scratch(int exporter_fd, struct dumb_bo *scratch,
 	scratch->height = mode->vdisplay;
 	scratch->bpp = 32;
 
-	scratch->handle = kmstest_dumb_create(exporter_fd,
-			ALIGN(scratch->width, 256),
-			scratch->height,
-			scratch->bpp,
-			&scratch->pitch,
-			&scratch->size);
-
-
-	ptr = kmstest_dumb_map_buffer(exporter_fd,
-				      scratch->handle,
-				      scratch->size,
-				      PROT_WRITE);
+	igt_calc_fb_size(exporter_fd, mode->hdisplay, mode->vdisplay, DRM_FORMAT_XRGB8888,
+			 DRM_FORMAT_MOD_NONE, &scratch->size, &scratch->pitch);
+	if (gem_has_lmem(exporter_fd))
+		scratch->handle = gem_create_in_memory_regions(exporter_fd, scratch->size,
+							       REGION_LMEM(0), REGION_SMEM);
+	else
+		scratch->handle = gem_create_in_memory_regions(exporter_fd, scratch->size,
+							       REGION_SMEM);
+
+	ptr = gem_mmap_ptr(exporter_fd, scratch->handle, 0, scratch->size, PROT_WRITE | PROT_READ);
 
 	for (size_t idx = 0; idx < scratch->size / sizeof(*ptr); ++idx)
 		ptr[idx] = color;
Signature · 1 line
2.20.1
#3 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for tests/kms_prime: Sharing BO with smem as placement

In reply to Ramalingam C
== Series Details ==

== Series Details ==

Series: tests/kms_prime: Sharing BO with smem as placement
URL : https://patchwork.freedesktop.org/series/94446/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10557 -> IGTPW_6205
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_6205 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_6205, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

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

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

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

### IGT changes ###

#### Possible regressions ####

* igt@runner@aborted:
- fi-tgl-y: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-tgl-y/igt@[email protected]

New tests
---------

New tests have been introduced between CI_DRM_10557 and IGTPW_6205:

### New IGT tests (8) ###

* igt@kms_flip@basic-flip-vs-dpms@d-dp1:
- Statuses : 1 pass(s)
- Exec time: [0.81] s

* igt@kms_flip@basic-flip-vs-modeset@d-dp1:
- Statuses : 1 pass(s)
- Exec time: [0.78] s

* igt@kms_flip@basic-flip-vs-wf_vblank@d-dp1:
- Statuses : 1 pass(s)
- Exec time: [1.03] s

* igt@kms_flip@basic-plain-flip@d-dp1:
- Statuses : 1 pass(s)
- Exec time: [0.76] s

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-a:
- Statuses : 28 pass(s) 7 skip(s)
- Exec time: [0.0, 1.61] s

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-b:
- Statuses : 28 pass(s) 7 skip(s)
- Exec time: [0.0, 2.71] s

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- Statuses : 23 pass(s) 12 skip(s)
- Exec time: [0.0, 2.74] s

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- Statuses : 3 pass(s) 32 skip(s)
- Exec time: [0.0, 3.21] s

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

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

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_prime@amd-to-i915:
- fi-kbl-x1275: NOTRUN -> [SKIP][2] ([fdo#109271]) +26 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-kbl-x1275/igt@amdgpu/[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-kbl-x1275: NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#2190])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-kbl-x1275/igt@[email protected]

* igt@i915_selftest@live@gt_lrc:
- fi-rkl-guc: [PASS][4] -> [DMESG-WARN][5] ([i915#3958])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10557/fi-rkl-guc/igt@i915_selftest@live@gt_lrc.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-rkl-guc/igt@i915_selftest@live@gt_lrc.html

* igt@i915_selftest@live@gt_pm:
- fi-tgl-1115g4: [PASS][6] -> [DMESG-FAIL][7] ([i915#3987])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10557/fi-tgl-1115g4/igt@i915_selftest@live@gt_pm.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-tgl-1115g4/igt@i915_selftest@live@gt_pm.html

* igt@kms_chamelium@hdmi-crc-fast:
- fi-kbl-x1275: NOTRUN -> [SKIP][8] ([fdo#109271] / [fdo#111827]) +8 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-kbl-x1275/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d (NEW):
- fi-kbl-x1275: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#533])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/fi-kbl-x1275/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#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#3958]: https://gitlab.freedesktop.org/drm/intel/issues/3958
[i915#3987]: https://gitlab.freedesktop.org/drm/intel/issues/3987
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533

Participating hosts (47 -> 38)
------------------------------

Additional (1): fi-kbl-x1275
Missing (10): fi-kbl-soraka fi-ilk-m540 bat-adls-5 bat-dg1-6 fi-hsw-4200u fi-bsw-cyan bat-adlp-4 fi-ctg-p8600 fi-bsw-kefka fi-bdw-samus

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

* CI: CI-20190529 -> None
* IGT: IGT_6198 -> IGTPW_6205

CI-20190529: 20190529
CI_DRM_10557: e8f764006582e44658833c07aef79c8c4b1a0758 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_6205: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/index.html
IGT_6198: 0f17f38c3e5e2139e59f1458c149bb7a93c88bbf @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6205/index.html