From ef30e9aa2012e258d314ff8089fe1b0613ec37bd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 10 Jun 2011 21:04:13 +0100 Subject: [PATCH] drm/i915: Disable page-faults around the fast pwrite/pread paths These paths hold onto the struct mutex whilst accessing pages. In order, to prevent a recursive dead-lock should we fault-in a GTT mapped page we need to return -EFAULT and fallback to the slow path. Lockdep has complained before about the potential dead-lock, but rvis is the first application found to sufficiently abuse the API to trigger it. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38115 Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 890af70..0a3a131 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -556,8 +556,11 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, goto out; ret = -EFAULT; - if (!i915_gem_object_needs_bit17_swizzle(obj)) + if (!i915_gem_object_needs_bit17_swizzle(obj)) { + pagefault_disable(); ret = i915_gem_shmem_pread_fast(dev, obj, args, file); + pagefault_enable(); + } if (ret == -EFAULT) ret = i915_gem_shmem_pread_slow(dev, obj, args, file); @@ -1013,7 +1016,9 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, if (ret) goto out_unpin; + pagefault_disable(); ret = i915_gem_gtt_pwrite_fast(dev, obj, args, file); + pagefault_enable(); if (ret == -EFAULT) ret = i915_gem_gtt_pwrite_slow(dev, obj, args, file); @@ -1025,8 +1030,11 @@ out_unpin: goto out; ret = -EFAULT; - if (!i915_gem_object_needs_bit17_swizzle(obj)) + if (!i915_gem_object_needs_bit17_swizzle(obj)) { + pagefault_disable(); ret = i915_gem_shmem_pwrite_fast(dev, obj, args, file); + pagefault_enable(); + } if (ret == -EFAULT) ret = i915_gem_shmem_pwrite_slow(dev, obj, args, file); } -- 1.7.5.3