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 <ben at bwidawsk.net> --- 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 -- 1.8.3.1