From patchwork Fri May 9 12:08:50 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: 4142321 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 BAC1A9F1E1 for ; Fri, 9 May 2014 12:14:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBBC3201D3 for ; Fri, 9 May 2014 12:14:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0C295201B4 for ; Fri, 9 May 2014 12:14:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 735D16E539; Fri, 9 May 2014 05:14:48 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 38FAE4A05A for ; Fri, 9 May 2014 05:14:47 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 09 May 2014 05:14:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="4.97,1018,1389772800"; d="scan'208"; a="529106941" Received: from omateolo-linux2.iwi.intel.com ([172.28.253.145]) by fmsmga001.fm.intel.com with ESMTP; 09 May 2014 05:14:45 -0700 From: oscar.mateo@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 9 May 2014 13:08:50 +0100 Message-Id: <1399637360-4277-21-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1399637360-4277-1-git-send-email-oscar.mateo@intel.com> References: <1399637360-4277-1-git-send-email-oscar.mateo@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 20/50] drm/i915/bdw: Rework init code for Logical Ring Contexts 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: Ben Widawsky This modifies the init code to try to start logical ring contexts when possible, and fall back to legacy ringbuffers when not. Most importantly, things make things easy if we do the context creation before ringbuffer initialization. Upcoming patches will make it clearer why that is. For the initial enabling of execlists, the ringbuffer code will be reused a decent amount. As such this code will have to change, but it helps with enabling to be able to run through a bunch of the context init, and still have a system boot. Finally, for the bikeshedders out there: I've tried merging the legacy hw context init functionality, ie. one init function, and this logic was in the context creation. The resulting code was much uglier and for no real gain. Signed-off-by: Ben Widawsky v2: Rebased on top of the Full PPGTT series. Signed-off-by: Oscar Mateo v3: Factor out a enable_execlists() function so it's clear what the condition is. Use module parameter to enable. Signed-off-by: Damien Lespiau --- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_gem.c | 24 +++++++++++++++++++----- drivers/gpu/drm/i915/intel_lrc.c | 5 +++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index bd93dc2..41d3f95 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2425,6 +2425,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file); +/* intel_lrc.c */ +int gen8_gem_context_init(struct drm_device *dev); + /* i915_gem_evict.c */ int __must_check i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 4a22560..f8acf3d 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4490,10 +4490,18 @@ i915_gem_init_hw(struct drm_device *dev) return ret; } +static bool enable_execlists(struct drm_device *dev) +{ + if (!i915.enable_execlists) + return false; + + return HAS_LOGICAL_RING_CONTEXTS(dev) && USES_PPGTT(dev); +} + int i915_gem_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; - int ret; + int ret = -1; mutex_lock(&dev->struct_mutex); @@ -4509,11 +4517,17 @@ int i915_gem_init(struct drm_device *dev) intel_init_rings_early(dev); - ret = i915_gem_context_init(dev); + if (enable_execlists(dev)) + ret = gen8_gem_context_init(dev); + if (ret) { - mutex_unlock(&dev->struct_mutex); - return ret; - } + ret = i915_gem_context_init(dev); + if (ret) { + mutex_unlock(&dev->struct_mutex); + return ret; + } + } else + dev_priv->lrc_enabled = true; ret = i915_gem_init_hw(dev); if (ret == -EIO) { diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 49bb6fc..3a93e99 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -40,3 +40,8 @@ #include #include #include "i915_drv.h" + +int gen8_gem_context_init(struct drm_device *dev) +{ + return -ENOSYS; +}