From patchwork Fri Aug 22 03:12:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 4761171 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC65FC0338 for ; Fri, 22 Aug 2014 03:14:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D33C62018E for ; Fri, 22 Aug 2014 03:14:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 79BCD20155 for ; Fri, 22 Aug 2014 03:14:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E504D6E84A; Thu, 21 Aug 2014 20:14:20 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id D47DC6E89D; Thu, 21 Aug 2014 20:14:14 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 21 Aug 2014 20:14:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="375576267" Received: from unknown (HELO ironside.intel.com) ([10.255.12.192]) by FMSMGA003.fm.intel.com with ESMTP; 21 Aug 2014 20:10:21 -0700 From: Ben Widawsky To: Intel GFX Date: Thu, 21 Aug 2014 20:12:34 -0700 Message-Id: <1408677155-1840-72-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1408677155-1840-1-git-send-email-benjamin.widawsky@intel.com> References: <1408677155-1840-1-git-send-email-benjamin.widawsky@intel.com> Cc: mesa-dev , Ben Widawsky Subject: [Intel-gfx] [PATCH] i965: First step toward prelocation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This was a quick proof of concept to show the new API for prelocating buffers. It needs way more testing, to not ifdef the no-relocs, and to do a libdrm ABI dep bump. --- src/mesa/drivers/dri/i965/Makefile.am | 1 + src/mesa/drivers/dri/i965/brw_performance_monitor.c | 6 +++--- src/mesa/drivers/dri/i965/brw_program.c | 5 +++-- src/mesa/drivers/dri/i965/brw_queryobj.c | 6 +++--- src/mesa/drivers/dri/i965/brw_state_cache.c | 4 ++-- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 3 +++ src/mesa/drivers/dri/i965/intel_batchbuffer.h | 8 ++++++++ 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/Makefile.am b/src/mesa/drivers/dri/i965/Makefile.am index 5809dc6..4b20d36 100644 --- a/src/mesa/drivers/dri/i965/Makefile.am +++ b/src/mesa/drivers/dri/i965/Makefile.am @@ -24,6 +24,7 @@ include Makefile.sources AM_CFLAGS = \ + -DNO_RELOC \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/mapi \ diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c index edfa3d2..e30c527 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -1105,13 +1105,13 @@ brw_begin_perf_monitor(struct gl_context *ctx, * wasting memory for contexts that don't use performance monitors. */ if (!brw->perfmon.bookend_bo) { - brw->perfmon.bookend_bo = drm_intel_bo_alloc(brw->bufmgr, + brw->perfmon.bookend_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "OA bookend BO", BOOKEND_BO_SIZE_BYTES, 64); } monitor->oa_bo = - drm_intel_bo_alloc(brw->bufmgr, "perf. monitor OA bo", 4096, 64); + drm_intel_bo_alloc_wrapper(brw->bufmgr, "perf. monitor OA bo", 4096, 64); #ifdef DEBUG /* Pre-filling the BO helps debug whether writes landed. */ drm_intel_bo_map(monitor->oa_bo, true); @@ -1146,7 +1146,7 @@ brw_begin_perf_monitor(struct gl_context *ctx, if (monitor_needs_statistics_registers(brw, m)) { monitor->pipeline_stats_bo = - drm_intel_bo_alloc(brw->bufmgr, "perf. monitor stats bo", 4096, 64); + drm_intel_bo_alloc_wrapper(brw->bufmgr, "perf. monitor stats bo", 4096, 64); /* Take starting snapshots. */ snapshot_statistics_registers(brw, monitor, 0); diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index d782b4f..74ff40c 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -43,6 +43,7 @@ #include "brw_context.h" #include "brw_wm.h" +#include "intel_batchbuffer.h" static unsigned get_new_program_id(struct intel_screen *screen) @@ -242,7 +243,7 @@ brw_get_scratch_bo(struct brw_context *brw, } if (!old_bo) { - *scratch_bo = drm_intel_bo_alloc(brw->bufmgr, "scratch bo", size, 4096); + *scratch_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "scratch bo", size, 4096); } } @@ -265,7 +266,7 @@ void brw_init_shader_time(struct brw_context *brw) { const int max_entries = 4096; - brw->shader_time.bo = drm_intel_bo_alloc(brw->bufmgr, "shader time", + brw->shader_time.bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "shader time", max_entries * SHADER_TIME_STRIDE, 4096); brw->shader_time.shader_programs = rzalloc_array(brw, struct gl_shader_program *, diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index c053c34..cf5a2a5 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -230,7 +230,7 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) * the system was doing other work, such as running other applications. */ drm_intel_bo_unreference(query->bo); - query->bo = drm_intel_bo_alloc(brw->bufmgr, "timer query", 4096, 4096); + query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "timer query", 4096, 4096); brw_write_timestamp(brw, query->bo, 0); break; @@ -388,7 +388,7 @@ ensure_bo_has_space(struct gl_context *ctx, struct brw_query_object *query) brw_queryobj_get_results(ctx, query); } - query->bo = drm_intel_bo_alloc(brw->bufmgr, "query", 4096, 1); + query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "query", 4096, 1); query->last_index = 0; } } @@ -474,7 +474,7 @@ brw_query_counter(struct gl_context *ctx, struct gl_query_object *q) assert(q->Target == GL_TIMESTAMP); drm_intel_bo_unreference(query->bo); - query->bo = drm_intel_bo_alloc(brw->bufmgr, "timestamp query", 4096, 4096); + query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "timestamp query", 4096, 4096); brw_write_timestamp(brw, query->bo, 0); } diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index b0986ea..daf5a11 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -171,7 +171,7 @@ brw_cache_new_bo(struct brw_cache *cache, uint32_t new_size) struct brw_context *brw = cache->brw; drm_intel_bo *new_bo; - new_bo = drm_intel_bo_alloc(brw->bufmgr, "program cache", new_size, 64); + new_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "program cache", new_size, 64); /* Copy any existing data that needs to be saved. */ if (cache->next_offset != 0) { @@ -335,7 +335,7 @@ brw_init_caches(struct brw_context *brw) cache->items = calloc(1, cache->size * sizeof(struct brw_cache_item *)); - cache->bo = drm_intel_bo_alloc(brw->bufmgr, + cache->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "program cache", 4096, 64); diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 71dc268..50834c2 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -253,6 +253,9 @@ do_flush_locked(struct brw_context *brw) if (!brw->intelScreen->no_hw) { int flags; +#ifdef NO_RELOC + flags |= I915_EXEC_NO_RELOC; +#endif if (brw->gen >= 6 && batch->ring == BLT_RING) { flags = I915_EXEC_BLT; diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h index 7bdd836..2670d22 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h @@ -11,6 +11,14 @@ extern "C" { #endif +#ifdef NO_RELOC + #define drm_intel_bo_alloc_wrapper(bufmgr, name, size, align) \ + drm_intel_bo_alloc_prelocated(bufmgr, name, size, 1) +#else + #define drm_intel_bo_alloc_wrapper drm_intel_bo_alloc +#endif + + /** * Number of bytes to reserve for commands necessary to complete a batch. *