From patchwork Tue Aug 14 21:35:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 1324431 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 683A83FD8C for ; Wed, 15 Aug 2012 00:20:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AE00A0A28 for ; Tue, 14 Aug 2012 17:20:56 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.chad-versace.us (209-20-75-48.static.cloud-ips.com [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BF549F393 for ; Tue, 14 Aug 2012 14:35:48 -0700 (PDT) Received: by shiva.chad-versace.us (Postfix, from userid 1005) id C1887885A4; Tue, 14 Aug 2012 21:35:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on shiva.chad-versace.us X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.2 Received: from stallone.nims.intel.com (unknown [192.102.209.254]) by shiva.chad-versace.us (Postfix) with ESMTPSA id 4A192885C7; Tue, 14 Aug 2012 21:35:36 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Tue, 14 Aug 2012 14:35:15 -0700 Message-Id: <1344980117-1993-4-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1344980117-1993-1-git-send-email-ben@bwidawsk.net> References: <1344980117-1993-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 3/5] drm/i915/contexts: Switch to default on resume 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+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org In order to make the HW state CCID match with what we think it should be, we must order a switch to the default context. The really sad thing here is that the switch can potentially fail, and as such we have to assume contexts no longer work. There is likely room for improvement but until we actually start seeing the case occur, I think it should be fine. This was accidentally left this out of the first series, noticed by Chris Wilson. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_context.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 5c2d354..3e884dc 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -244,15 +244,26 @@ void i915_gem_context_init(struct drm_device *dev) struct drm_i915_private *dev_priv = dev->dev_private; uint32_t ctx_size; + if (dev_priv->hw_contexts_disabled) + return; + if (!HAS_HW_CONTEXTS(dev)) { dev_priv->hw_contexts_disabled = true; return; } - /* If called from reset, or thaw... we've been here already */ - if (dev_priv->hw_contexts_disabled || - dev_priv->ring[RCS].default_context) + /* If called from reset, or thaw we want to switch back to the default + * context so our HW CCID matches what we think it should be in software. + */ + if (dev_priv->ring[RCS].default_context) { + int ret = do_switch(dev_priv->ring[RCS].default_context); + if (ret) { + DRM_ERROR("HW contexts were broken after resume\n"); + i915_gem_context_fini(dev); + dev_priv->hw_contexts_disabled = true; + } return; + } ctx_size = get_context_size(dev); dev_priv->hw_context_size = get_context_size(dev);