Skip to content

Commit d3fae3b

Browse files
dma-buf: drop the _rcu postfix on function names v3
The functions can be called both in _rcu context as well as while holding the lock. v2: add some kerneldoc as suggested by Daniel v3: fix indentation Signed-off-by: Christian König <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6b41323 commit d3fae3b

31 files changed

+84
-103
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,7 @@ static int __dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
11471147
long ret;
11481148

11491149
/* Wait on any implicit rendering fences */
1150-
ret = dma_resv_wait_timeout_rcu(resv, write, true,
1151-
MAX_SCHEDULE_TIMEOUT);
1150+
ret = dma_resv_wait_timeout(resv, write, true, MAX_SCHEDULE_TIMEOUT);
11521151
if (ret < 0)
11531152
return ret;
11541153

drivers/dma-buf/dma-resv.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
396396
EXPORT_SYMBOL(dma_resv_copy_fences);
397397

398398
/**
399-
* dma_resv_get_fences_rcu - Get an object's shared and exclusive
399+
* dma_resv_get_fences - Get an object's shared and exclusive
400400
* fences without update side lock held
401401
* @obj: the reservation object
402402
* @pfence_excl: the returned exclusive fence (or NULL)
@@ -408,10 +408,9 @@ EXPORT_SYMBOL(dma_resv_copy_fences);
408408
* exclusive fence is not specified the fence is put into the array of the
409409
* shared fences as well. Returns either zero or -ENOMEM.
410410
*/
411-
int dma_resv_get_fences_rcu(struct dma_resv *obj,
412-
struct dma_fence **pfence_excl,
413-
unsigned int *pshared_count,
414-
struct dma_fence ***pshared)
411+
int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
412+
unsigned int *pshared_count,
413+
struct dma_fence ***pshared)
415414
{
416415
struct dma_fence **shared = NULL;
417416
struct dma_fence *fence_excl;
@@ -494,23 +493,24 @@ int dma_resv_get_fences_rcu(struct dma_resv *obj,
494493
*pshared = shared;
495494
return ret;
496495
}
497-
EXPORT_SYMBOL_GPL(dma_resv_get_fences_rcu);
496+
EXPORT_SYMBOL_GPL(dma_resv_get_fences);
498497

499498
/**
500-
* dma_resv_wait_timeout_rcu - Wait on reservation's objects
499+
* dma_resv_wait_timeout - Wait on reservation's objects
501500
* shared and/or exclusive fences.
502501
* @obj: the reservation object
503502
* @wait_all: if true, wait on all fences, else wait on just exclusive fence
504503
* @intr: if true, do interruptible wait
505504
* @timeout: timeout value in jiffies or zero to return immediately
506505
*
506+
* Callers are not required to hold specific locks, but maybe hold
507+
* dma_resv_lock() already
507508
* RETURNS
508509
* Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or
509510
* greater than zer on success.
510511
*/
511-
long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
512-
bool wait_all, bool intr,
513-
unsigned long timeout)
512+
long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr,
513+
unsigned long timeout)
514514
{
515515
long ret = timeout ? timeout : 1;
516516
unsigned int seq, shared_count;
@@ -582,7 +582,7 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
582582
rcu_read_unlock();
583583
goto retry;
584584
}
585-
EXPORT_SYMBOL_GPL(dma_resv_wait_timeout_rcu);
585+
EXPORT_SYMBOL_GPL(dma_resv_wait_timeout);
586586

587587

588588
static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence)
@@ -602,16 +602,18 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence)
602602
}
603603

604604
/**
605-
* dma_resv_test_signaled_rcu - Test if a reservation object's
606-
* fences have been signaled.
605+
* dma_resv_test_signaled - Test if a reservation object's fences have been
606+
* signaled.
607607
* @obj: the reservation object
608608
* @test_all: if true, test all fences, otherwise only test the exclusive
609609
* fence
610610
*
611+
* Callers are not required to hold specific locks, but maybe hold
612+
* dma_resv_lock() already
611613
* RETURNS
612614
* true if all fences signaled, else false
613615
*/
614-
bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
616+
bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all)
615617
{
616618
unsigned int seq, shared_count;
617619
int ret;
@@ -660,7 +662,7 @@ bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
660662
rcu_read_unlock();
661663
return ret;
662664
}
663-
EXPORT_SYMBOL_GPL(dma_resv_test_signaled_rcu);
665+
EXPORT_SYMBOL_GPL(dma_resv_test_signaled);
664666

