intel_breadcrumbs.c 19.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Copyright © 2015 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 */

25 26
#include <linux/kthread.h>

27 28
#include "i915_drv.h"

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
static void intel_breadcrumbs_hangcheck(unsigned long data)
{
	struct intel_engine_cs *engine = (struct intel_engine_cs *)data;
	struct intel_breadcrumbs *b = &engine->breadcrumbs;

	if (!b->irq_enabled)
		return;

	if (time_before(jiffies, b->timeout)) {
		mod_timer(&b->hangcheck, b->timeout);
		return;
	}

	DRM_DEBUG("Hangcheck timer elapsed... %s idle\n", engine->name);
	set_bit(engine->id, &engine->i915->gpu_error.missed_irq_rings);
	mod_timer(&engine->breadcrumbs.fake_irq, jiffies + 1);

	/* Ensure that even if the GPU hangs, we get woken up.
	 *
	 * However, note that if no one is waiting, we never notice
	 * a gpu hang. Eventually, we will have to wait for a resource
	 * held by the GPU and so trigger a hangcheck. In the most
	 * pathological case, this will be upon memory starvation! To
	 * prevent this, we also queue the hangcheck from the retire
	 * worker.
	 */
	i915_queue_hangcheck(engine->i915);
}

static unsigned long wait_timeout(void)
{
	return round_jiffies_up(jiffies + DRM_I915_HANGCHECK_JIFFIES);
}

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
static void intel_breadcrumbs_fake_irq(unsigned long data)
{
	struct intel_engine_cs *engine = (struct intel_engine_cs *)data;

	/*
	 * The timer persists in case we cannot enable interrupts,
	 * or if we have previously seen seqno/interrupt incoherency
	 * ("missed interrupt" syndrome). Here the worker will wake up
	 * every jiffie in order to kick the oldest waiter to do the
	 * coherent seqno check.
	 */
	if (intel_engine_wakeup(engine))
		mod_timer(&engine->breadcrumbs.fake_irq, jiffies + 1);
}

static void irq_enable(struct intel_engine_cs *engine)
{
80 81 82 83
	/* Enabling the IRQ may miss the generation of the interrupt, but
	 * we still need to force the barrier before reading the seqno,
	 * just in case.
	 */
84
	engine->breadcrumbs.irq_posted = true;
85

86 87
	/* Caller disables interrupts */
	spin_lock(&engine->i915->irq_lock);
88
	engine->irq_enable(engine);
89
	spin_unlock(&engine->i915->irq_lock);
90 91 92 93
}

static void irq_disable(struct intel_engine_cs *engine)
{
94 95
	/* Caller disables interrupts */
	spin_lock(&engine->i915->irq_lock);
96
	engine->irq_disable(engine);
97
	spin_unlock(&engine->i915->irq_lock);
98

99
	engine->breadcrumbs.irq_posted = false;
100 101
}

102
static void __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b)
103 104 105 106 107 108 109
{
	struct intel_engine_cs *engine =
		container_of(b, struct intel_engine_cs, breadcrumbs);
	struct drm_i915_private *i915 = engine->i915;

	assert_spin_locked(&b->lock);
	if (b->rpm_wakelock)
110
		return;
111 112 113 114 115 116 117 118 119 120 121

	/* Since we are waiting on a request, the GPU should be busy
	 * and should have its own rpm reference. For completeness,
	 * record an rpm reference for ourselves to cover the
	 * interrupt we unmask.
	 */
	intel_runtime_pm_get_noresume(i915);
	b->rpm_wakelock = true;

	/* No interrupts? Kick the waiter every jiffie! */
	if (intel_irqs_enabled(i915)) {
122
		if (!test_bit(engine->id, &i915->gpu_error.test_irq_rings))
123 124 125 126 127
			irq_enable(engine);
		b->irq_enabled = true;
	}

	if (!b->irq_enabled ||
128
	    test_bit(engine->id, &i915->gpu_error.missed_irq_rings)) {
129
		mod_timer(&b->fake_irq, jiffies + 1);
130
		i915_queue_hangcheck(i915);
131 132 133 134 135
	} else {
		/* Ensure we never sleep indefinitely */
		GEM_BUG_ON(!time_after(b->timeout, jiffies));
		mod_timer(&b->hangcheck, b->timeout);
	}
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
}

