From patchwork Thu Mar 27 17:59:58 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: 3898711 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 06D9C9F388 for ; Thu, 27 Mar 2014 17:09:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29CA52025A for ; Thu, 27 Mar 2014 17:09:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B957120253 for ; Thu, 27 Mar 2014 17:09:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1EA576EA09; Thu, 27 Mar 2014 10:09:49 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id D93936E9FB for ; Thu, 27 Mar 2014 10:09:41 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 27 Mar 2014 10:03:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,743,1389772800"; d="scan'208";a="501086832" Received: from omateolo-linux2.iwi.intel.com ([172.28.253.148]) by fmsmga001.fm.intel.com with ESMTP; 27 Mar 2014 10:06:17 -0700 From: oscar.mateo@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 27 Mar 2014 17:59:58 +0000 Message-Id: <1395943218-7708-30-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395943218-7708-1-git-send-email-oscar.mateo@intel.com> References: <1395943218-7708-1-git-send-email-oscar.mateo@intel.com> Subject: [Intel-gfx] [PATCH 29/49] drm/i915/bdw: Pin context pages at context create time 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.6 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 For the moment, this is simple and works allright. When we start having a lot of contexts, this is going to become problematic. Signed-off-by: Oscar Mateo --- drivers/gpu/drm/i915/i915_lrc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_lrc.c b/drivers/gpu/drm/i915/i915_lrc.c index d5afb0d..74ab558 100644 --- a/drivers/gpu/drm/i915/i915_lrc.c +++ b/drivers/gpu/drm/i915/i915_lrc.c @@ -41,6 +41,8 @@ #include #include "i915_drv.h" +#define GEN8_CONTEXT_ALIGN 4096 + #define GEN8_LR_CONTEXT_SIZE (21 * PAGE_SIZE) #define RING_ELSP(ring) ((ring)->mmio_base+0x230) @@ -86,6 +88,7 @@ void gen8_gem_context_free(struct i915_hw_context *ctx) ctx->ringbuf->obj = NULL; kfree(ctx->ringbuf); ctx->ringbuf = NULL; + i915_gem_object_ggtt_unpin(ctx->obj); } } @@ -108,10 +111,18 @@ gen8_gem_create_context(struct drm_device *dev, if (IS_ERR_OR_NULL(ctx)) return ctx; + if (file_priv) { + ret = i915_gem_obj_ggtt_pin(ctx->obj, GEN8_CONTEXT_ALIGN, 0); + if (ret) { + DRM_DEBUG_DRIVER("Couldn't pin %d\n", ret); + i915_gem_context_unreference(ctx); + return ERR_PTR(ret); + } + } + ring_obj = i915_gem_alloc_object(dev, 32 * PAGE_SIZE); if (!ring_obj) { - if (!file_priv) - i915_gem_object_ggtt_unpin(ctx->obj); + i915_gem_object_ggtt_unpin(ctx->obj); i915_gem_context_unreference(ctx); return ERR_PTR(-ENOMEM); } @@ -124,8 +135,7 @@ gen8_gem_create_context(struct drm_device *dev, ret = i915_gem_obj_ggtt_pin(ring_obj, PAGE_SIZE, PIN_MAPPABLE); if (ret) { drm_gem_object_unreference(&ring_obj->base); - if (!file_priv) - i915_gem_object_ggtt_unpin(ctx->obj); + i915_gem_object_ggtt_unpin(ctx->obj); i915_gem_context_unreference(ctx); return ERR_PTR(ret); } @@ -272,8 +282,7 @@ destroy_ring_obj: i915_gem_object_ggtt_unpin(ring_obj); drm_gem_object_unreference(&ring_obj->base); ctx->ringbuf->obj = NULL; - if (!file_priv) - i915_gem_object_ggtt_unpin(ctx->obj); + i915_gem_object_ggtt_unpin(ctx->obj); i915_gem_context_unreference(ctx); return ERR_PTR(ret);