665667
#if IS_ENABLED(CONFIG_LOCKDEP)
666668
static int __init dma_resv_lockdep(void)

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,8 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
203203
goto unpin;
204204
}
205205

206-
r = dma_resv_get_fences_rcu(new_abo->tbo.base.resv, &work->excl,
207-
&work->shared_count,
208-
&work->shared);
206+
r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->excl,
207+
&work->shared_count, &work->shared);
209208
if (unlikely(r != 0)) {
210209
DRM_ERROR("failed to get fences for buffer\n");
211210
goto unpin;

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ __dma_resv_make_exclusive(struct dma_resv *obj)
5252
if (!dma_resv_shared_list(obj)) /* no shared fences to convert */
5353
return 0;
5454

55-
r = dma_resv_get_fences_rcu(obj, NULL, &count, &fences);
55+
r = dma_resv_get_fences(obj, NULL, &count, &fences);
5656
if (r)
5757
return r;
5858

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ int amdgpu_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
526526
return -ENOENT;
527527
}
528528
robj = gem_to_amdgpu_bo(gobj);
529-
ret = dma_resv_wait_timeout_rcu(robj->tbo.base.resv, true, true,
530-
timeout);
529+
ret = dma_resv_wait_timeout(robj->tbo.base.resv, true, true, timeout);
531530

532531
/* ret == 0 means not signaled,
533532
* ret > 0 means signaled

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv,
112112
unsigned count;
113113
int r;
114114

115-
r = dma_resv_get_fences_rcu(resv, NULL, &count, &fences);
115+
r = dma_resv_get_fences(resv, NULL, &count, &fences);
116116
if (r)
117117
goto fallback;
118118

@@ -156,8 +156,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv,
156156
/* Not enough memory for the delayed delete, as last resort
157157
* block for all the fences to complete.
158158
*/
159-
dma_resv_wait_timeout_rcu(resv, true, false,
160-
MAX_SCHEDULE_TIMEOUT);
159+
dma_resv_wait_timeout(resv, true, false, MAX_SCHEDULE_TIMEOUT);
161160
amdgpu_pasid_free(pasid);
162161
}
163162

drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static bool amdgpu_mn_invalidate_gfx(struct mmu_interval_notifier *mni,
7575

7676
mmu_interval_set_seq(mni, cur_seq);
7777

78-
r = dma_resv_wait_timeout_rcu(bo->tbo.base.resv, true, false,
79-
MAX_SCHEDULE_TIMEOUT);
78+
r = dma_resv_wait_timeout(bo->tbo.base.resv, true, false,
79+
MAX_SCHEDULE_TIMEOUT);
8080
mutex_unlock(&adev->notifier_lock);
8181
if (r <= 0)
8282
DRM_ERROR("(%ld) failed to wait for user bo\n", r);

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
756756
return 0;
757757
}
758758

759-
r = dma_resv_wait_timeout_rcu(bo->tbo.base.resv, false, false,
760-
MAX_SCHEDULE_TIMEOUT);
759+
r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
760+
MAX_SCHEDULE_TIMEOUT);
761761
if (r < 0)
762762
return r;
763763

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,8 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
11261126
ib->length_dw = 16;
11271127

11281128
if (direct) {
1129-
r = dma_resv_wait_timeout_rcu(bo->tbo.base.resv,
1130-
true, false,
1131-
msecs_to_jiffies(10));
1129+
r = dma_resv_wait_timeout(bo->tbo.base.resv, true, false,
1130+
msecs_to_jiffies(10));
11321131
if (r == 0)
11331132
r = -ETIMEDOUT;
11341133
if (r < 0)

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,13 +2022,12 @@ static void amdgpu_vm_prt_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
20222022
unsigned i, shared_count;
20232023
int r;
20242024

2025-
r = dma_resv_get_fences_rcu(resv, &excl,
2026-
&shared_count, &shared);
2025+
r = dma_resv_get_fences(resv, &excl, &shared_count, &shared);
20272026
if (r) {
20282027
/* Not enough memory to grab the fence list, as last resort
20292028
* block for all the fences to complete.
20302029
*/
2031-
dma_resv_wait_timeout_rcu(resv, true, false,
2030+
dma_resv_wait_timeout(resv, true, false,
20322031
MAX_SCHEDULE_TIMEOUT);
20332032
return;
20342033
}
@@ -2640,7 +2639,7 @@ bool amdgpu_vm_evictable(struct amdgpu_bo *bo)
26402639
return true;
26412640

26422641
/* Don't evict VM page tables while they are busy */
2643-
if (!dma_resv_test_signaled_rcu(bo->tbo.base.resv, true))
2642+
if (!dma_resv_test_signaled(bo->tbo.base.resv, true))
26442643
return false;
26452644

26462645
/* Try to block ongoing updates */
@@ -2820,8 +2819,8 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
28202819
*/
28212820
long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
28222821
{
2823-
timeout = dma_resv_wait_timeout_rcu(vm->root.base.bo->tbo.base.resv,
2824-
true, true, timeout);
2822+
timeout = dma_resv_wait_timeout(vm->root.base.bo->tbo.base.resv, true,
2823+
true, timeout);
28252824
if (timeout <= 0)
28262825
return timeout;
28272826

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8400,9 +8400,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
84008400
* deadlock during GPU reset when this fence will not signal
84018401
* but we hold reservation lock for the BO.
84028402
*/
8403-
r = dma_resv_wait_timeout_rcu(abo->tbo.base.resv, true,
8404-
false,
8405-
msecs_to_jiffies(5000));
8403+
r = dma_resv_wait_timeout(abo->tbo.base.resv, true, false,
8404+
msecs_to_jiffies(5000));
84068405
if (unlikely(r <= 0))
84078406
DRM_ERROR("Waiting for fences timed out!");
84088407

drivers/gpu/drm/drm_gem.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,7 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
770770
return -EINVAL;
771771
}
772772

773-
ret = dma_resv_wait_timeout_rcu(obj->resv, wait_all,
774-
true, timeout);
773+
ret = dma_resv_wait_timeout(obj->resv, wait_all, true, timeout);
775774
if (ret == 0)
776775
ret = -ETIME;
777776
else if (ret > 0)
@@ -1380,7 +1379,7 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array,
13801379
return drm_gem_fence_array_add(fence_array, fence);
13811380
}
13821381

1383-
ret = dma_resv_get_fences_rcu(obj->resv, NULL,
1382+
ret = dma_resv_get_fences(obj->resv, NULL,
13841383
&fence_count, &fences);
13851384
if (ret || !fence_count)
13861385
return ret;

drivers/gpu/drm/etnaviv/etnaviv_gem.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,12 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
390390
}
391391

392392
if (op & ETNA_PREP_NOSYNC) {
393-
if (!dma_resv_test_signaled_rcu(obj->resv,
394-
write))
393+
if (!dma_resv_test_signaled(obj->resv, write))
395394
return -EBUSY;
396395
} else {
397396
unsigned long remain = etnaviv_timeout_to_jiffies(timeout);
398397

399-
ret = dma_resv_wait_timeout_rcu(obj->resv,
400-
write, true, remain);
398+
ret = dma_resv_wait_timeout(obj->resv, write, true, remain);
401399
if (ret <= 0)
402400
return ret == 0 ? -ETIMEDOUT : ret;
403401
}

drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
189189
continue;
190190

191191
if (bo->flags & ETNA_SUBMIT_BO_WRITE) {
192-
ret = dma_resv_get_fences_rcu(robj, &bo->excl,
193-
&bo->nr_shared,
194-
&bo->shared);
192+
ret = dma_resv_get_fences(robj, &bo->excl,
193+
&bo->nr_shared,
194+
&bo->shared);
195195
if (ret)
196196
return ret;
197197
} else {

drivers/gpu/drm/i915/dma_resv_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
void dma_resv_prune(struct dma_resv *resv)
1111
{
1212
if (dma_resv_trylock(resv)) {
13-
if (dma_resv_test_signaled_rcu(resv, true))
13+
if (dma_resv_test_signaled(resv, true))
1414
dma_resv_add_excl_fence(resv, NULL);
1515
dma_resv_unlock(resv);
1616
}

drivers/gpu/drm/i915/gem/i915_gem_busy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
105105
* Alternatively, we can trade that extra information on read/write
106106
* activity with
107107
* args->busy =
108-
* !dma_resv_test_signaled_rcu(obj->resv, true);
108+
* !dma_resv_test_signaled(obj->resv, true);
109109
* to report the overall busyness. This is what the wait-ioctl does.
110110
*
111111
*/

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ static inline bool use_reloc_gpu(struct i915_vma *vma)
14811481
if (DBG_FORCE_RELOC)
14821482
return false;
14831483

1484-
return !dma_resv_test_signaled_rcu(vma->resv, true);
1484+
return !dma_resv_test_signaled(vma->resv, true);
14851485
}
14861486

14871487
static unsigned long vma_phys_addr(struct i915_vma *vma, u32 offset)

drivers/gpu/drm/i915/gem/i915_gem_userptr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ static bool i915_gem_userptr_invalidate(struct mmu_interval_notifier *mni,
8585
return true;
8686

8787
/* we will unbind on next submission, still have userptr pins */
88-
r = dma_resv_wait_timeout_rcu(obj->base.resv, true, false,
89-
MAX_SCHEDULE_TIMEOUT);
88+
r = dma_resv_wait_timeout(obj->base.resv, true, false,
89+
MAX_SCHEDULE_TIMEOUT);
9090
if (r <= 0)
9191
drm_err(&i915->drm, "(%ld) failed to wait for idle\n", r);
9292

drivers/gpu/drm/i915/gem/i915_gem_wait.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
4545
unsigned int count, i;
4646
int ret;
4747

48-
ret = dma_resv_get_fences_rcu(resv, &excl, &count, &shared);
48+
ret = dma_resv_get_fences(resv, &excl, &count, &shared);
4949
if (ret)
5050
return ret;
5151

@@ -158,8 +158,8 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj,
158158
unsigned int count, i;
159159
int ret;
160160

161-
ret = dma_resv_get_fences_rcu(obj->base.resv,
162-
&excl, &count, &shared);
161+
ret = dma_resv_get_fences(obj->base.resv, &excl, &count,
162+
&shared);
163163
if (ret)
164164
return ret;
165165

drivers/gpu/drm/i915/i915_request.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,8 @@ i915_request_await_object(struct i915_request *to,
15941594
struct dma_fence **shared;
15951595
unsigned int count, i;
15961596

1597-
ret = dma_resv_get_fences_rcu(obj->base.resv,
1598-
&excl, &count, &shared);
1597+
ret = dma_resv_get_fences(obj->base.resv, &excl, &count,
1598+
&shared);
15991599
if (ret)
16001600
return ret;
16011601

drivers/gpu/drm/i915/i915_sw_fence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence,
582582
struct dma_fence **shared;
583583
unsigned int count, i;
584584

585-
ret = dma_resv_get_fences_rcu(resv, &excl, &count, &shared);
585+
ret = dma_resv_get_fences(resv, &excl, &count, &shared);
586586
if (ret)
587587
return ret;
588588

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,7 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
915915
op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
916916
long ret;
917917

918-
ret = dma_resv_wait_timeout_rcu(obj->resv, write,
919-
true, remain);
918+
ret = dma_resv_wait_timeout(obj->resv, write, true, remain);
920919
if (ret == 0)
921920
return remain == 0 ? -EBUSY : -ETIMEDOUT;
922921
else if (ret < 0)

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,8 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
964964
return -ENOENT;
965965
nvbo = nouveau_gem_object(gem);
966966

967-
lret = dma_resv_wait_timeout_rcu(nvbo->bo.base.resv, write, true,
968-
no_wait ? 0 : 30 * HZ);
967+
lret = dma_resv_wait_timeout(nvbo->bo.base.resv, write, true,
968+
no_wait ? 0 : 30 * HZ);
969969
if (!lret)
970970
ret = -EBUSY;
971971
else if (lret > 0)

drivers/gpu/drm/panfrost/panfrost_drv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ panfrost_ioctl_wait_bo(struct drm_device *dev, void *data,
312312
if (!gem_obj)
313313
return -ENOENT;
314314

315-
ret = dma_resv_wait_timeout_rcu(gem_obj->resv, true,
316-
true, timeout);
315+
ret = dma_resv_wait_timeout(gem_obj->resv, true, true, timeout);
317316
if (!ret)
318317
ret = timeout ? -ETIMEDOUT : -EBUSY;
319318

0 commit comments

Comments
 (0)