static void __intel_breadcrumbs_disable_irq(struct intel_breadcrumbs *b)
{
	struct intel_engine_cs *engine =
		container_of(b, struct intel_engine_cs, breadcrumbs);

	assert_spin_locked(&b->lock);
	if (!b->rpm_wakelock)
		return;

	if (b->irq_enabled) {
		irq_disable(engine);
		b->irq_enabled = false;
	}

	intel_runtime_pm_put(engine->i915);
	b->rpm_wakelock = false;
}

static inline struct intel_wait *to_wait(struct rb_node *node)
{
158
	return rb_entry(node, struct intel_wait, node);
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
}

static inline void __intel_breadcrumbs_finish(struct intel_breadcrumbs *b,
					      struct intel_wait *wait)
{
	assert_spin_locked(&b->lock);

	/* This request is completed, so remove it from the tree, mark it as
	 * complete, and *then* wake up the associated task.
	 */
	rb_erase(&wait->node, &b->waiters);
	RB_CLEAR_NODE(&wait->node);

	wake_up_process(wait->tsk); /* implicit smp_wmb() */
}

static bool __intel_engine_add_wait(struct intel_engine_cs *engine,
				    struct intel_wait *wait)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;
	struct rb_node **p, *parent, *completed;
	bool first;
	u32 seqno;

	/* Insert the request into the retirement ordered list
	 * of waiters by walking the rbtree. If we are the oldest
	 * seqno in the tree (the first to be retired), then
	 * set ourselves as the bottom-half.
	 *
	 * As we descend the tree, prune completed branches since we hold the
	 * spinlock we know that the first_waiter must be delayed and can
	 * reduce some of the sequential wake up latency if we take action
	 * ourselves and wake up the completed tasks in parallel. Also, by
	 * removing stale elements in the tree, we may be able to reduce the
	 * ping-pong between the old bottom-half and ourselves as first-waiter.
	 */
	first = true;
	parent = NULL;
	completed = NULL;
198
	seqno = intel_engine_get_seqno(engine);
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237

	 /* If the request completed before we managed to grab the spinlock,
	  * return now before adding ourselves to the rbtree. We let the
	  * current bottom-half handle any pending wakeups and instead
	  * try and get out of the way quickly.
	  */
	if (i915_seqno_passed(seqno, wait->seqno)) {
		RB_CLEAR_NODE(&wait->node);
		return first;
	}

	p = &b->waiters.rb_node;
	while (*p) {
		parent = *p;
		if (wait->seqno == to_wait(parent)->seqno) {
			/* We have multiple waiters on the same seqno, select
			 * the highest priority task (that with the smallest
			 * task->prio) to serve as the bottom-half for this
			 * group.
			 */
			if (wait->tsk->prio > to_wait(parent)->tsk->prio) {
				p = &parent->rb_right;
				first = false;
			} else {
				p = &parent->rb_left;
			}
		} else if (i915_seqno_passed(wait->seqno,
					     to_wait(parent)->seqno)) {
			p = &parent->rb_right;
			if (i915_seqno_passed(seqno, to_wait(parent)->seqno))
				completed = parent;
			else
				first = false;
		} else {
			p = &parent->rb_left;
		}
	}
	rb_link_node(&wait->node, parent, p);
	rb_insert_color(&wait->node, &b->waiters);
238
	GEM_BUG_ON(!first && !rcu_access_pointer(b->irq_seqno_bh));
