@@ -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;
}
@@ -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,
@@ -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
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@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(-)