intel_guc_submission.c 19.6 KB
Newer Older
1
// SPDX-License-Identifier: MIT
2 3 4 5
/*
 * Copyright © 2014 Intel Corporation
 */

6
#include <linux/circ_buf.h>
7

8
#include "gem/i915_gem_context.h"
9 10
#include "gt/intel_context.h"
#include "gt/intel_engine_pm.h"
11
#include "gt/intel_gt.h"
12
#include "gt/intel_gt_pm.h"
13
#include "gt/intel_lrc_reg.h"
14 15
#include "gt/intel_ring.h"

16
#include "intel_guc_submission.h"
17

18
#include "i915_drv.h"
19
#include "i915_trace.h"
20

21
/**
A
Alex Dai 已提交
22
 * DOC: GuC-based command submission
23
 *
24 25 26 27 28 29
 * IMPORTANT NOTE: GuC submission is currently not supported in i915. The GuC
 * firmware is moving to an updated submission interface and we plan to
 * turn submission back on when that lands. The below documentation (and related
 * code) matches the old submission model and will be updated as part of the
 * upgrade to the new flow.
 *
30
 * GuC stage descriptor:
31
 * During initialization, the driver allocates a static pool of 1024 such
32 33
 * descriptors, and shares them with the GuC. Currently, we only use one
 * descriptor. This stage descriptor lets the GuC know about the workqueue and
34 35
 * process descriptor. Theoretically, it also lets the GuC know about our HW
 * contexts (context ID, etc...), but we actually employ a kind of submission
36
 * where the GuC uses the LRCA sent via the work item instead. This is called
37
 * a "proxy" submission.
38 39 40 41 42 43 44 45
 *
 * The Scratch registers:
 * There are 16 MMIO-based registers start from 0xC180. The kernel driver writes
 * a value to the action register (SOFT_SCRATCH_0) along with any data. It then
 * triggers an interrupt on the GuC via another register write (0xC4C8).
 * Firmware writes a success/fail code back to the action register after
 * processes the request. The kernel driver polls waiting for this update and
 * then proceeds.
46
 * See intel_guc_send()
47 48 49 50 51 52 53
 *
 * Work Items:
 * There are several types of work items that the host may place into a
 * workqueue, each with its own requirements and limitations. Currently only
 * WQ_TYPE_INORDER is needed to support legacy submission via GuC, which
 * represents in-order queue. The kernel driver packs ring tail pointer and an
 * ELSP context descriptor dword into Work Item.
54
 * See guc_add_request()
55 56 57
 *
 */

58 59 60 61 62
static inline struct i915_priolist *to_priolist(struct rb_node *rb)
{
	return rb_entry(rb, struct i915_priolist, node);
}

63
static struct guc_stage_desc *__get_stage_desc(struct intel_guc *guc, u32 id)
64
{
65 66 67
	struct guc_stage_desc *base = guc->stage_desc_pool_vaddr;

	return &base[id];
68 69
}

70
static int guc_workqueue_create(struct intel_guc *guc)
71
{
72 73
	return intel_guc_allocate_and_map_vma(guc, GUC_WQ_SIZE, &guc->workqueue,
					      &guc->workqueue_vaddr);
74 75
}

76
static void guc_workqueue_destroy(struct intel_guc *guc)
77
{
78
	i915_vma_unpin_and_release(&guc->workqueue, I915_VMA_RELEASE_MAP);
79 80
}

81 82 83
/*
 * Initialise the process descriptor shared with the GuC firmware.
 */
84 85 86 87 88 89 90 91 92 93 94 95 96 97
static int guc_proc_desc_create(struct intel_guc *guc)
{
	const u32 size = PAGE_ALIGN(sizeof(struct guc_process_desc));

	return intel_guc_allocate_and_map_vma(guc, size, &guc->proc_desc,
					      &guc->proc_desc_vaddr);
}

static void guc_proc_desc_destroy(struct intel_guc *guc)
{
	i915_vma_unpin_and_release(&guc->proc_desc, I915_VMA_RELEASE_MAP);
}

static void guc_proc_desc_init(struct intel_guc *guc)
98 99 100
{
	struct guc_process_desc *desc;

101
	desc = memset(guc->proc_desc_vaddr, 0, sizeof(*desc));
102 103 104 105 106 107 108 109 110 111

	/*
	 * XXX: pDoorbell and WQVBaseAddress are pointers in process address
	 * space for ring3 clients (set them as in mmap_ioctl) or kernel
	 * space for kernel clients (map on demand instead? May make debug
	 * easier to have it mapped).
	 */
	desc->wq_base_addr = 0;
	desc->db_base_addr = 0;

112
	desc->wq_size_bytes = GUC_WQ_SIZE;
113
	desc->wq_status = WQ_STATUS_ACTIVE;
114
	desc->priority = GUC_CLIENT_PRIORITY_KMD_NORMAL;
115 116
}

