We can now grab a reference to all the fences in question, no need for the sequence counter any more. Signed-off-by: Christian König <christian.koenig@xxxxxxx> --- drivers/dma-buf/dma-resv.c | 22 ++-------------------- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 13 ++++--------- include/linux/dma-resv.h | 3 --- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 7fa0e86b4e75..51067edff930 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -50,12 +50,6 @@ DEFINE_WD_CLASS(reservation_ww_class); EXPORT_SYMBOL(reservation_ww_class); -struct lock_class_key reservation_seqcount_class; -EXPORT_SYMBOL(reservation_seqcount_class); - -const char reservation_seqcount_string[] = "reservation_seqcount"; -EXPORT_SYMBOL(reservation_seqcount_string); - static void dma_resv_fences_init(struct dma_resv_fences *fences) { RCU_INIT_POINTER(fences->fence, NULL); @@ -244,8 +238,6 @@ void dma_resv_init(struct dma_resv *obj) { ww_mutex_init(&obj->lock, &reservation_ww_class); - __seqcount_init(&obj->seq, reservation_seqcount_string, - &reservation_seqcount_class); RCU_INIT_POINTER(obj->fence_excl, NULL); dma_resv_fences_init(&obj->shared); } @@ -321,13 +313,8 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence) dma_fence_get(fence); - preempt_disable(); - write_seqcount_begin(&obj->seq); - /* write_seqcount_begin provides the necessary memory barrier */ - RCU_INIT_POINTER(obj->fence_excl, fence); + rcu_assign_pointer(obj->fence_excl, fence); dma_resv_fences_set(obj, &obj->shared, NULL); - write_seqcount_end(&obj->seq); - preempt_enable(); dma_fence_put(old_fence); } @@ -377,13 +364,8 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src) old = dma_resv_get_excl(dst); - preempt_disable(); - write_seqcount_begin(&dst->seq); - /* write_seqcount_begin provides the necessary memory barrier */ - RCU_INIT_POINTER(dst->fence_excl, excl); + rcu_assign_pointer(dst->fence_excl, excl); dma_resv_fences_set(dst, &dst->shared, shared); - write_seqcount_end(&dst->seq); - preempt_enable(); dma_fence_put(old); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 0ef338a8cd9f..34256fff1f90 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -86,7 +86,6 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, struct dma_fence_array_cursor cursor; struct dma_fence *fence, *shared; struct drm_i915_gem_object *obj; - unsigned int seq; int err; err = -ENOENT; @@ -112,22 +111,18 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, * to report the overall busyness. This is what the wait-ioctl does. * */ -retry: - seq = raw_read_seqcount(&obj->base.resv->seq); + shared = dma_resv_fences_get_rcu(&obj->base.resv->shared); + fence = dma_fence_get_rcu_safe(&obj->base.resv->fence_excl); /* Translate the exclusive fence to the READ *and* WRITE engine */ - args->busy = - busy_check_writer(rcu_dereference(obj->base.resv->fence_excl)); + args->busy = busy_check_writer(fence); + dma_fence_put(fence); /* Translate shared fences to READ set of engines */ - shared = dma_resv_fences_get_rcu(&obj->base.resv->shared); dma_fence_array_for_each(fence, cursor, shared) args->busy |= busy_check_reader(fence); dma_fence_put(shared); - if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) - goto retry; - err = 0; out: rcu_read_unlock(); diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h index 040e3f04a8ad..44f975d772e8 100644 --- a/include/linux/dma-resv.h +++ b/include/linux/dma-resv.h @@ -48,8 +48,6 @@ struct dma_resv; extern struct ww_class reservation_ww_class; -extern struct lock_class_key reservation_seqcount_class; -extern const char reservation_seqcount_string[]; /** * struct dma_resv_fences - fences inside a reservation object @@ -81,7 +79,6 @@ void dma_resv_fences_commit(struct dma_resv *obj, */ struct dma_resv { struct ww_mutex lock; - seqcount_t seq; struct dma_fence __rcu *fence_excl; struct dma_resv_fences shared; -- 2.17.1