Skip to contentSkip to conversation

lib/igt_gt: Allow non-default contexts to hang non-render rings

PATCH Superseded Vinay Belgaumkar 3 participants 4 messages Oct 12, 2017 Library code

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 lib/igt_gt: Allow non-default contexts to hang non-render rings

This limitation does not exist in latest kernel. It was removed by this patch-

commit f7978a0c581a8a840a28306f8da43e06e7fef3bf

v2: Added commit id that removes the limitation(Chris Wilson)
V3: Generic way to find if kernel supports this instead of hardcoding gens(Chris Wilson)
v4: Optimize the if block (Daniele)
v5: Use the same context instead of creating a dummy (Chris Wilson)

Cc Michel Thierry <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
Cc Petri Latvala <[email protected]>
---
 lib/igt_gt.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)
lib/igt_gt.c +42 -2
index b3f3b38..2c88de6 100644
@@ -209,11 +209,51 @@ void igt_disallow_hang(int fd, igt_hang_t arg)
 }
 
 /**
+ * has_ctx_exec:
+ * @fd: open i915 drm file descriptor
+ * @ring: execbuf ring flag
+ * @ctx: Context to be checked
+ *
+ * This helper function checks if non default context submission is allowed
+ * on a ring.
+ *
+ * Returns:
+ * True if allowed
+ *
+ */
+static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx)
+{
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct drm_i915_gem_exec_object2 exec;
+	bool supported;
+
+	/* silly ABI, the kernel thinks everyone who has BSD also has BSD2 */
+	if ((ring & ~(3<<13)) == I915_EXEC_BSD) {
+		if (ring & (3 << 13) && !gem_has_bsd2(fd))
+			return false;
+	}
+
+	memset(&exec, 0, sizeof(exec));
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&exec);
+	execbuf.buffer_count = 1;
+	execbuf.flags = ring;
+	execbuf.rsvd1 = ctx;
+	/* If context submission is not allowed, this will return EINVAL
+	 * Otherwise, this will return ENOENT on account of no gem obj
+	 * being submitted */
+	supported = __gem_execbuf(fd, &execbuf) == -ENOENT;
+
+	return supported;
+}
+
+/**
  * igt_hang_ring_ctx:
  * @fd: open i915 drm file descriptor
  * @ctx: the contxt specifier
  * @ring: execbuf ring flag
  * @flags: set of flags to control execution
+ * @offset: The resultant gtt offset of the exec obj
  *
  * This helper function injects a hanging batch associated with @ctx into @ring.
  * It returns a #igt_hang_t structure which must be passed to
@@ -239,8 +279,8 @@ igt_hang_t igt_hang_ctx(int fd,
 
 	igt_require_hang_ring(fd, ring);
 
-	/* One day the kernel ABI will be fixed! */
-	igt_require(ctx == 0 || ring == I915_EXEC_RENDER);
+	/* check if non-default ctx submission is allowed */
+	igt_require(ctx == 0 || (has_ctx_exec(fd, ring, ctx)));
 
 	param.context = ctx;
 	param.size = 0;
Signature · 6 lines
1.9.1

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

✓ Fi.CI.BAT: success for lib/igt_gt: Allow non-default contexts to hang non-render rings (rev5)

== Series Details ==

== Series Details ==

Series: lib/igt_gt: Allow non-default contexts to hang non-render rings (rev5)
URL : https://patchwork.freedesktop.org/series/31693/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
69fbd44e269bd5e7e751a34e4d846e6cf3fa3eb3 tests/pm_backlight: Enable connected output to allow tests to succeed, v4.

with latest DRM-Tip kernel build CI_DRM_3223
e8024950de9e drm-tip: 2017y-10m-12d-15h-17m-52s UTC integration manifest

No testlist changes.

Test gem_exec_reloc:

        Subgroup basic-cpu-gtt-active:
                fail       -> PASS       (fi-gdg-551) fdo#102582
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-legacy:
                pass       -> FAIL       (fi-gdg-551) fdo#102618

fdo#102582 https://bugs.freedesktop.org/show_bug.cgi?id=102582
fdo#102618 https://bugs.freedesktop.org/show_bug.cgi?id=102618

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:456s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:472s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:392s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:577s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:285s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:525s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:525s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:549s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:527s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:568s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:636s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:434s
fi-gdg-551       total:289  pass:177  dwarn:1   dfail:0   fail:2   skip:109 time:284s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:604s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:442s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:465s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:507s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:480s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:501s
fi-kbl-7567u     total:289  pass:265  dwarn:4   dfail:0   fail:0   skip:20  time:492s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:595s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:660s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:468s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:662s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:536s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:524s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:477s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:590s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:436s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_341/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v5 1/1
#2 lore raw
In reply to Vinay Belgaumkar