117
static void guc_proc_desc_fini(struct intel_guc *guc)
118
{
119
	memset(guc->proc_desc_vaddr, 0, sizeof(struct guc_process_desc));
120 121
}

122 123
static int guc_stage_desc_pool_create(struct intel_guc *guc)
{
124 125
	u32 size = PAGE_ALIGN(sizeof(struct guc_stage_desc) *
			      GUC_MAX_STAGE_DESCRIPTORS);
126

127 128
	return intel_guc_allocate_and_map_vma(guc, size, &guc->stage_desc_pool,
					      &guc->stage_desc_pool_vaddr);
129 130 131 132
}

static void guc_stage_desc_pool_destroy(struct intel_guc *guc)
{
133
	i915_vma_unpin_and_release(&guc->stage_desc_pool, I915_VMA_RELEASE_MAP);
134 135
}

136
/*
137
 * Initialise/clear the stage descriptor shared with the GuC firmware.
138 139
 *
 * This descriptor tells the GuC where (in GGTT space) to find the important
140
 * data structures related to work submission (process descriptor, write queue,
141
 * etc).
142
 */
143
static void guc_stage_desc_init(struct intel_guc *guc)
144
{
145
	struct guc_stage_desc *desc;
146

147 148
	/* we only use 1 stage desc, so hardcode it to 0 */
	desc = __get_stage_desc(guc, 0);
149
	memset(desc, 0, sizeof(*desc));
150

151 152
	desc->attribute = GUC_STAGE_DESC_ATTR_ACTIVE |
			  GUC_STAGE_DESC_ATTR_KERNEL;
153

154 155
	desc->stage_id = 0;
	desc->priority = GUC_CLIENT_PRIORITY_KMD_NORMAL;
156

157 158 159
	desc->process_desc = intel_guc_ggtt_offset(guc, guc->proc_desc);
	desc->wq_addr = intel_guc_ggtt_offset(guc, guc->workqueue);
	desc->wq_size = GUC_WQ_SIZE;
160 161
}

162
static void guc_stage_desc_fini(struct intel_guc *guc)
163
{
164
	struct guc_stage_desc *desc;
165

166
	desc = __get_stage_desc(guc, 0);
167
	memset(desc, 0, sizeof(*desc));
168 169
}

170
/* Construct a Work Item and append it to the GuC's Work Queue */
171
static void guc_wq_item_append(struct intel_guc *guc,
172 173
			       u32 target_engine, u32 context_desc,
			       u32 ring_tail, u32 fence_id)
174
{
175 176
	/* wqi_len is in DWords, and does not include the one-word header */
	const size_t wqi_size = sizeof(struct guc_wq_item);
177
	const u32 wqi_len = wqi_size / sizeof(u32) - 1;
178
	struct guc_process_desc *desc = guc->proc_desc_vaddr;
179
	struct guc_wq_item *wqi;
180
	u32 wq_off;
181

182
	lockdep_assert_held(&guc->wq_lock);
183

184 185 186 187 188 189 190
	/* For now workqueue item is 4 DWs; workqueue buffer is 2 pages. So we
	 * should not have the case where structure wqi is across page, neither
	 * wrapped to the beginning. This simplifies the implementation below.
	 *
	 * XXX: if not the case, we need save data to a temp wqi and copy it to
	 * workqueue buffer dw by dw.
	 */
191
	BUILD_BUG_ON(wqi_size != 16);
192

193 194 195
	/* We expect the WQ to be active if we're appending items to it */
	GEM_BUG_ON(desc->wq_status != WQ_STATUS_ACTIVE);

196 197 198 199
	/* Free space is guaranteed. */
	wq_off = READ_ONCE(desc->tail);
	GEM_BUG_ON(CIRC_SPACE(wq_off, READ_ONCE(desc->head),
			      GUC_WQ_SIZE) < wqi_size);
200
	GEM_BUG_ON(wq_off & (wqi_size - 1));
201

202
	wqi = guc->workqueue_vaddr + wq_off;
203 204 205 206 207 208 209 210 211 212

	/* Now fill in the 4-word work queue item */
	wqi->header = WQ_TYPE_INORDER |
		      (wqi_len << WQ_LEN_SHIFT) |
		      (target_engine << WQ_TARGET_SHIFT) |
		      WQ_NO_WCFLUSH_WAIT;
	wqi->context_desc = context_desc;
	wqi->submit_element_info = ring_tail << WQ_RING_TAIL_SHIFT;
	GEM_BUG_ON(ring_tail > WQ_RING_TAIL_MAX);
	wqi->fence_id = fence_id;
213

214
	/* Make the update visible to GuC */
215
	WRITE_ONCE(desc->tail, (wq_off + wqi_size) & (GUC_WQ_SIZE - 1));
216 217
}