239 240 241 242 243 244 245

	if (completed) {
		struct rb_node *next = rb_next(completed);

		GEM_BUG_ON(!next && !first);
		if (next && next != &wait->node) {
			GEM_BUG_ON(first);
246
			b->timeout = wait_timeout();
247
			b->first_wait = to_wait(next);
248
			rcu_assign_pointer(b->irq_seqno_bh, b->first_wait->tsk);
249 250 251 252 253 254 255 256 257 258 259
			/* As there is a delay between reading the current
			 * seqno, processing the completed tasks and selecting
			 * the next waiter, we may have missed the interrupt
			 * and so need for the next bottom-half to wakeup.
			 *
			 * Also as we enable the IRQ, we may miss the
			 * interrupt for that seqno, so we have to wake up
			 * the next bottom-half in order to do a coherent check
			 * in case the seqno passed.
			 */
			__intel_breadcrumbs_enable_irq(b);
260
			if (READ_ONCE(b->irq_posted))
261
				wake_up_process(to_wait(next)->tsk);
262 263 264 265 266 267 268 269 270 271 272
		}

		do {
			struct intel_wait *crumb = to_wait(completed);
			completed = rb_prev(completed);
			__intel_breadcrumbs_finish(b, crumb);
		} while (completed);
	}

	if (first) {
		GEM_BUG_ON(rb_first(&b->waiters) != &wait->node);
273
		b->timeout = wait_timeout();
274
		b->first_wait = wait;
275
		rcu_assign_pointer(b->irq_seqno_bh, wait->tsk);
276 277 278 279 280
		/* After assigning ourselves as the new bottom-half, we must
		 * perform a cursory check to prevent a missed interrupt.
		 * Either we miss the interrupt whilst programming the hardware,
		 * or if there was a previous waiter (for a later seqno) they
		 * may be woken instead of us (due to the inherent race
281 282
		 * in the unlocked read of b->irq_seqno_bh in the irq handler)
		 * and so we miss the wake up.
283 284
		 */
		__intel_breadcrumbs_enable_irq(b);
285
	}
286
	GEM_BUG_ON(!rcu_access_pointer(b->irq_seqno_bh));
287 288 289 290 291 292 293 294 295 296 297 298
	GEM_BUG_ON(!b->first_wait);
	GEM_BUG_ON(rb_first(&b->waiters) != &b->first_wait->node);

	return first;
}

bool intel_engine_add_wait(struct intel_engine_cs *engine,
			   struct intel_wait *wait)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;
	bool first;

299
	spin_lock_irq(&b->lock);
300
	first = __intel_engine_add_wait(engine, wait);
301
	spin_unlock_irq(&b->lock);
302 303 304 305 306 307 308 309 310

	return first;
}

static inline bool chain_wakeup(struct rb_node *rb, int priority)
{
	return rb && to_wait(rb)->tsk->prio <= priority;
}

311 312 313 314 315 316 317 318 319
static inline int wakeup_priority(struct intel_breadcrumbs *b,
				  struct task_struct *tsk)
{
	if (tsk == b->signaler)
		return INT_MIN;
	else
		return tsk->prio;
}

320 321 322 323 324 325 326 327 328 329 330 331
void intel_engine_remove_wait(struct intel_engine_cs *engine,
			      struct intel_wait *wait)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;

	/* Quick check to see if this waiter was already decoupled from
	 * the tree by the bottom-half to avoid contention on the spinlock
	 * by the herd.
	 */
	if (RB_EMPTY_NODE(&wait->node))
		return;

332
	spin_lock_irq(&b->lock);
