From patchwork Sat May 10 03:59:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 4146291 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 A76029F23C for ; Sat, 10 May 2014 04:01:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0622201DC for ; Sat, 10 May 2014 04:01:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E0904200B4 for ; Sat, 10 May 2014 04:01:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64A856F08E; Fri, 9 May 2014 21:01:55 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.bwidawsk.net (bwidawsk.net [166.78.191.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D5706F08E for ; Fri, 9 May 2014 21:01:54 -0700 (PDT) Received: by mail.bwidawsk.net (Postfix, from userid 5001) id A284958083; Fri, 9 May 2014 21:01:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: 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 Received: from ironside.intel.com (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by mail.bwidawsk.net (Postfix) with ESMTPSA id 9EF3D5808C; Fri, 9 May 2014 21:00:20 -0700 (PDT) From: Ben Widawsky To: Intel GFX Date: Fri, 9 May 2014 20:59:28 -0700 Message-Id: <1399694391-3935-34-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1399694391-3935-1-git-send-email-benjamin.widawsky@intel.com> References: <1399694391-3935-1-git-send-email-benjamin.widawsky@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH 33/56] drm/i915/bdw: Make the pdp switch a bit less hacky 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-Virus-Scanned: ClamAV using ClamSMTP One important part of this patch is we now write a scratch page directory into any unused PDP descriptors. This matters for 2 reasons, first, it's not clear we're allowed to just use 0, or an invalid pointer, and second, we must wipe out any previous contents from the last context. The latter point only matters with full PPGTT. The former point would only effect 32b platforms, or platforms with less than 4GB memory. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_gtt.c | 32 ++++++++++++++++++++------------ drivers/gpu/drm/i915/i915_gem_gtt.h | 5 ++++- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 041ddca..a895f4b 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -390,8 +390,10 @@ static struct i915_pagedir *alloc_pd_single(struct drm_device *dev) } /* Broadwell Page Directory Pointer Descriptors */ -static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry, - uint64_t val, bool synchronous) +static int gen8_write_pdp(struct intel_ring_buffer *ring, + unsigned entry, + dma_addr_t addr, + bool synchronous) { struct drm_i915_private *dev_priv = ring->dev->dev_private; int ret; @@ -399,8 +401,8 @@ static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry, BUG_ON(entry >= 4); if (synchronous) { - I915_WRITE(GEN8_RING_PDP_UDW(ring, entry), val >> 32); - I915_WRITE(GEN8_RING_PDP_LDW(ring, entry), (u32)val); + I915_WRITE(GEN8_RING_PDP_UDW(ring, entry), upper_32_bits(addr)); + I915_WRITE(GEN8_RING_PDP_LDW(ring, entry), lower_32_bits(addr)); return 0; } @@ -410,10 +412,10 @@ static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry, intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1)); intel_ring_emit(ring, GEN8_RING_PDP_UDW(ring, entry)); - intel_ring_emit(ring, (u32)(val >> 32)); + intel_ring_emit(ring, upper_32_bits(addr)); intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1)); intel_ring_emit(ring, GEN8_RING_PDP_LDW(ring, entry)); - intel_ring_emit(ring, (u32)(val)); + intel_ring_emit(ring, lower_32_bits(addr)); intel_ring_advance(ring); return 0; @@ -425,11 +427,11 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt, { int i, ret; - /* bit of a hack to find the actual last used pd */ - int used_pd = ppgtt->num_pd_entries / I915_PDES_PER_PD; - - for (i = used_pd - 1; i >= 0; i--) { - dma_addr_t addr = ppgtt->pdp.pagedirs[i]->daddr; + for (i = GEN8_LEGACY_PDPES - 1; i >= 0; i--) { + struct i915_pagedir *pd = ppgtt->pdp.pagedirs[i]; + dma_addr_t addr = pd ? pd->daddr : ppgtt->scratch_pt->daddr; + /* The page directory might be NULL, but we need to clear out + * whatever the previous context might have used. */ ret = gen8_write_pdp(ring, i, addr, synchronous); if (ret) return ret; @@ -689,10 +691,16 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt, uint64_t size) ppgtt->base.start = 0; ppgtt->base.total = size; + ppgtt->scratch_pd = alloc_pt_scratch(ppgtt->base.dev); + if (IS_ERR(ppgtt->scratch_pd)) + return PTR_ERR(ppgtt->scratch_pd); + /* 1. Do all our allocations for page directories and page tables. */ ret = gen8_ppgtt_alloc(ppgtt, ppgtt->base.start, ppgtt->base.total); - if (ret) + if (ret) { + free_pt_scratch(ppgtt->scratch_pd, ppgtt->base.dev); return ret; + } /* * 2. Map all the page directory entires to point to the page tables diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h index fae0867..5c6db90 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.h +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h @@ -267,7 +267,10 @@ struct i915_hw_ppgtt { struct i915_pagedir pd; }; - struct i915_pagetab *scratch_pt; + union { + struct i915_pagetab *scratch_pt; + struct i915_pagetab *scratch_pd; /* Just need the daddr */ + }; struct i915_hw_context *ctx;