218
static void guc_add_request(struct intel_guc *guc, struct i915_request *rq)
219 220
{
	struct intel_engine_cs *engine = rq->engine;
221
	u32 ctx_desc = lower_32_bits(rq->hw_context->lrc_desc);
222 223
	u32 ring_tail = intel_ring_set_tail(rq->ring, rq->tail) / sizeof(u64);

224
	guc_wq_item_append(guc, engine->guc_id, ctx_desc,
225
			   ring_tail, rq->fence.seqno);
226 227
}

228 229 230 231 232 233 234 235 236 237
/*
 * When we're doing submissions using regular execlists backend, writing to
 * ELSP from CPU side is enough to make sure that writes to ringbuffer pages
 * pinned in mappable aperture portion of GGTT are visible to command streamer.
 * Writes done by GuC on our behalf are not guaranteeing such ordering,
 * therefore, to ensure the flush, we're issuing a POSTING READ.
 */
static void flush_ggtt_writes(struct i915_vma *vma)
{
	if (i915_vma_is_map_and_fenceable(vma))
238 239
		intel_uncore_posting_read_fw(vma->vm->gt->uncore,
					     GUC_STATUS);
240 241
}

242 243 244
static void guc_submit(struct intel_engine_cs *engine,
		       struct i915_request **out,
		       struct i915_request **end)
245
{
246
	struct intel_guc *guc = &engine->gt->uc.guc;
247

248
	spin_lock(&guc->wq_lock);
249

250 251
	do {
		struct i915_request *rq = *out++;
252

253 254 255
		flush_ggtt_writes(rq->ring->vma);
		guc_add_request(guc, rq);
	} while (out != end);
256

257
	spin_unlock(&guc->wq_lock);
258 259
}

260
static inline int rq_prio(const struct i915_request *rq)
261
{
262
	return rq->sched.attr.priority | __NO_PREEMPTION;
263 264
}

265
static struct i915_request *schedule_in(struct i915_request *rq, int idx)
266
{
267 268
	trace_i915_request_in(rq, idx);

269 270 271 272 273 274
	/*
	 * Currently we are not tracking the rq->context being inflight
	 * (ce->inflight = rq->engine). It is only used by the execlists
	 * backend at the moment, a similar counting strategy would be
	 * required if we generalise the inflight tracking.
	 */
275

276
	__intel_gt_pm_get(rq->engine->gt);
277
	return i915_request_get(rq);
278 279
}

280
static void schedule_out(struct i915_request *rq)
281
{
282 283
	trace_i915_request_out(rq);

284
	intel_gt_pm_put_async(rq->engine->gt);
285
	i915_request_put(rq);
286 287
}

288
static void __guc_dequeue(struct intel_engine_cs *engine)
289
{
290
	struct intel_engine_execlists * const execlists = &engine->execlists;
291 292 293 294
	struct i915_request **first = execlists->inflight;
	struct i915_request ** const last_port = first + execlists->port_mask;
	struct i915_request *last = first[0];
	struct i915_request **port;
295
	bool submit = false;
296 297
	struct rb_node *rb;

298
	lockdep_assert_held(&engine->active.lock);
299

300 301 302 303 304
	if (last) {
		if (*++first)
			return;

		last = NULL;
305 306
	}

307 308 309 310 311
	/*
	 * We write directly into the execlists->inflight queue and don't use
	 * the execlists->pending queue, as we don't have a distinct switch
	 * event.
	 */
312
	port = first;
313
	while ((rb = rb_first_cached(&execlists->queue))) {
314
		struct i915_priolist *p = to_priolist(rb);
315
		struct i915_request *rq, *rn;
316
		int i;
317

318
		priolist_for_each_request_consume(rq, rn, p, i) {
319
			if (last && rq->hw_context != last->hw_context) {
320
				if (port == last_port)
321 322
					goto done;

323 324
				*port = schedule_in(last,
						    port - execlists->inflight);
325 326 327
				port++;
			}

328
			list_del_init(&rq->sched.link);
329
			__i915_request_submit(rq);
330
			submit = true;
331
			last = rq;
332 333
		}

334
		rb_erase_cached(&p->node, &execlists->queue);
335
		i915_priolist_free(p);
336
	}
337
done:
338 339
	execlists->queue_priority_hint =
		rb ? to_priolist(rb)->priority : INT_MIN;
340 341 342 343 344 345
	if (submit) {
		*port = schedule_in(last, port - execlists->inflight);
		*++port = NULL;
		guc_submit(engine, first, port);
	}
	execlists->active = execlists->inflight;
346 347
}