333 334 335 336 337

	if (RB_EMPTY_NODE(&wait->node))
		goto out_unlock;

	if (b->first_wait == wait) {
338
		const int priority = wakeup_priority(b, wait->tsk);
339 340
		struct rb_node *next;

341
		GEM_BUG_ON(rcu_access_pointer(b->irq_seqno_bh) != wait->tsk);
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362

		/* We are the current bottom-half. Find the next candidate,
		 * the first waiter in the queue on the remaining oldest
		 * request. As multiple seqnos may complete in the time it
		 * takes us to wake up and find the next waiter, we have to
		 * wake up that waiter for it to perform its own coherent
		 * completion check.
		 */
		next = rb_next(&wait->node);
		if (chain_wakeup(next, priority)) {
			/* If the next waiter is already complete,
			 * wake it up and continue onto the next waiter. So
			 * if have a small herd, they will wake up in parallel
			 * rather than sequentially, which should reduce
			 * the overall latency in waking all the completed
			 * clients.
			 *
			 * However, waking up a chain adds extra latency to
			 * the first_waiter. This is undesirable if that
			 * waiter is a high priority task.
			 */
363
			u32 seqno = intel_engine_get_seqno(engine);
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382

			while (i915_seqno_passed(seqno, to_wait(next)->seqno)) {
				struct rb_node *n = rb_next(next);

				__intel_breadcrumbs_finish(b, to_wait(next));
				next = n;
				if (!chain_wakeup(next, priority))
					break;
			}
		}

		if (next) {
			/* In our haste, we may have completed the first waiter
			 * before we enabled the interrupt. Do so now as we
			 * have a second waiter for a future seqno. Afterwards,
			 * we have to wake up that waiter in case we missed
			 * the interrupt, or if we have to handle an
			 * exception rather than a seqno completion.
			 */
383
			b->timeout = wait_timeout();
384
			b->first_wait = to_wait(next);
385
			rcu_assign_pointer(b->irq_seqno_bh, b->first_wait->tsk);
386 387
			if (b->first_wait->seqno != wait->seqno)
				__intel_breadcrumbs_enable_irq(b);
388
			wake_up_process(b->first_wait->tsk);
389 390
		} else {
			b->first_wait = NULL;
391
			rcu_assign_pointer(b->irq_seqno_bh, NULL);
392 393 394 395 396 397 398 399 400 401 402 403 404
			__intel_breadcrumbs_disable_irq(b);
		}
	} else {
		GEM_BUG_ON(rb_first(&b->waiters) == &wait->node);
	}

	GEM_BUG_ON(RB_EMPTY_NODE(&wait->node));
	rb_erase(&wait->node, &b->waiters);

out_unlock:
	GEM_BUG_ON(b->first_wait == wait);
	GEM_BUG_ON(rb_first(&b->waiters) !=
		   (b->first_wait ? &b->first_wait->node : NULL));
405
	GEM_BUG_ON(!rcu_access_pointer(b->irq_seqno_bh) ^ RB_EMPTY_ROOT(&b->waiters));
406
	spin_unlock_irq(&b->lock);
407 408
}

409
static bool signal_complete(struct drm_i915_gem_request *request)
410
{
411
	if (!request)
412 413 414 415 416
		return false;

	/* If another process served as the bottom-half it may have already
	 * signalled that this wait is already completed.
	 */
417
	if (intel_wait_complete(&request->signaling.wait))
418 419 420 421 422
		return true;

	/* Carefully check if the request is complete, giving time for the
	 * seqno to be visible or if the GPU hung.
	 */
423
	if (__i915_request_irq_complete(request))
424 425 426 427 428
		return true;

	return false;
}

429
static struct drm_i915_gem_request *to_signaler(struct rb_node *rb)
430
{
431
	return rb_entry(rb, struct drm_i915_gem_request, signaling.node);
432 433 434 435 436 437 438 439 440 441 442 443 444
}

static void signaler_set_rtpriority(void)
{
	 struct sched_param param = { .sched_priority = 1 };

	 sched_setscheduler_nocheck(current, SCHED_FIFO, &param);
}

