All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@bitplanet.net>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 1/2] intel: Use I915_EXEC_HANDLE_LUT when available
Date: Fri, 16 Jan 2015 17:45:59 -0800	[thread overview]
Message-ID: <1421459160-2323-1-git-send-email-krh@bitplanet.net> (raw)

In userspace we can track which buffer a relocation refers to in
constant time.  However, the kernel has to look up the per-fd gem
handle for each relocation.  Using the I915_EXEC_HANDLE_LUT flag lets
us use the the bos validation list index instead of the gem handle in
the relocation entries.  This allows the kernel to look up the bo for
a reloc in constant time.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
---
 intel/intel_bufmgr_gem.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index cf85bb8..8a51cea 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -130,6 +130,7 @@ typedef struct _drm_intel_bufmgr_gem {
 	unsigned int bo_reuse : 1;
 	unsigned int no_exec : 1;
 	unsigned int has_vebox : 1;
+	unsigned int has_handle_lut : 1;
 	bool fenced_relocs;
 
 	char *aub_filename;
@@ -399,11 +400,12 @@ drm_intel_gem_dump_validation_list(drm_intel_bufmgr_gem *bufmgr_gem)
 			    (drm_intel_bo_gem *) target_bo;
 
 			DBG("%2d: %d (%s)@0x%08llx -> "
-			    "%d (%s)@0x%08lx + 0x%08x\n",
+			    "%d (#%d) (%s)@0x%08lx + 0x%08x\n",
 			    i,
 			    bo_gem->gem_handle, bo_gem->name,
 			    (unsigned long long)bo_gem->relocs[j].offset,
 			    target_gem->gem_handle,
+			    bo_gem->relocs[j].target_handle,
 			    target_gem->name,
 			    target_bo->offset64,
 			    bo_gem->relocs[j].delta);
@@ -470,7 +472,7 @@ drm_intel_add_validate_buffer2(drm_intel_bo *bo, int need_fence)
 {
 	drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
 	drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
-	int index;
+	int i, index;
 
 	if (bo_gem->validate_index != -1) {
 		if (need_fence)
@@ -512,6 +514,26 @@ drm_intel_add_validate_buffer2(drm_intel_bo *bo, int need_fence)
 			EXEC_OBJECT_NEEDS_FENCE;
 	}
 	bufmgr_gem->exec_count++;
+
+	if (bufmgr_gem->has_handle_lut) {
+		/* If the kernel supports I915_EXEC_HANDLE_LUT, we can
+		 * use validate_index instead of the gem handle in
+		 * target_handle in the reloc entry.  This allows the
+		 * kernel to do a simple constant time lookup instead
+		 * of looking up the gem handle for each reloc.
+		 *
+		 * We have to fix up the relocs here, since the bo_gem
+		 * needs to have a valid validate_index in case there
+		 * are self-relocs in the reloc list.
+		 */
+		for (i = 0; i < bo_gem->reloc_count; i++) {
+			drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *)
+				bo_gem->reloc_target_info[i].bo;
+
+			bo_gem->relocs[i].target_handle =
+				target_bo_gem->validate_index;
+		}
+	}
 }
 
 #define RELOC_BUF_SIZE(x) ((I915_RELOC_HEADER + x * I915_RELOC0_STRIDE) * \
@@ -2447,6 +2469,9 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx,
 	if (bufmgr_gem->no_exec)
 		goto skip_execution;
 
+	if (bufmgr_gem->has_handle_lut)
+		execbuf.flags |= I915_EXEC_HANDLE_LUT;
+
 	ret = drmIoctl(bufmgr_gem->fd,
 		       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 		       &execbuf);
@@ -3569,6 +3594,10 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
 		}
 	}
 
+	gp.param = I915_PARAM_HAS_EXEC_HANDLE_LUT;
+	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	bufmgr_gem->has_handle_lut = ret == 0;
+
 	/* Let's go with one relocation per every 2 dwords (but round down a bit
 	 * since a power of two will mean an extra page allocation for the reloc
 	 * buffer).
-- 
2.2.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2015-01-17  1:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-17  1:45 Kristian Høgsberg [this message]
2015-01-17  1:46 ` [PATCH 2/2] intel: Use I915_EXEC_NO_RELOC when available Kristian Høgsberg
2015-01-17  4:23   ` Daniel Vetter
2015-01-17  9:49     ` Chris Wilson
2015-01-20  5:58       ` Kristian Høgsberg
2015-01-20  8:34         ` Daniel Vetter
2015-01-20  5:45     ` Kristian Høgsberg
2015-01-20  8:42       ` Daniel Vetter
2015-01-20 20:53         ` Kristian Høgsberg
2015-01-20 21:46           ` Chris Wilson
2015-01-21  6:10             ` Kristian Høgsberg
2015-01-21  9:11               ` Daniel Vetter
2015-01-21  9:17               ` Daniel Vetter
2015-01-21  9:24                 ` Daniel Vetter
2015-01-21  9:24               ` Chris Wilson
2015-01-17  9:46 ` [PATCH 1/2] intel: Use I915_EXEC_HANDLE_LUT " Chris Wilson
2015-05-01 14:53 ` RFC Fast batch and relocation handling for i965 Chris Wilson
2015-05-01 14:53   ` [PATCH 1/4] i965: Transplant PIPE_CONTROL routines to brw_pipe_control Chris Wilson
2015-05-01 17:58     ` Kenneth Graunke
2015-05-01 14:53   ` [PATCH 2/4] i915: Rename intel_emit* to reflect their new location in brw_pipe_control Chris Wilson
2015-05-01 14:53   ` [PATCH 3/4] i965: Move pipecontrol workaround bo to brw_pipe_control Chris Wilson
2015-05-01 14:53   ` [PATCH 4/4] i965: Introduce a context-local batch manager Chris Wilson
2015-05-05 16:16     ` [Mesa-dev] " Emil Velikov

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=1421459160-2323-1-git-send-email-krh@bitplanet.net \
    --to=krh@bitplanet.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.