348
static void guc_submission_tasklet(unsigned long data)
349
{
350
	struct intel_engine_cs * const engine = (struct intel_engine_cs *)data;
351
	struct intel_engine_execlists * const execlists = &engine->execlists;
352
	struct i915_request **port, *rq;
353 354
	unsigned long flags;

355
	spin_lock_irqsave(&engine->active.lock, flags);
356

357 358 359
	for (port = execlists->inflight; (rq = *port); port++) {
		if (!i915_request_completed(rq))
			break;
360

361 362 363 364 365 366
		schedule_out(rq);
	}
	if (port != execlists->inflight) {
		int idx = port - execlists->inflight;
		int rem = ARRAY_SIZE(execlists->inflight) - idx;
		memmove(execlists->inflight, port, rem * sizeof(*port));
367
	}
368

369
	__guc_dequeue(engine);
370

371
	spin_unlock_irqrestore(&engine->active.lock, flags);
372 373
}

374
static void guc_reset_prepare(struct intel_engine_cs *engine)
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
{
	struct intel_engine_execlists * const execlists = &engine->execlists;

	GEM_TRACE("%s\n", engine->name);

	/*
	 * Prevent request submission to the hardware until we have
	 * completed the reset in i915_gem_reset_finish(). If a request
	 * is completed by one engine, it may then queue a request
	 * to a second via its execlists->tasklet *just* as we are
	 * calling engine->init_hw() and also writing the ELSP.
	 * Turning off the execlists->tasklet until the reset is over
	 * prevents the race.
	 */
	__tasklet_disable_sync_once(&execlists->tasklet);
}

392 393 394 395 396 397 398 399 400 401 402 403 404
static void
cancel_port_requests(struct intel_engine_execlists * const execlists)
{
	struct i915_request * const *port, *rq;

	/* Note we are only using the inflight and not the pending queue */

	for (port = execlists->active; (rq = *port); port++)
		schedule_out(rq);
	execlists->active =
		memset(execlists->inflight, 0, sizeof(execlists->inflight));
}

405 406 407 408 409 410
static void guc_reset(struct intel_engine_cs *engine, bool stalled)
{
	struct intel_engine_execlists * const execlists = &engine->execlists;
	struct i915_request *rq;
	unsigned long flags;

411
	spin_lock_irqsave(&engine->active.lock, flags);
412

413
	cancel_port_requests(execlists);
414 415 416 417 418 419 420 421 422

	/* Push back any incomplete requests for replay after the reset. */
	rq = execlists_unwind_incomplete_requests(execlists);
	if (!rq)
		goto out_unlock;

	if (!i915_request_started(rq))
		stalled = false;

423
	__i915_request_reset(rq, stalled);
424 425 426
	intel_lr_context_reset(engine, rq->hw_context, rq->head, stalled);

out_unlock:
427
	spin_unlock_irqrestore(&engine->active.lock, flags);
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
}

