From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org, Matthew Auld <matthew.auld@intel.com>
Subject: [igt-dev] [PATCH i-g-t] prime_busy: Prebind the batch buffer
Date: Wed, 21 Aug 2019 21:03:28 +0100 [thread overview]
Message-ID: <20190821200328.22668-1-chris@chris-wilson.co.uk> (raw)
The test assumes that the dmabuf for the batch buffer has no exclusive
fence. This is only true for the batch as it executes on the GPU; prior
to that we may be in the process of moving it into memory and the
ppGTT which cause the batch to carry an exclusive fence. Keep the test
simple and prebind the batch buffer so that when we poll the dmabuf fd,
we only expect it to be the spinning batch.
Alternatively we could wait until we start writing values into scratch
(i.e. igt_spin_busywait_until_started()). This seemed simpler.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
---
tests/prime_busy.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/tests/prime_busy.c b/tests/prime_busy.c
index a82acbdbc..4f237f68f 100644
--- a/tests/prime_busy.c
+++ b/tests/prime_busy.c
@@ -41,6 +41,7 @@ static bool prime_busy(struct pollfd *pfd, bool excl)
static void busy(int fd, unsigned ring, unsigned flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
+ const uint32_t _bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_exec_object2 obj[2];
struct pollfd pfd[2];
#define SCRATCH 0
@@ -55,7 +56,7 @@ static void busy(int fd, unsigned ring, unsigned flags)
gem_quiescent_gpu(fd);
memset(&execbuf, 0, sizeof(execbuf));
- execbuf.buffers_ptr = (uintptr_t)obj;
+ execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring;
if (gen < 6)
@@ -65,7 +66,11 @@ static void busy(int fd, unsigned ring, unsigned flags)
obj[SCRATCH].handle = gem_create(fd, 4096);
obj[BATCH].handle = gem_create(fd, size);
- obj[BATCH].relocs_ptr = (uintptr_t)store;
+ obj[BATCH].offset = 1 << 20;
+ gem_write(fd, obj[BATCH].handle, 0, &_bbe, sizeof(_bbe));
+ igt_require(__gem_execbuf(fd, &execbuf) == 0); /* prebind the buffers */
+
+ obj[BATCH].relocs_ptr = to_user_pointer(store);
obj[BATCH].relocation_count = ARRAY_SIZE(store);
memset(store, 0, sizeof(store));
@@ -81,23 +86,28 @@ static void busy(int fd, unsigned ring, unsigned flags)
i = 0;
for (count = 0; count < 1024; count++) {
+ uint64_t offset;
+
store[count].target_handle = obj[SCRATCH].handle;
- store[count].presumed_offset = -1;
+ store[count].presumed_offset = obj[SCRATCH].offset;
store[count].offset = sizeof(uint32_t) * (i + 1);
store[count].delta = sizeof(uint32_t) * count;
- store[count].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
- store[count].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
+ store[count].read_domains = I915_GEM_DOMAIN_RENDER;
+ store[count].write_domain = I915_GEM_DOMAIN_RENDER;
+
+ offset = store[count].presumed_offset + store[count].delta;
+
batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
if (gen >= 8) {
- batch[++i] = 0;
- batch[++i] = 0;
+ batch[++i] = offset;
+ batch[++i] = offset >> 32;
} else if (gen >= 4) {
batch[++i] = 0;
- batch[++i] = 0;
+ batch[++i] = offset;
store[count].offset += sizeof(uint32_t);
} else {
batch[i]--;
- batch[++i] = 0;
+ batch[++i] = offset;
}
batch[++i] = count;
i++;
@@ -105,7 +115,7 @@ static void busy(int fd, unsigned ring, unsigned flags)
bbe = &batch[i];
store[count].target_handle = obj[BATCH].handle; /* recurse */
- store[count].presumed_offset = 0;
+ store[count].presumed_offset = obj[BATCH].offset;
store[count].offset = sizeof(uint32_t) * (i + 1);
store[count].delta = 0;
store[count].read_domains = I915_GEM_DOMAIN_COMMAND;
@@ -113,14 +123,14 @@ static void busy(int fd, unsigned ring, unsigned flags)
batch[i] = MI_BATCH_BUFFER_START;
if (gen >= 8) {
batch[i] |= 1 << 8 | 1;
- batch[++i] = 0;
- batch[++i] = 0;
+ batch[++i] = obj[BATCH].offset;
+ batch[++i] = obj[BATCH].offset >> 32;
} else if (gen >= 6) {
batch[i] |= 1 << 8;
- batch[++i] = 0;
+ batch[++i] = obj[BATCH].offset;
} else {
batch[i] |= 2 << 6;
- batch[++i] = 0;
+ batch[++i] = obj[BATCH].offset;
if (gen < 4) {
batch[i] |= 1;
store[count].delta = 1;
--
2.23.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-08-21 20:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 20:03 Chris Wilson [this message]
2019-08-21 21:01 ` [igt-dev] ✓ Fi.CI.BAT: success for prime_busy: Prebind the batch buffer Patchwork
2019-08-22 9:54 ` [igt-dev] [PATCH i-g-t] " Matthew Auld
2019-08-22 10:54 ` [igt-dev] ✓ Fi.CI.IGT: success for " 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=20190821200328.22668-1-chris@chris-wilson.co.uk \
--to=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
/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