From patchwork Fri Jan 3 05:50:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 3430351 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B94C9F54D for ; Fri, 3 Jan 2014 05:51:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EB7920134 for ; Fri, 3 Jan 2014 05:51:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A212D20127 for ; Fri, 3 Jan 2014 05:51:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96B04FA5B2; Thu, 2 Jan 2014 21:51:00 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A1F2FA78D; Thu, 2 Jan 2014 21:50:55 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 02 Jan 2014 21:50:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,595,1384329600"; d="scan'208";a="433340667" Received: from unknown (HELO ironside.intel.com) ([10.255.12.92]) by orsmga001.jf.intel.com with ESMTP; 02 Jan 2014 21:50:50 -0800 From: Ben Widawsky To: Intel GFX Subject: [PATCH 4/5] intel: Intel full PPGTT param Date: Thu, 2 Jan 2014 19:50:33 -1000 Message-Id: <1388728235-20410-7-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1388728235-20410-1-git-send-email-benjamin.widawsky@intel.com> References: <1388728235-20410-1-git-send-email-benjamin.widawsky@intel.com> Cc: Ben Widawsky , Kenneth Graunke , DRI Development , Ben Widawsky X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.7 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 will allow mesa to determine if it needs to create a context, or can reuse the default context. Reusing the default context saves memory, and startup time. To keep the libdrm interface as dumb as possible, we simply expose a getter for the default context (which is only a real context when thereis full PPGTT and per fd contexts). As such, callers can expect NULL when this is not the case. See the usage in mesa for details. Cc: Kenneth Graunke Signed-off-by: Ben Widawsky --- include/drm/i915_drm.h | 1 + intel/intel_bufmgr.h | 1 + intel/intel_bufmgr_gem.c | 30 ++++++++++++++++++++++++++++++ intel/intel_bufmgr_priv.h | 1 + 4 files changed, 33 insertions(+) diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index 2f4eb8c..50b080e 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -337,6 +337,7 @@ typedef struct drm_i915_irq_wait { #define I915_PARAM_HAS_EXEC_NO_RELOC 25 #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26 #define I915_PARAM_HAS_WT 27 +#define I915_PARAM_HAS_FULL_PPGTT 28 typedef struct drm_i915_getparam { int param; diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h index 2eb9742..7f08093 100644 --- a/intel/intel_bufmgr.h +++ b/intel/intel_bufmgr.h @@ -191,6 +191,7 @@ int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr); int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns); drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr); +drm_intel_context * drm_intel_gem_default_context_get(drm_intel_bufmgr *bufmgr); void drm_intel_gem_context_destroy(drm_intel_context *ctx); int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx, int used, unsigned int flags); diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index ad722dd..dbd333a 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -126,6 +126,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_full_ppgtt : 1; bool fenced_relocs; char *aub_filename; @@ -3039,6 +3040,26 @@ drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr) return context; } +drm_intel_context * +drm_intel_gem_default_context_get(drm_intel_bufmgr *bufmgr) +{ + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bufmgr; + drm_intel_context *context = NULL; + + if (!bufmgr_gem->has_full_ppgtt) + return NULL; + + context = calloc(1, sizeof(*context)); + if (!context) + return NULL; + + context->ctx_id = 0; + context->bufmgr = bufmgr; + context->is_default = 1; + + return context; +} + void drm_intel_gem_context_destroy(drm_intel_context *ctx) { @@ -3049,6 +3070,11 @@ drm_intel_gem_context_destroy(drm_intel_context *ctx) if (ctx == NULL) return; + if (ctx->is_default) { + free(ctx); + return; + } + VG_CLEAR(destroy); bufmgr_gem = (drm_intel_bufmgr_gem *)ctx->bufmgr; @@ -3267,6 +3293,10 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); bufmgr_gem->has_vebox = (ret == 0) & (*gp.value > 0); + gp.param = I915_PARAM_HAS_FULL_PPGTT; + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); + bufmgr_gem->has_full_ppgtt = (ret == 0) & (*gp.value > 0); + if (bufmgr_gem->gen < 4) { gp.param = I915_PARAM_NUM_FENCES_AVAIL; gp.value = &bufmgr_gem->available_fences; diff --git a/intel/intel_bufmgr_priv.h b/intel/intel_bufmgr_priv.h index 2592d42..e622746 100644 --- a/intel/intel_bufmgr_priv.h +++ b/intel/intel_bufmgr_priv.h @@ -283,6 +283,7 @@ struct _drm_intel_bufmgr { struct _drm_intel_context { unsigned int ctx_id; struct _drm_intel_bufmgr *bufmgr; + int is_default; }; #define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))