From patchwork Sat Jan 17 01:45:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kristian Hogsberg X-Patchwork-Id: 5651421 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EA50E9F357 for ; Sat, 17 Jan 2015 01:43:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA8BE203ED for ; Sat, 17 Jan 2015 01:43:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4EA4D2038A for ; Sat, 17 Jan 2015 01:43:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 728826E3DA; Fri, 16 Jan 2015 17:43:49 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 151BA6E395 for ; Fri, 16 Jan 2015 17:43:49 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 16 Jan 2015 17:43:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,414,1418112000"; d="scan'208";a="513561796" Received: from rashidah-mobl1.amr.corp.intel.com (HELO hedera.jf.intel.com) ([10.254.76.218]) by orsmga003.jf.intel.com with ESMTP; 16 Jan 2015 17:37:25 -0800 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= To: intel-gfx@lists.freedesktop.org Date: Fri, 16 Jan 2015 17:45:59 -0800 Message-Id: <1421459160-2323-1-git-send-email-krh@bitplanet.net> X-Mailer: git-send-email 2.2.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] intel: Use I915_EXEC_HANDLE_LUT when available X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Chris Wilson --- 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).