Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
d224985a 6b2bb726

+11 -16
+7 -6
drivers/gpu/drm/drm_dp_aux_dev.c
··· 177 177 res = pos - iocb->ki_pos; 178 178 iocb->ki_pos = pos; 179 179 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 + 182 183 return res; 183 184 } 184 185 ··· 219 218 res = pos - iocb->ki_pos; 220 219 iocb->ki_pos = pos; 221 220 222 - atomic_dec(&aux_dev->usecount); 223 - wake_up_atomic_t(&aux_dev->usecount); 221 + if (atomic_dec_and_test(&aux_dev->usecount)) 222 + wake_up_var(&aux_dev->usecount); 223 + 224 224 return res; 225 225 } 226 226 ··· 279 277 mutex_unlock(&aux_idr_mutex); 280 278 281 279 atomic_dec(&aux_dev->usecount); 282 - wait_on_atomic_t(&aux_dev->usecount, atomic_t_wait, 283 - TASK_UNINTERRUPTIBLE); 280 + wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount)); 284 281 285 282 minor = aux_dev->index; 286 283 if (aux_dev->dev)
+4 -10
drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c
··· 271 271 u32 seqno; 272 272 }; 273 273 274 - static int wait_atomic_timeout(atomic_t *p, unsigned int mode) 275 - { 276 - return schedule_timeout(10 * HZ) ? 0 : -ETIMEDOUT; 277 - } 278 - 279 274 static bool wait_for_ready(struct igt_wakeup *w) 280 275 { 281 276 DEFINE_WAIT(ready); 282 277 283 278 set_bit(IDLE, &w->flags); 284 279 if (atomic_dec_and_test(w->done)) 285 - wake_up_atomic_t(w->done); 280 + wake_up_var(w->done); 286 281 287 282 if (test_bit(STOP, &w->flags)) 288 283 goto out; ··· 294 299 out: 295 300 clear_bit(IDLE, &w->flags); 296 301 if (atomic_dec_and_test(w->set)) 297 - wake_up_atomic_t(w->set); 302 + wake_up_var(w->set); 298 303 299 304 return !test_bit(STOP, &w->flags); 300 305 } ··· 337 342 atomic_set(ready, 0); 338 343 wake_up_all(wq); 339 344 340 - wait_on_atomic_t(set, atomic_t_wait, TASK_UNINTERRUPTIBLE); 345 + wait_var_event(set, !atomic_read(set)); 341 346 atomic_set(ready, count); 342 347 atomic_set(done, count); 343 348 } ··· 345 350 static int igt_wakeup(void *arg) 346 351 { 347 352 I915_RND_STATE(prng); 348 - const int state = TASK_UNINTERRUPTIBLE; 349 353 struct intel_engine_cs *engine = arg; 350 354 struct igt_wakeup *waiters; 351 355 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); ··· 412 418 * that they are ready for the next test. We wait until all 413 419 * threads are complete and waiting for us (i.e. not a seqno). 414 420 */ 415 - err = wait_on_atomic_t(&done, wait_atomic_timeout, state); 421 + err = wait_var_event_timeout(&done, !atomic_read(&done), 10 * HZ); 416 422 if (err) { 417 423 pr_err("Timed out waiting for %d remaining waiters\n", 418 424 atomic_read(&done));