Quoting Vinay Belgaumkar (2017-10-12 17:47:10)

Quoted 48 lines

This limitation does not exist in latest kernel. It was removed by this patch-

commit f7978a0c581a8a840a28306f8da43e06e7fef3bf

v2: Added commit id that removes the limitation(Chris Wilson)
V3: Generic way to find if kernel supports this instead of hardcoding gens(Chris Wilson)
v4: Optimize the if block (Daniele)
v5: Use the same context instead of creating a dummy (Chris Wilson)

Cc Michel Thierry <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
Cc Petri Latvala <[email protected]>
---
 lib/igt_gt.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)
lib/igt_gt.c +23 -0
index b3f3b38..2c88de6 100644
@@ -209,11 +209,51 @@ void igt_disallow_hang(int fd, igt_hang_t arg)
 }
 
 /**
+ * has_ctx_exec:
+ * @fd: open i915 drm file descriptor
+ * @ring: execbuf ring flag
+ * @ctx: Context to be checked
+ *
+ * This helper function checks if non default context submission is allowed
+ * on a ring.
+ *
+ * Returns:
+ * True if allowed
+ *
+ */
+static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx)
+{
+       struct drm_i915_gem_execbuffer2 execbuf;
+       struct drm_i915_gem_exec_object2 exec;
+       bool supported;
+
+       /* silly ABI, the kernel thinks everyone who has BSD also has BSD2 */
+       if ((ring & ~(3<<13)) == I915_EXEC_BSD) {
+               if (ring & (3 << 13) && !gem_has_bsd2(fd))
+                       return false;
+       }

lib/igt_gt.c void igt_disallow_hang(int fd, igt_hang_t arg) · line 244

Quoted 10 lines
lib/igt_gt.c +10 -0
+
+       memset(&exec, 0, sizeof(exec));
+       memset(&execbuf, 0, sizeof(execbuf));
+       execbuf.buffers_ptr = to_user_pointer(&exec);
+       execbuf.buffer_count = 1;
+       execbuf.flags = ring;
+       execbuf.rsvd1 = ctx;
+       /* If context submission is not allowed, this will return EINVAL
+        * Otherwise, this will return ENOENT on account of no gem obj
+        * being submitted */

/*
* Opening and closing should on separate lines for block comments. */

Although we are lax on the opening /* being on a separate line, our coding style, borrowed from the kernel, prefers to have them separate.

lib/igt_gt.c void igt_disallow_hang(int fd, igt_hang_t arg) · line 247

Quoted 3 lines
lib/igt_gt.c +3 -0
+       supported = __gem_execbuf(fd, &execbuf) == -ENOENT;
+
+       return supported;

We can kill the local variable now.

Quoted 13 lines
lib/igt_gt.c +4 -0
+}
+
+/**
  * igt_hang_ring_ctx:
  * @fd: open i915 drm file descriptor
  * @ctx: the contxt specifier
  * @ring: execbuf ring flag
  * @flags: set of flags to control execution
+ * @offset: The resultant gtt offset of the exec obj
  *
  * This helper function injects a hanging batch associated with @ctx into @ring.
  * It returns a #igt_hang_t structure which must be passed to

lib/igt_gt.c igt_hang_t igt_hang_ctx(int fd, · line 283

Quoted 7 lines
lib/igt_gt.c +2 -2
@@ -239,8 +279,8 @@ igt_hang_t igt_hang_ctx(int fd,
 
        igt_require_hang_ring(fd, ring);
 
-       /* One day the kernel ABI will be fixed! */
-       igt_require(ctx == 0 || ring == I915_EXEC_RENDER);
+       /* check if non-default ctx submission is allowed */
+       igt_require(ctx == 0 || (has_ctx_exec(fd, ring, ctx)));

Excess (brackets).

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.IGT: success for lib/igt_gt: Allow non-default contexts to hang non-render rings (rev5)

In reply to Vinay Belgaumkar
== Series Details ==

== Series Details ==

Series: lib/igt_gt: Allow non-default contexts to hang non-render rings (rev5)
URL : https://patchwork.freedesktop.org/series/31693/
State : success

== Summary ==

Test kms_busy:

        Subgroup extended-modeset-hang-oldfb-with-reset-render-C:
                dmesg-warn -> PASS       (shard-hsw)
Test perf:
        Subgroup polling:
                fail       -> PASS       (shard-hsw) fdo#102252
Test prime_self_import:
        Subgroup export-vs-gem_close-race:
                fail       -> PASS       (shard-hsw)
Test kms_atomic:
        Subgroup test_only:
                skip       -> PASS       (shard-hsw)

fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252

shard-hsw total:2552 pass:1440 dwarn:0 dfail:0 fail:9 skip:1103 time:9684s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_341/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx