From patchwork Tue Feb 18 03:01:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 3666961 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 ECF59BF40C for ; Tue, 18 Feb 2014 03:02:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0435B20107 for ; Tue, 18 Feb 2014 03:02:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C5BCB20109 for ; Tue, 18 Feb 2014 03:02:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0534FA957; Mon, 17 Feb 2014 19:02:26 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id B401EFA924 for ; Mon, 17 Feb 2014 19:02:08 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 17 Feb 2014 19:02:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,499,1389772800"; d="scan'208";a="484967349" Received: from unknown (HELO ironside.amr.corp.intel.com) ([10.255.13.201]) by orsmga002.jf.intel.com with ESMTP; 17 Feb 2014 19:02:04 -0800 From: Ben Widawsky To: Intel GFX Date: Mon, 17 Feb 2014 19:01:52 -0800 Message-Id: <1392692512-2268-12-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1392692512-2268-1-git-send-email-benjamin.widawsky@intel.com> References: <1390969547-1018-2-git-send-email-benjamin.widawsky@intel.com> <1392692512-2268-1-git-send-email-benjamin.widawsky@intel.com> Cc: "David E. Box" , Ben Widawsky , Kristen Carlson Accardi , Ben Widawsky Subject: [Intel-gfx] [PATCH 11/11] drm/i915/bdw: Ensure a context is loaded before RC6 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org 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 RC6 works a lot like HW contexts in that when the GPU enters RC6 it saves away the state to a context, and loads it upon wake. It's to be somewhat expected that BIOS will not set up valid GPU state. As a result, if loading bad state can cause the GPU to get angry, it would make sense then that we need to load state first. There are two ways in which we can do this: 1. Create 3d state in the driver, load it up, then enable RC6. 1b. Reuse a known good state, [and if needed,] just bind objects where needed. Then enable RC6. 2. Hold off enabling RC6 until userspace has had a chance to complete batches. There has been discussions in the past with #1 as it has been recommended for fixes elsewhere. I'm not opposed to it, I'd just like to do the easy thing now to enable the platform. This patch is a hack that implement option #2. It will defer enabling rc6 until the first batch from userspace has been retired. It suffers two flaws. The first is, if the driver is loaded, but a batch is not submitted/completed, we'll never enter rc6. The other is, it expects userspace to submit a batch with 3d state first. Both of these things are not actual flaws for most users because most users will boot to a graphical composited desktop. Both mesa, and X will always emit the necessary 3d state. Once a context is loaded and we enable rc6, the default context should inherit the proper state because we always inhibit the restore for the default context. This assumes certain things about the workaround/issue itself to which I am not privy (primarily that the indirect state objects don't actually need to exist). With that, there are currently 4 options for BDW: 1. Don't use RC6. 2. Use RC6 and expect a hang on the first batch submitted for every context. 3. Use RC6 and use this patch. 4. Wait for another workaround implementation. NOTE: This patch could be used against other platforms as well. The fact that RC6 residency continues to increment, and that this patch prevents a hang on BDW silicon has been: Tested-by: Kenneth Graunke Cc: David E. Box Cc: Kristen Carlson Accardi Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++++ drivers/gpu/drm/i915/intel_display.c | 5 +++++ drivers/gpu/drm/i915/intel_pm.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 3618bb0..07170a7 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2420,6 +2420,7 @@ void i915_gem_reset(struct drm_device *dev) void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring) { + static bool rc6_enabled = false; uint32_t seqno; if (list_empty(&ring->request_list)) @@ -2443,6 +2444,17 @@ i915_gem_retire_requests_ring(struct intel_ring_buffer *ring) if (!i915_seqno_passed(seqno, obj->last_read_seqno)) break; + /* Wa: can't find the w/a name. + * This doesn't actually implement the w/a, but it a workaround + * for the workaround. It defers using rc6 until we know valid + * state exists. + */ + if (IS_BROADWELL(dev) && intel_enable_rc6(dev) && + !rc6_enabled && ring->id == RCS &&) { + intel_enable_gt_powersave(ring->dev); + rc6_enabled = true; + } + i915_gem_object_move_to_inactive(obj); } diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f19e6ea..72c8e1d 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -10983,6 +10983,11 @@ void intel_modeset_init_hw(struct drm_device *dev) intel_reset_dpio(dev); + if (IS_BROADWELL(dev)) { + DRM_DEBUG_DRIVER("Deferring RC6 enabling until first batch is complete\n"); + return; + } + mutex_lock(&dev->struct_mutex); intel_enable_gt_powersave(dev); mutex_unlock(&dev->struct_mutex); diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index a03a12e..c2980ff 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -4513,7 +4513,7 @@ void intel_enable_gt_powersave(struct drm_device *dev) ironlake_enable_drps(dev); ironlake_enable_rc6(dev); intel_init_emon(dev); - } else if (IS_GEN6(dev) || IS_GEN7(dev) || IS_BROADWELL(dev)) { + } else if (IS_GEN6(dev) || IS_GEN7(dev)) { /* * PCU communication is slow and this doesn't need to be * done at any specific time, so do this out of our fast path