From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH v2 06/16] drm/i915: Ensure gem_contexts selftests work with unbind changes.
Date: Mon, 29 Nov 2021 14:47:25 +0100 [thread overview]
Message-ID: <20211129134735.628712-7-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20211129134735.628712-1-maarten.lankhorst@linux.intel.com>
In the next commit, we don't evict when refcount = 0.
igt_vm_isolation() continuously tries to pin/unpin at same address,
but also calls put() on the object, which means the object may not
be unpinned in time.
Instead of this, re-use the same object over and over, so they can
be unbound as required.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
.../drm/i915/gem/selftests/i915_gem_context.c | 54 +++++++++++--------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index b32f7fed2d9c..3fc595b57cf4 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -1481,10 +1481,10 @@ static int check_scratch(struct i915_address_space *vm, u64 offset)
static int write_to_scratch(struct i915_gem_context *ctx,
struct intel_engine_cs *engine,
+ struct drm_i915_gem_object *obj,
u64 offset, u32 value)
{
struct drm_i915_private *i915 = ctx->i915;
- struct drm_i915_gem_object *obj;
struct i915_address_space *vm;
struct i915_request *rq;
struct i915_vma *vma;
@@ -1497,15 +1497,9 @@ static int write_to_scratch(struct i915_gem_context *ctx,
if (err)
return err;
- obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
- if (IS_ERR(obj))
- return PTR_ERR(obj);
-
cmd = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WB);
- if (IS_ERR(cmd)) {
- err = PTR_ERR(cmd);
- goto out;
- }
+ if (IS_ERR(cmd))
+ return PTR_ERR(cmd);
*cmd++ = MI_STORE_DWORD_IMM_GEN4;
if (GRAPHICS_VER(i915) >= 8) {
@@ -1569,17 +1563,19 @@ static int write_to_scratch(struct i915_gem_context *ctx,
i915_vma_unpin(vma);
out_vm:
i915_vm_put(vm);
-out:
- i915_gem_object_put(obj);
+
+ if (!err)
+ err = i915_gem_object_wait(obj, 0, MAX_SCHEDULE_TIMEOUT);
+
return err;
}
static int read_from_scratch(struct i915_gem_context *ctx,
struct intel_engine_cs *engine,
+ struct drm_i915_gem_object *obj,
u64 offset, u32 *value)
{
struct drm_i915_private *i915 = ctx->i915;
- struct drm_i915_gem_object *obj;
struct i915_address_space *vm;
const u32 result = 0x100;
struct i915_request *rq;
@@ -1594,10 +1590,6 @@ static int read_from_scratch(struct i915_gem_context *ctx,
if (err)
return err;
- obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
- if (IS_ERR(obj))
- return PTR_ERR(obj);
-
if (GRAPHICS_VER(i915) >= 8) {
const u32 GPR0 = engine->mmio_base + 0x600;
@@ -1615,7 +1607,7 @@ static int read_from_scratch(struct i915_gem_context *ctx,
cmd = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WB);
if (IS_ERR(cmd)) {
err = PTR_ERR(cmd);
- goto out;
+ goto err_unpin;
}
memset(cmd, POISON_INUSE, PAGE_SIZE);
@@ -1651,7 +1643,7 @@ static int read_from_scratch(struct i915_gem_context *ctx,
cmd = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WB);
if (IS_ERR(cmd)) {
err = PTR_ERR(cmd);
- goto out;
+ goto err_unpin;
}
memset(cmd, POISON_INUSE, PAGE_SIZE);
@@ -1722,8 +1714,10 @@ static int read_from_scratch(struct i915_gem_context *ctx,
i915_vma_unpin(vma);
out_vm:
i915_vm_put(vm);
-out:
- i915_gem_object_put(obj);
+
+ if (!err)
+ err = i915_gem_object_wait(obj, 0, MAX_SCHEDULE_TIMEOUT);
+
return err;
}
@@ -1765,6 +1759,7 @@ static int igt_vm_isolation(void *arg)
u64 vm_total;
u32 expected;
int err;
+ struct drm_i915_gem_object *obj_a, *obj_b;
if (GRAPHICS_VER(i915) < 7)
return 0;
@@ -1810,6 +1805,18 @@ static int igt_vm_isolation(void *arg)
vm_total = ctx_a->vm->total;
GEM_BUG_ON(ctx_b->vm->total != vm_total);
+ obj_a = i915_gem_object_create_internal(i915, PAGE_SIZE);
+ if (IS_ERR(obj_a)) {
+ err = PTR_ERR(obj_a);
+ goto out_file;
+ }
+
+ obj_b = i915_gem_object_create_internal(i915, PAGE_SIZE);
+ if (IS_ERR(obj_b)) {
+ err = PTR_ERR(obj_b);
+ goto put_a;
+ }
+
count = 0;
num_engines = 0;
for_each_uabi_engine(engine, i915) {
@@ -1832,10 +1839,10 @@ static int igt_vm_isolation(void *arg)
I915_GTT_PAGE_SIZE, vm_total,
sizeof(u32), alignof_dword);
- err = write_to_scratch(ctx_a, engine,
+ err = write_to_scratch(ctx_a, engine, obj_a,
offset, 0xdeadbeef);
if (err == 0)
- err = read_from_scratch(ctx_b, engine,
+ err = read_from_scratch(ctx_b, engine, obj_b,
offset, &value);
if (err)
goto out_file;
@@ -1858,6 +1865,9 @@ static int igt_vm_isolation(void *arg)
pr_info("Checked %lu scratch offsets across %lu engines\n",
count, num_engines);
+ i915_gem_object_put(obj_b);
+put_a:
+ i915_gem_object_put(obj_a);
out_file:
if (igt_live_test_end(&t))
err = -EIO;
--
2.34.0
next prev parent reply other threads:[~2021-11-29 13:57 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 13:47 [Intel-gfx] [PATCH v2 00/16] drm/i915: Remove short term pins from execbuf Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 01/16] drm/i915: Remove unused bits of i915_vma/active api Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 02/16] drm/i915: Change shrink ordering to use locking around unbinding Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 03/16] drm/i915: Remove pages_mutex and intel_gtt->vma_ops.set/clear_pages members, v2 Maarten Lankhorst
2021-12-06 13:13 ` Matthew Auld
2021-12-06 15:18 ` Maarten Lankhorst
2021-12-06 17:00 ` Matthew Auld
2021-12-07 18:15 ` Daniel Vetter
2021-12-06 17:10 ` Matthew Auld
2021-12-07 10:06 ` Maarten Lankhorst
2021-12-07 10:45 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 04/16] drm/i915: Take object lock in i915_ggtt_pin if ww is not set Maarten Lankhorst
2021-12-06 13:18 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 05/16] drm/i915: Force ww lock for i915_gem_object_ggtt_pin_ww Maarten Lankhorst
2021-11-30 9:20 ` [Intel-gfx] [PATCH] drm/i915: Force ww lock for i915_gem_object_ggtt_pin_ww, v2 Maarten Lankhorst
2021-12-01 15:07 ` Matthew Auld
2021-11-29 13:47 ` Maarten Lankhorst [this message]
2021-12-07 10:44 ` [Intel-gfx] [PATCH v2 06/16] drm/i915: Ensure gem_contexts selftests work with unbind changes Matthew Auld
2021-12-08 13:20 ` Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 07/16] drm/i915: Take trylock during eviction, v2 Maarten Lankhorst
2021-12-07 11:01 ` Matthew Auld
2021-12-08 13:28 ` Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 08/16] drm/i915: Pass trylock context to callers Maarten Lankhorst
2021-12-07 14:26 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 09/16] drm/i915: Ensure i915_vma tests do not get -ENOSPC with the locking changes Maarten Lankhorst
2021-12-08 11:49 ` Matthew Auld
2021-12-08 12:01 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 10/16] drm/i915: Make i915_gem_evict_vm work correctly for already locked objects Maarten Lankhorst
2021-12-08 12:07 ` Matthew Auld
2021-12-08 13:34 ` Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 11/16] drm/i915: Call i915_gem_evict_vm in vm_fault_gtt to prevent new ENOSPC errors Maarten Lankhorst
2021-12-09 12:17 ` Matthew Auld
2021-12-09 12:59 ` Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 12/16] drm/i915: Add i915_vma_unbind_unlocked, and take obj lock for i915_vma_unbind Maarten Lankhorst
2021-12-09 13:05 ` Matthew Auld
2021-12-09 13:25 ` Maarten Lankhorst
2021-12-09 13:40 ` Matthew Auld
2021-12-09 13:45 ` Maarten Lankhorst
2021-12-09 14:27 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 13/16] drm/i915: Require object lock when freeing pages during destruction Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 14/16] drm/i915: Remove assert_object_held_shared Maarten Lankhorst
2021-12-09 13:07 ` Matthew Auld
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 15/16] drm/i915: Remove support for unlocked i915_vma unbind Maarten Lankhorst
2021-11-29 13:47 ` [Intel-gfx] [PATCH v2 16/16] drm/i915: Remove short-term pins from execbuf, v5 Maarten Lankhorst
2021-12-09 16:22 ` Matthew Auld
2021-11-29 15:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Remove short term pins from execbuf Patchwork
2021-11-29 15:33 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-11-29 15:37 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-11-29 16:11 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-11-30 8:54 ` [Intel-gfx] [PATCH v2 00/16] " Tvrtko Ursulin
2021-11-30 11:17 ` Maarten Lankhorst
2021-11-30 18:38 ` Tvrtko Ursulin
2021-12-01 11:15 ` Maarten Lankhorst
2021-12-01 13:11 ` Tvrtko Ursulin
2021-11-30 11:18 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Remove short term pins from execbuf. (rev2) Patchwork
2021-11-30 11:19 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-11-30 11:23 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-11-30 11:49 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-11-30 14:51 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211129134735.628712-7-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox