drm/i915/gem: Defer obj->base.resv fini until RCU callback
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 3 Jul 2019 18:06:01 +0000 (19:06 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 4 Jul 2019 14:34:35 +0000 (15:34 +0100)
commit0c159ffef628fa94d0f4f9128e7f2b6f2b5e86ef
treeb03539a32585baf353d26f051bef55c9de15899d
parent21de5a9e34fb0f3efa31df5712cedc0ae97f7b4d
drm/i915/gem: Defer obj->base.resv fini until RCU callback

Since reservation_object_fini() does an immediate free, rather than
kfree_rcu as normal, we have to delay the release until after the RCU
grace period has elapsed (i.e. from the rcu cleanup callback) so that we
can rely on the RCU protected access to the fences while the object is a
zombie.

i915_gem_busy_ioctl relies on having an RCU barrier to protect the
reservation in order to avoid having to take a reference and strong
memory barriers.

v2: Order is important; only release after putting the pages!

Fixes: c03467ba40f7 ("drm/i915/gem: Free pages before rcu-freeing the object")
Testcase: igt/gem_busy/close-race
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190703180601.10950-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/i915_gem_object.c
drivers/gpu/drm/i915/gem/i915_gem_phys.c
drivers/gpu/drm/i915/gem/i915_gem_shmem.c
drivers/gpu/drm/i915/gem/i915_gem_stolen.c