static int intel_breadcrumbs_signaler(void *arg)
{
	struct intel_engine_cs *engine = arg;
	struct intel_breadcrumbs *b = &engine->breadcrumbs;
445
	struct drm_i915_gem_request *request;
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460

	/* Install ourselves with high priority to reduce signalling latency */
	signaler_set_rtpriority();

	do {
		set_current_state(TASK_INTERRUPTIBLE);

		/* We are either woken up by the interrupt bottom-half,
		 * or by a client adding a new signaller. In both cases,
		 * the GPU seqno may have advanced beyond our oldest signal.
		 * If it has, propagate the signal, remove the waiter and
		 * check again with the next oldest signal. Otherwise we
		 * need to wait for a new interrupt from the GPU or for
		 * a new client.
		 */
461 462
		request = READ_ONCE(b->first_signal);
		if (signal_complete(request)) {
463 464 465
			/* Wake up all other completed waiters and select the
			 * next bottom-half for the next user interrupt.
			 */
466 467
			intel_engine_remove_wait(engine,
						 &request->signaling.wait);
468 469

			local_bh_disable();
470
			dma_fence_signal(&request->fence);
471
			local_bh_enable(); /* kick start the tasklets */
472 473 474 475 476 477 478

			/* Find the next oldest signal. Note that as we have
			 * not been holding the lock, another client may
			 * have installed an even older signal than the one
			 * we just completed - so double check we are still
			 * the oldest before picking the next one.
			 */
479
			spin_lock_irq(&b->lock);
480 481 482 483 484 485
			if (request == b->first_signal) {
				struct rb_node *rb =
					rb_next(&request->signaling.node);
				b->first_signal = rb ? to_signaler(rb) : NULL;
			}
			rb_erase(&request->signaling.node, &b->signals);
486
			spin_unlock_irq(&b->lock);
487

488
			i915_gem_request_put(request);
489 490 491 492 493 494 495 496 497 498 499 500
		} else {
			if (kthread_should_stop())
				break;

			schedule();
		}
	} while (1);
	__set_current_state(TASK_RUNNING);

	return 0;
}

501
void intel_engine_enable_signaling(struct drm_i915_gem_request *request)
502 503 504 505 506 507
{
	struct intel_engine_cs *engine = request->engine;
	struct intel_breadcrumbs *b = &engine->breadcrumbs;
	struct rb_node *parent, **p;
	bool first, wakeup;

508 509 510 511 512 513 514 515
	/* Note that we may be called from an interrupt handler on another
	 * device (e.g. nouveau signaling a fence completion causing us
	 * to submit a request, and so enable signaling). As such,
	 * we need to make sure that all other users of b->lock protect
	 * against interrupts, i.e. use spin_lock_irqsave.
	 */

	/* locked by dma_fence_enable_sw_signaling() (irqsafe fence->lock) */
516
	assert_spin_locked(&request->lock);
517 518
	if (!request->global_seqno)
		return;
519

520
	request->signaling.wait.tsk = b->signaler;
521
	request->signaling.wait.seqno = request->global_seqno;
522
	i915_gem_request_get(request);
523

524 525
	spin_lock(&b->lock);

526 527 528 529 530 531 532 533
	/* First add ourselves into the list of waiters, but register our
	 * bottom-half as the signaller thread. As per usual, only the oldest
	 * waiter (not just signaller) is tasked as the bottom-half waking
	 * up all completed waiters after the user interrupt.
	 *
	 * If we are the oldest waiter, enable the irq (after which we
	 * must double check that the seqno did not complete).
	 */
534
	wakeup = __intel_engine_add_wait(engine, &request->signaling.wait);
535 536 537 538 539 540 541 542 543 544

	/* Now insert ourselves into the retirement ordered list of signals
	 * on this engine. We track the oldest seqno as that will be the
	 * first signal to complete.
	 */
	parent = NULL;
	first = true;
	p = &b->signals.rb_node;
	while (*p) {
		parent = *p;
545 546
		if (i915_seqno_passed(request->global_seqno,
				      to_signaler(parent)->global_seqno)) {
547 548 549 550 551 552
			p = &parent->rb_right;
			first = false;
		} else {
			p = &parent->rb_left;
		}
	}
553 554
	rb_link_node(&request->signaling.node, parent, p);
	rb_insert_color(&request->signaling.node, &b->signals);
555
	if (first)
556 557
		smp_store_mb(b->first_signal, request);

558 559 560 561 562 563
	spin_unlock(&b->lock);

	if (wakeup)
		wake_up_process(b->signaler);
}

