From patchwork Thu Jun 12 15:25: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: 4342521 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 455849F333 for ; Thu, 12 Jun 2014 15:26:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 455DB20220 for ; Thu, 12 Jun 2014 15:26:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 40EB42020F for ; Thu, 12 Jun 2014 15:26:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF38F6E4EE; Thu, 12 Jun 2014 08:26:15 -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 5B92E6E4EE for ; Thu, 12 Jun 2014 08:26:14 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 12 Jun 2014 08:26:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,465,1400050800"; d="scan'208";a="554462915" Received: from unknown (HELO ironside.intel.com) ([10.255.13.61]) by fmsmga002.fm.intel.com with ESMTP; 12 Jun 2014 08:25:53 -0700 From: Ben Widawsky To: Intel GFX Date: Thu, 12 Jun 2014 08:25:52 -0700 Message-Id: <1402586752-22484-1-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 2.0.0 Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [REPOST] [PATCH] drm/i915/ppgtt: Load address space after mi_set_context 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 On GEN8 the PDPs are saved and restored with context, which means we must set them after the context switch has occurred. If we do not do this, we end up saving the new PDPs for the old context. Example of a problem LRI PDPs 1 MI_SET_CONTEXT bar LRI_PDPs 2 MI_SET_CONTEXT foo // save PDPs 2 to bar's context // load foos PDPs LRI PDPs 1 MI_SET_CONTEXT bar // save PDPs 1 to foo's context It's all wacky. This should allow full PPGTT on Broadwell to work. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_context.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 3ffe308..b2434e0 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -623,13 +623,12 @@ static int do_switch(struct intel_engine_cs *ring, */ from = ring->last_context; - if (USES_FULL_PPGTT(ring->dev)) { - ret = ppgtt->switch_mm(ppgtt, ring, false); - if (ret) - goto unpin_out; - } - if (ring != &dev_priv->ring[RCS]) { + if (USES_FULL_PPGTT(ring->dev)) { + ret = ppgtt->switch_mm(ppgtt, ring, false); + if (ret) + goto unpin_out; + } if (from) i915_gem_context_unreference(from); goto done; @@ -660,6 +659,19 @@ static int do_switch(struct intel_engine_cs *ring, if (ret) goto unpin_out; + if (USES_FULL_PPGTT(ring->dev)) { + ret = ppgtt->switch_mm(ppgtt, ring, false); + /* The hardware context switch is emitted, but we haven't + * actually changed the state - so it's probably safe to bail + * here. Still, let the user know something dangerous has + * happened. + */ + if (ret) { + DRM_ERROR("Failed to change address space on context switch\n"); + goto unpin_out; + } + } + for (i = 0; i < MAX_L3_SLICES; i++) { if (!(to->remap_slice & (1<