Skip to content

Commit d224985

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/wait, drivers/drm: Convert wait_on_atomic_t() usage to the new wait_var_event() API
The old wait_on_atomic_t() is going to get removed, use the more flexible wait_var_event() API instead. Unlike wake_up_atomic_t(), wake_up_var() will issue the wakeup even if the variable is not 0. No change in functionality. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 6b2bb72 commit d224985

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

drivers/gpu/drm/drm_dp_aux_dev.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ static ssize_t auxdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
177177
res = pos - iocb->ki_pos;
178178
iocb->ki_pos = pos;
179179

180-
atomic_dec(&aux_dev->usecount);
181-
wake_up_atomic_t(&aux_dev->usecount);
180+
if (atomic_dec_and_test(&aux_dev->usecount))
181+
wake_up_var(&aux_dev->usecount);
182+
182183
return res;
183184
}
184185

@@ -218,8 +219,9 @@ static ssize_t auxdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
218219
res = pos - iocb->ki_pos;
219220
iocb->ki_pos = pos;
220221

221-
atomic_dec(&aux_dev->usecount);
222-
wake_up_atomic_t(&aux_dev->usecount);
222+
if (atomic_dec_and_test(&aux_dev->usecount))
223+
wake_up_var(&aux_dev->usecount);
224+
223225
return res;
224226
}
225227

@@ -277,8 +279,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
277279
mutex_unlock(&aux_idr_mutex);
278280

279281
atomic_dec(&aux_dev->usecount);
280-
wait_on_atomic_t(&aux_dev->usecount, atomic_t_wait,
281-
TASK_UNINTERRUPTIBLE);
282+
wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount));
282283

283284
minor = aux_dev->index;
284285
if (aux_dev->dev)

drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,13 @@ struct igt_wakeup {
271271
u32 seqno;
272272
};
273273

274-
static int wait_atomic_timeout(atomic_t *p, unsigned int mode)
275-
{
276-
return schedule_timeout(10 * HZ) ? 0 : -ETIMEDOUT;
277-
}
278-
279274
static bool wait_for_ready(struct igt_wakeup *w)
280275
{
281276
DEFINE_WAIT(ready);
282277

283278
set_bit(IDLE, &w->flags);
284279
if (atomic_dec_and_test(w->done))
285-
wake_up_atomic_t(w->done);
280+
wake_up_var(w->done);
286281

287282
if (test_bit(STOP, &w->flags))
288283
goto out;
@@ -299,7 +294,7 @@ static bool wait_for_ready(struct igt_wakeup *w)
299294
out:
300295
clear_bit(IDLE, &w->flags);
301296
if (atomic_dec_and_test(w->set))
302-
wake_up_atomic_t(w->set);
297+
wake_up_var(w->set);
303298

304299
return !test_bit(STOP, &w->flags);
305300
}
@@ -342,15 +337,14 @@ static void igt_wake_all_sync(atomic_t *ready,
342337
atomic_set(ready, 0);
343338
wake_up_all(wq);
344339

345-
wait_on_atomic_t(set, atomic_t_wait, TASK_UNINTERRUPTIBLE);
340+
wait_var_event(set, !atomic_read(set));
346341
atomic_set(ready, count);
347342
atomic_set(done, count);
348343
}
349344

350345
static int igt_wakeup(void *arg)
351346
{
352347
I915_RND_STATE(prng);
353-
const int state = TASK_UNINTERRUPTIBLE;
354348
struct intel_engine_cs *engine = arg;
355349
struct igt_wakeup *waiters;
356350
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
@@ -418,7 +412,7 @@ static int igt_wakeup(void *arg)
418412
* that they are ready for the next test. We wait until all
419413
* threads are complete and waiting for us (i.e. not a seqno).
420414
*/
421-
err = wait_on_atomic_t(&done, wait_atomic_timeout, state);
415+
err = wait_var_event_timeout(&done, !atomic_read(&done), 10 * HZ);
422416
if (err) {
423417
pr_err("Timed out waiting for %d remaining waiters\n",
424418
atomic_read(&done));

0 commit comments

Comments
 (0)