static void guc_cancel_requests(struct intel_engine_cs *engine)
{
	struct intel_engine_execlists * const execlists = &engine->execlists;
	struct i915_request *rq, *rn;
	struct rb_node *rb;
	unsigned long flags;

	GEM_TRACE("%s\n", engine->name);

	/*
	 * Before we call engine->cancel_requests(), we should have exclusive
	 * access to the submission state. This is arranged for us by the
	 * caller disabling the interrupt generation, the tasklet and other
	 * threads that may then access the same state, giving us a free hand
	 * to reset state. However, we still need to let lockdep be aware that
	 * we know this state may be accessed in hardirq context, so we
	 * disable the irq around this manipulation and we want to keep
	 * the spinlock focused on its duties and not accidentally conflate
	 * coverage to the submission's irq state. (Similarly, although we
	 * shouldn't need to disable irq around the manipulation of the
	 * submission's irq state, we also wish to remind ourselves that
	 * it is irq state.)
	 */
453
	spin_lock_irqsave(&engine->active.lock, flags);
454 455

	/* Cancel the requests on the HW and clear the ELSP tracker. */
456
	cancel_port_requests(execlists);
457 458

	/* Mark all executing requests as skipped. */
459
	list_for_each_entry(rq, &engine->active.requests, sched.link) {
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
		if (!i915_request_signaled(rq))
			dma_fence_set_error(&rq->fence, -EIO);

		i915_request_mark_complete(rq);
	}

	/* Flush the queued requests to the timeline list (for retiring). */
	while ((rb = rb_first_cached(&execlists->queue))) {
		struct i915_priolist *p = to_priolist(rb);
		int i;

		priolist_for_each_request_consume(rq, rn, p, i) {
			list_del_init(&rq->sched.link);
			__i915_request_submit(rq);
			dma_fence_set_error(&rq->fence, -EIO);
			i915_request_mark_complete(rq);
		}

		rb_erase_cached(&p->node, &execlists->queue);
		i915_priolist_free(p);
	}

	/* Remaining _unready_ requests will be nop'ed when submitted */

	execlists->queue_priority_hint = INT_MIN;
	execlists->queue = RB_ROOT_CACHED;

487
	spin_unlock_irqrestore(&engine->active.lock, flags);
488 489 490 491 492 493 494 495 496 497 498 499 500 501
}

static void guc_reset_finish(struct intel_engine_cs *engine)
{
	struct intel_engine_execlists * const execlists = &engine->execlists;

	if (__tasklet_enable(&execlists->tasklet))
		/* And kick in case we missed a new request submission. */
		tasklet_hi_schedule(&execlists->tasklet);

	GEM_TRACE("%s: depth->%d\n", engine->name,
		  atomic_read(&execlists->tasklet.count));
}

502 503 504
/*
 * Everything below here is concerned with setup & teardown, and is
 * therefore not part of the somewhat time-critical batch-submission
505
 * path of guc_submit() above.
506 507
 */

508
/*
509 510
 * Set up the memory resources to be shared with the GuC (via the GGTT)
 * at firmware loading time.
511
 */
512
int intel_guc_submission_init(struct intel_guc *guc)
513
{
514
	int ret;
515

516
	if (guc->stage_desc_pool)
517
		return 0;
518

519 520 521
	ret = guc_stage_desc_pool_create(guc);
	if (ret)
		return ret;
522 523 524 525 526
	/*
	 * Keep static analysers happy, let them know that we allocated the
	 * vma after testing that it didn't exist earlier.
	 */
	GEM_BUG_ON(!guc->stage_desc_pool);
527

528
	ret = guc_workqueue_create(guc);
529
	if (ret)
530
		goto err_pool;
531

532 533 534 535 536 537
	ret = guc_proc_desc_create(guc);
	if (ret)
		goto err_workqueue;

	spin_lock_init(&guc->wq_lock);

538
	return 0;
539

540 541
err_workqueue:
	guc_workqueue_destroy(guc);
542 543 544
err_pool:
	guc_stage_desc_pool_destroy(guc);
	return ret;
545 546
}

547
void intel_guc_submission_fini(struct intel_guc *guc)
548
{
549 550 551
	if (guc->stage_desc_pool) {
		guc_proc_desc_destroy(guc);
		guc_workqueue_destroy(guc);
552
		guc_stage_desc_pool_destroy(guc);
553
	}
554 555
}

556
static void guc_interrupts_capture(struct intel_gt *gt)
557
{
558
	struct intel_uncore *uncore = gt->uncore;
559 560
	u32 irqs = GT_CONTEXT_SWITCH_INTERRUPT;
	u32 dmask = irqs << 16 | irqs;
561

562
	GEM_BUG_ON(INTEL_GEN(gt->i915) < 11);
563

564 565 566
	/* Don't handle the ctx switch interrupt in GuC submission mode */
	intel_uncore_rmw(uncore, GEN11_RENDER_COPY_INTR_ENABLE, dmask, 0);
	intel_uncore_rmw(uncore, GEN11_VCS_VECS_INTR_ENABLE, dmask, 0);
567 568
}

