From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 4/5] intel: Intel full PPGTT param Date: Tue, 7 Jan 2014 08:53:36 +0100 Message-ID: <20140107075336.GD4770@phenom.ffwll.local> References: <1388728235-20410-1-git-send-email-benjamin.widawsky@intel.com> <1388728235-20410-7-git-send-email-benjamin.widawsky@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com [74.125.83.47]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A1461089AA for ; Mon, 6 Jan 2014 23:52:21 -0800 (PST) Received: by mail-ee0-f47.google.com with SMTP id e51so6977329eek.6 for ; Mon, 06 Jan 2014 23:52:19 -0800 (PST) Content-Disposition: inline In-Reply-To: <1388728235-20410-7-git-send-email-benjamin.widawsky@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Ben Widawsky Cc: Intel GFX , Ben Widawsky , DRI Development , Kenneth Graunke List-Id: intel-gfx@lists.freedesktop.org On Thu, Jan 02, 2014 at 07:50:33PM -1000, Ben Widawsky wrote: > 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 Fyi I've killed this. -Daniel > --- > 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)) > -- > 1.8.5.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch