hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/dma-buf/reservation.c
....@@ -109,8 +109,7 @@
109109
110110 dma_fence_get(fence);
111111
112
- preempt_disable();
113
- write_seqcount_begin(&obj->seq);
112
+ write_seqlock(&obj->seq);
114113
115114 for (i = 0; i < fobj->shared_count; ++i) {
116115 struct dma_fence *old_fence;
....@@ -121,8 +120,7 @@
121120 if (old_fence->context == fence->context) {
122121 /* memory barrier is added by write_seqcount_begin */
123122 RCU_INIT_POINTER(fobj->shared[i], fence);
124
- write_seqcount_end(&obj->seq);
125
- preempt_enable();
123
+ write_sequnlock(&obj->seq);
126124
127125 dma_fence_put(old_fence);
128126 return;
....@@ -146,8 +144,7 @@
146144 fobj->shared_count++;
147145 }
148146
149
- write_seqcount_end(&obj->seq);
150
- preempt_enable();
147
+ write_sequnlock(&obj->seq);
151148
152149 dma_fence_put(signaled);
153150 }
....@@ -191,15 +188,13 @@
191188 fobj->shared_count++;
192189
193190 done:
194
- preempt_disable();
195
- write_seqcount_begin(&obj->seq);
191
+ write_seqlock(&obj->seq);
196192 /*
197193 * RCU_INIT_POINTER can be used here,
198194 * seqcount provides the necessary barriers
199195 */
200196 RCU_INIT_POINTER(obj->fence, fobj);
201
- write_seqcount_end(&obj->seq);
202
- preempt_enable();
197
+ write_sequnlock(&obj->seq);
203198
204199 if (!old)
205200 return;
....@@ -259,14 +254,11 @@
259254 if (fence)
260255 dma_fence_get(fence);
261256
262
- preempt_disable();
263
- write_seqcount_begin(&obj->seq);
264
- /* write_seqcount_begin provides the necessary memory barrier */
257
+ write_seqlock(&obj->seq);
265258 RCU_INIT_POINTER(obj->fence_excl, fence);
266259 if (old)
267260 old->shared_count = 0;
268
- write_seqcount_end(&obj->seq);
269
- preempt_enable();
261
+ write_sequnlock(&obj->seq);
270262
271263 /* inplace update, no shared fences */
272264 while (i--)
....@@ -349,13 +341,10 @@
349341 src_list = reservation_object_get_list(dst);
350342 old = reservation_object_get_excl(dst);
351343
352
- preempt_disable();
353
- write_seqcount_begin(&dst->seq);
354
- /* write_seqcount_begin provides the necessary memory barrier */
344
+ write_seqlock(&dst->seq);
355345 RCU_INIT_POINTER(dst->fence_excl, new);
356346 RCU_INIT_POINTER(dst->fence, dst_list);
357
- write_seqcount_end(&dst->seq);
358
- preempt_enable();
347
+ write_sequnlock(&dst->seq);
359348
360349 if (src_list)
361350 kfree_rcu(src_list, rcu);
....@@ -396,7 +385,7 @@
396385 shared_count = i = 0;
397386
398387 rcu_read_lock();
399
- seq = read_seqcount_begin(&obj->seq);
388
+ seq = read_seqbegin(&obj->seq);
400389
401390 fence_excl = rcu_dereference(obj->fence_excl);
402391 if (fence_excl && !dma_fence_get_rcu(fence_excl))
....@@ -445,7 +434,7 @@
445434 }
446435 }
447436
448
- if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) {
437
+ if (i != shared_count || read_seqretry(&obj->seq, seq)) {
449438 while (i--)
450439 dma_fence_put(shared[i]);
451440 dma_fence_put(fence_excl);
....@@ -494,7 +483,7 @@
494483
495484 retry:
496485 shared_count = 0;
497
- seq = read_seqcount_begin(&obj->seq);
486
+ seq = read_seqbegin(&obj->seq);
498487 rcu_read_lock();
499488 i = -1;
500489
....@@ -541,7 +530,7 @@
541530
542531 rcu_read_unlock();
543532 if (fence) {
544
- if (read_seqcount_retry(&obj->seq, seq)) {
533
+ if (read_seqretry(&obj->seq, seq)) {
545534 dma_fence_put(fence);
546535 goto retry;
547536 }
....@@ -597,7 +586,7 @@
597586 retry:
598587 ret = true;
599588 shared_count = 0;
600
- seq = read_seqcount_begin(&obj->seq);
589
+ seq = read_seqbegin(&obj->seq);
601590
602591 if (test_all) {
603592 unsigned i;
....@@ -618,7 +607,7 @@
618607 break;
619608 }
620609
621
- if (read_seqcount_retry(&obj->seq, seq))
610
+ if (read_seqretry(&obj->seq, seq))
622611 goto retry;
623612 }
624613
....@@ -631,7 +620,7 @@
631620 if (ret < 0)
632621 goto retry;
633622
634
- if (read_seqcount_retry(&obj->seq, seq))
623
+ if (read_seqretry(&obj->seq, seq))
635624 goto retry;
636625 }
637626 }