569
static void guc_interrupts_release(struct intel_gt *gt)
570
{
571
	struct intel_uncore *uncore = gt->uncore;
572 573
	u32 irqs = GT_CONTEXT_SWITCH_INTERRUPT;
	u32 dmask = irqs << 16 | irqs;
574

575 576 577 578 579
	GEM_BUG_ON(INTEL_GEN(gt->i915) < 11);

	/* Handle ctx switch interrupts again */
	intel_uncore_rmw(uncore, GEN11_RENDER_COPY_INTR_ENABLE, 0, dmask);
	intel_uncore_rmw(uncore, GEN11_VCS_VECS_INTR_ENABLE, 0, dmask);
580 581
}

582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
static void guc_set_default_submission(struct intel_engine_cs *engine)
{
	/*
	 * We inherit a bunch of functions from execlists that we'd like
	 * to keep using:
	 *
	 *    engine->submit_request = execlists_submit_request;
	 *    engine->cancel_requests = execlists_cancel_requests;
	 *    engine->schedule = execlists_schedule;
	 *
	 * But we need to override the actual submission backend in order
	 * to talk to the GuC.
	 */
	intel_execlists_set_default_submission(engine);

	engine->execlists.tasklet.func = guc_submission_tasklet;

599 600
	/* do not use execlists park/unpark */
	engine->park = engine->unpark = NULL;
601 602

	engine->reset.prepare = guc_reset_prepare;
603 604 605 606
	engine->reset.reset = guc_reset;
	engine->reset.finish = guc_reset_finish;

	engine->cancel_requests = guc_cancel_requests;
607 608

	engine->flags &= ~I915_ENGINE_SUPPORTS_STATS;
609 610 611 612 613 614 615 616 617
	engine->flags |= I915_ENGINE_NEEDS_BREADCRUMB_TASKLET;

	/*
	 * For the breadcrumb irq to work we need the interrupts to stay
	 * enabled. However, on all platforms on which we'll have support for
	 * GuC submission we don't allow disabling the interrupts at runtime, so
	 * we're always safe with the current flow.
	 */
	GEM_BUG_ON(engine->irq_enable || engine->irq_disable);
618 619
}

620
void intel_guc_submission_enable(struct intel_guc *guc)
621
{
622
	struct intel_gt *gt = guc_to_gt(guc);
623
	struct intel_engine_cs *engine;
624
	enum intel_engine_id id;
625

626 627 628 629 630 631 632 633 634
	/*
	 * We're using GuC work items for submitting work through GuC. Since
	 * we're coalescing multiple requests from a single context into a
	 * single work item prior to assigning it to execlist_port, we can
	 * never have more work items than the total number of ports (for all
	 * engines). The GuC firmware is controlling the HEAD of work queue,
	 * and it is guaranteed that it will remove the work item from the
	 * queue before our request is completed.
	 */
635
	BUILD_BUG_ON(ARRAY_SIZE(engine->execlists.inflight) *
636 637 638
		     sizeof(struct guc_wq_item) *
		     I915_NUM_ENGINES > GUC_WQ_SIZE);

639 640
	guc_proc_desc_init(guc);
	guc_stage_desc_init(guc);
A
Alex Dai 已提交
641

642
	/* Take over from manual control of ELSP (execlists) */
643
	guc_interrupts_capture(gt);
644

645
	for_each_engine(engine, gt, id) {
646 647
		engine->set_default_submission = guc_set_default_submission;
		engine->set_default_submission(engine);
648
	}
649 650
}

651
void intel_guc_submission_disable(struct intel_guc *guc)
652
{
653
	struct intel_gt *gt = guc_to_gt(guc);
654

655
	GEM_BUG_ON(gt->awake); /* GT should be parked first */
656

657 658
	/* Note: By the time we're here, GuC may have already been reset */

659
	guc_interrupts_release(gt);
660 661 662

	guc_stage_desc_fini(guc);
	guc_proc_desc_fini(guc);
663
}
664

665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
static bool __guc_submission_support(struct intel_guc *guc)
{
	/* XXX: GuC submission is unavailable for now */
	return false;

	if (!intel_guc_is_supported(guc))
		return false;

	return i915_modparams.enable_guc & ENABLE_GUC_SUBMISSION;
}

void intel_guc_submission_init_early(struct intel_guc *guc)
{
	guc->submission_supported = __guc_submission_support(guc);
}
680 681 682 683 684

bool intel_engine_in_guc_submission_mode(const struct intel_engine_cs *engine)
{
	return engine->set_default_submission == guc_set_default_submission;
}