From patchwork Fri Jun 28 22:23:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2802591 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 85897BF4A1 for ; Fri, 28 Jun 2013 22:22:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D8A32028F for ; Fri, 28 Jun 2013 22:22:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AD3D120286 for ; Fri, 28 Jun 2013 22:22:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7362E672A for ; Fri, 28 Jun 2013 15:22:04 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (unknown [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id C6C85E6346 for ; Fri, 28 Jun 2013 15:20:34 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 99) id 55A6088652; Fri, 28 Jun 2013 22:20:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lundgren.kumite (c-24-21-100-90.hsd1.or.comcast.net [24.21.100.90]) by shiva.localdomain (Postfix) with ESMTPSA id 42A11884FB; Fri, 28 Jun 2013 22:20:33 +0000 (UTC) From: Ben Widawsky To: Intel GFX Date: Fri, 28 Jun 2013 15:23:34 -0700 Message-Id: <1372458217-2053-4-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1372458217-2053-1-git-send-email-ben@bwidawsk.net> References: <1372458217-2053-1-git-send-email-ben@bwidawsk.net> Cc: Paul Berry , Ben Widawsky Subject: [Intel-gfx] [PATCH 3/6] drm/i915: Reset scratch pages when using debug_flags 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 X-Virus-Scanned: ClamAV using ClamSMTP Instead of waiting an indeterminate amount of time for ranges to get cleared with the PTEs that will fault, do it immediately. Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_debugfs.c | 7 +++++++ drivers/gpu/drm/i915/i915_drv.h | 4 +++- drivers/gpu/drm/i915/i915_gem_gtt.c | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 5d6a020..86e750c 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -2198,6 +2198,7 @@ i915_debug_flags_set(void *data, u64 val) { struct drm_device *dev = data; struct drm_i915_private *dev_priv = dev->dev_private; + u64 old_flags = dev_priv->debug_flags; int ret; /* FIXME?: Nothing prevents this from working pre GEN6; but don't want @@ -2209,7 +2210,13 @@ i915_debug_flags_set(void *data, u64 val) ret = mutex_lock_interruptible(&dev->struct_mutex); if (ret) return ret; + dev_priv->debug_flags = val; + + /* If setting or unsetting scratch faults, we need special handling */ + if ((old_flags ^ val) & I915_SCRATCH_FAULTS) + i915_gem_rewrite_scratch_ptes(dev); + mutex_unlock(&dev_priv->dev->struct_mutex); return 0; } diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 7a98f7e..b99087f8 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1865,7 +1865,9 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev) if (INTEL_INFO(dev)->gen < 6) intel_gtt_chipset_flush(); } - +#ifdef CONFIG_DEBUG_FS +void i915_gem_rewrite_scratch_ptes(struct drm_device *dev); +#endif /* i915_gem_evict.c */ int __must_check i915_gem_evict_something(struct drm_device *dev, int min_size, diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 982c791..f71636e 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -889,3 +889,23 @@ int i915_gem_gtt_init(struct drm_device *dev) return 0; } + +#ifdef CONFIG_DEBUG_FS +void i915_gem_rewrite_scratch_ptes(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + struct drm_mm_node *n; + unsigned long start, end; + struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; + + drm_mm_for_each_hole(n, &dev_priv->mm.gtt_space, start, end) { + dev_priv->gtt.gtt_clear_range(dev, + start >> PAGE_SHIFT, + (end - start) >> PAGE_SHIFT); + if (ppgtt) + ppgtt->clear_range(ppgtt, + start >> PAGE_SHIFT, + (end - start) >> PAGE_SHIFT); + } +} +#endif