564 565 566
int intel_engine_init_breadcrumbs(struct intel_engine_cs *engine)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;
567
	struct task_struct *tsk;
568 569 570 571 572

	spin_lock_init(&b->lock);
	setup_timer(&b->fake_irq,
		    intel_breadcrumbs_fake_irq,
		    (unsigned long)engine);
573 574 575
	setup_timer(&b->hangcheck,
		    intel_breadcrumbs_hangcheck,
		    (unsigned long)engine);
576

577 578 579 580 581 582 583 584 585 586 587 588 589
	/* Spawn a thread to provide a common bottom-half for all signals.
	 * As this is an asynchronous interface we cannot steal the current
	 * task for handling the bottom-half to the user interrupt, therefore
	 * we create a thread to do the coherent seqno dance after the
	 * interrupt and then signal the waitqueue (via the dma-buf/fence).
	 */
	tsk = kthread_run(intel_breadcrumbs_signaler, engine,
			  "i915/signal:%d", engine->id);
	if (IS_ERR(tsk))
		return PTR_ERR(tsk);

	b->signaler = tsk;

590 591 592
	return 0;
}

593 594 595 596 597 598 599 600 601 602 603 604 605 606
static void cancel_fake_irq(struct intel_engine_cs *engine)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;

	del_timer_sync(&b->hangcheck);
	del_timer_sync(&b->fake_irq);
	clear_bit(engine->id, &engine->i915->gpu_error.missed_irq_rings);
}

void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;

	cancel_fake_irq(engine);
607
	spin_lock_irq(&b->lock);
608 609 610 611 612 613 614 615 616 617 618 619

	__intel_breadcrumbs_disable_irq(b);
	if (intel_engine_has_waiter(engine)) {
		b->timeout = wait_timeout();
		__intel_breadcrumbs_enable_irq(b);
		if (READ_ONCE(b->irq_posted))
			wake_up_process(b->first_wait->tsk);
	} else {
		/* sanitize the IMR and unmask any auxiliary interrupts */
		irq_disable(engine);
	}

620
	spin_unlock_irq(&b->lock);
621 622
}

623 624 625 626
void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine)
{
	struct intel_breadcrumbs *b = &engine->breadcrumbs;

627 628 629 630 631 632
	/* The engines should be idle and all requests accounted for! */
	WARN_ON(READ_ONCE(b->first_wait));
	WARN_ON(!RB_EMPTY_ROOT(&b->waiters));
	WARN_ON(READ_ONCE(b->first_signal));
	WARN_ON(!RB_EMPTY_ROOT(&b->signals));

633 634 635
	if (!IS_ERR_OR_NULL(b->signaler))
		kthread_stop(b->signaler);

636
	cancel_fake_irq(engine);
637 638
}

639
unsigned int intel_breadcrumbs_busy(struct drm_i915_private *i915)
640 641
{
	struct intel_engine_cs *engine;
642
	enum intel_engine_id id;
643 644
	unsigned int mask = 0;

645 646
	for_each_engine(engine, i915, id) {
		struct intel_breadcrumbs *b = &engine->breadcrumbs;
647

648
		spin_lock_irq(&b->lock);
649

650 651 652 653
		if (b->first_wait) {
			wake_up_process(b->first_wait->tsk);
			mask |= intel_engine_flag(engine);
		}
654

655 656
		if (b->first_signal) {
			wake_up_process(b->signaler);
657 658
			mask |= intel_engine_flag(engine);
		}
659 660

		spin_unlock_irq(&b->lock);
661 662 663 664
	}

	return mask;
}