From patchwork Fri Jun 13 15:37:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: oscar.mateo@intel.com X-Patchwork-Id: 4349831 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 F35D1BEECB for ; Fri, 13 Jun 2014 15:43:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19B362022A for ; Fri, 13 Jun 2014 15:43:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A9A3C20263 for ; Fri, 13 Jun 2014 15:43:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F7A66EA56; Fri, 13 Jun 2014 08:43:06 -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 66D896EA54 for ; Fri, 13 Jun 2014 08:43:04 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 13 Jun 2014 08:43:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,471,1400050800"; d="scan'208";a="555136367" Received: from omateolo-linux2.iwi.intel.com ([172.28.253.145]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2014 08:43:02 -0700 From: oscar.mateo@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 13 Jun 2014 16:37:31 +0100 Message-Id: <1402673891-14618-14-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1402673891-14618-1-git-send-email-oscar.mateo@intel.com> References: <1402673891-14618-1-git-send-email-oscar.mateo@intel.com> Subject: [Intel-gfx] [PATCH 13/53] drm/i915/bdw: Deferred creation of user-created LRCs 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.8 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 From: Oscar Mateo The backing objects for contexts created via open fd are actually empty until the user starts sending execbuffers to them. We do this because, at create time, we really don't know which engine is going to be used with the context later on. v2: As context created via ioctl can only be used with the render ring, we have enough information to allocate & populate them right away. Signed-off-by: Oscar Mateo --- drivers/gpu/drm/i915/i915_gem_context.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 1fb4592..70bf6d0 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -795,6 +795,7 @@ static bool contexts_enabled(struct drm_device *dev) int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { + struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_gem_context_create *args = data; struct drm_i915_file_private *file_priv = file->driver_priv; struct intel_context *ctx; @@ -808,9 +809,23 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, return ret; ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev)); - mutex_unlock(&dev->struct_mutex); - if (IS_ERR(ctx)) + if (IS_ERR(ctx)) { + mutex_unlock(&dev->struct_mutex); return PTR_ERR(ctx); + } + + if (dev_priv->lrc_enabled) { + /* NB: We know this context will only be used with the render ring + * (as we enforce it) so we can allocate & populate it already */ + int ret = intel_lr_context_deferred_create(ctx, &dev_priv->ring[RCS]); + if (ret) { + mutex_unlock(&dev->struct_mutex); + DRM_DEBUG_DRIVER("Could not create LRC: %d\n", ret); + return ret; + } + } + + mutex_unlock(&dev->struct_mutex); args->ctx_id = ctx->id; DRM_DEBUG_DRIVER("HW context %d created\n", args->ctx_id); @@ -851,6 +866,7 @@ struct intel_context * i915_gem_context_validate(struct drm_device *dev, struct drm_file *file, struct intel_engine_cs *ring, const u32 ctx_id) { + struct drm_i915_private *dev_priv = dev->dev_private; struct intel_context *ctx = NULL; struct i915_ctx_hang_stats *hs; @@ -867,5 +883,13 @@ i915_gem_context_validate(struct drm_device *dev, struct drm_file *file, return ERR_PTR(-EIO); } + if (dev_priv->lrc_enabled && !ctx->engine[ring->id].obj) { + int ret = intel_lr_context_deferred_create(ctx, ring); + if (ret) { + DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret); + return ERR_PTR(ret); + } + } + return ctx; }