Commit 6edbd6ab authored by Christian König's avatar Christian König
Browse files

dma-buf: rename and cleanup dma_resv_get_excl v3



When the comment needs to state explicitly that this
doesn't get a reference to the object then the function
is named rather badly.

Rename the function and use rcu_dereference_check(), this
way it can be used from both rcu as well as lock protected
critical sections.

v2: improve kerneldoc as suggested by Daniel
v3: use dma_resv_excl_fence as function name

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarJason Ekstrand <jason@jlekstrand.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20210602111714.212426-4-christian.koenig@amd.com
parent 415f6767
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
		shared_count = fobj->shared_count;
	else
		shared_count = 0;
	fence_excl = rcu_dereference(resv->fence_excl);
	fence_excl = dma_resv_excl_fence(resv);
	if (read_seqcount_retry(&resv->seq, seq)) {
		rcu_read_unlock();
		goto retry;
@@ -1382,8 +1382,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
				buf_obj->name ?: "");

		robj = buf_obj->resv;
		fence = rcu_dereference_protected(robj->fence_excl,
						  dma_resv_held(robj));
		fence = dma_resv_excl_fence(robj);
		if (fence)
			seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n",
				   fence->ops->get_driver_name(fence),
+5 −5
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ EXPORT_SYMBOL(dma_resv_add_shared_fence);
 */
void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
{
	struct dma_fence *old_fence = dma_resv_get_excl(obj);
	struct dma_fence *old_fence = dma_resv_excl_fence(obj);
	struct dma_resv_list *old;
	u32 i = 0;

@@ -380,7 +380,7 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
	rcu_read_unlock();

	src_list = dma_resv_get_list(dst);
	old = dma_resv_get_excl(dst);
	old = dma_resv_excl_fence(dst);

	write_seqcount_begin(&dst->seq);
	/* write_seqcount_begin provides the necessary memory barrier */
@@ -428,7 +428,7 @@ int dma_resv_get_fences_rcu(struct dma_resv *obj,
		rcu_read_lock();
		seq = read_seqcount_begin(&obj->seq);

		fence_excl = rcu_dereference(obj->fence_excl);
		fence_excl = dma_resv_excl_fence(obj);
		if (fence_excl && !dma_fence_get_rcu(fence_excl))
			goto unlock;

@@ -523,7 +523,7 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
	rcu_read_lock();
	i = -1;

	fence = rcu_dereference(obj->fence_excl);
	fence = dma_resv_excl_fence(obj);
	if (fence && !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
		if (!dma_fence_get_rcu(fence))
			goto unlock_retry;
@@ -645,7 +645,7 @@ bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
	}

	if (!shared_count) {
		struct dma_fence *fence_excl = rcu_dereference(obj->fence_excl);
		struct dma_fence *fence_excl = dma_resv_excl_fence(obj);

		if (fence_excl) {
			ret = dma_resv_test_signaled_single(fence_excl);
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj,
	if (!amdgpu_vm_ready(vm))
		goto out_unlock;

	fence = dma_resv_get_excl(bo->tbo.base.resv);
	fence = dma_resv_excl_fence(bo->tbo.base.resv);
	if (fence) {
		amdgpu_bo_fence(bo, fence, true);
		fence = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ int amdgpu_sync_resv(struct amdgpu_device *adev, struct amdgpu_sync *sync,
		return -EINVAL;

	/* always sync to the exclusive fence */
	f = dma_resv_get_excl(resv);
	f = dma_resv_excl_fence(resv);
	r = amdgpu_sync_fence(sync, f);

	flist = dma_resv_get_list(resv);
+1 −1
Original line number Diff line number Diff line
@@ -471,7 +471,7 @@ static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
		}
	}

	fence = rcu_dereference(robj->fence_excl);
	fence = dma_resv_excl_fence(robj);
	if (fence)
		etnaviv_gem_describe_fence(fence, "Exclusive", m);
	rcu_read_unlock();
Loading