OSDN Git Service

drm/i915: Restrict pagefault disabling to just around copy_from_user()
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 18 Oct 2016 12:02:51 +0000 (13:02 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 18 Oct 2016 13:22:27 +0000 (14:22 +0100)
commitebc0808fa2da0548a78e715858024cb81cd732bc
tree40a3f1bb4776fe513f3bc016090c0440317d4824
parent4ff340f0617d02ab67a087977883ef8eff36bd68
drm/i915: Restrict pagefault disabling to just around copy_from_user()

When handling execbuf relocations, we play a delicate dance with
pagefault. We first try to access the user pages underneath our
struct_mutex. However, if those pages were inside a GEM object, we may
trigger a pagefault and deadlock as i915_gem_fault() tries to
recursively acquire struct_mutex. Instead, we choose to disable
pagefaulting around the copy_from_user whilst inside the struct_mutex
and handle the EFAULT by falling back to a copy outside the
struct_mutex.

We however presumed that disabling pagefaults would be expensive. It is
just an operation on the local current task. Cheap enough that we can
restrict the disable/enable to the critical section around the copy, and
so avoid having to handle the atomic sections within the relocation
handling itself.

v2: Just illustrate the broken error handling rather than argue why it
is safer to ignore it, for now.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161018120251.25043-4-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_execbuffer.c