Lines Matching full:engine

60 static struct intel_ring *mock_ring(struct intel_engine_cs *engine)  in mock_ring()  argument
75 ring->vma = create_ring_vma(engine->gt->ggtt, PAGE_SIZE); in mock_ring()
93 static struct i915_request *first_request(struct mock_engine *engine) in first_request() argument
95 return list_first_entry_or_null(&engine->hw_queue, in first_request()
106 intel_engine_signal_breadcrumbs(request->engine); in advance()
111 struct mock_engine *engine = from_timer(engine, t, hw_delay); in hw_delay_complete() local
115 spin_lock_irqsave(&engine->hw_lock, flags); in hw_delay_complete()
118 request = first_request(engine); in hw_delay_complete()
126 while ((request = first_request(engine))) { in hw_delay_complete()
128 mod_timer(&engine->hw_delay, in hw_delay_complete()
136 spin_unlock_irqrestore(&engine->hw_lock, flags); in hw_delay_complete()
167 ce->ring = mock_ring(ce->engine); in mock_context_alloc()
171 ce->timeline = intel_timeline_create(ce->engine->gt); in mock_context_alloc()
173 kfree(ce->engine); in mock_context_alloc()
238 struct mock_engine *engine = in mock_submit_request() local
239 container_of(request->engine, typeof(*engine), base); in mock_submit_request()
244 spin_lock_irqsave(&engine->hw_lock, flags); in mock_submit_request()
245 list_add_tail(&request->mock.link, &engine->hw_queue); in mock_submit_request()
246 if (list_is_first(&request->mock.link, &engine->hw_queue)) { in mock_submit_request()
248 mod_timer(&engine->hw_delay, in mock_submit_request()
253 spin_unlock_irqrestore(&engine->hw_lock, flags); in mock_submit_request()
258 lockdep_assert_held(&rq->engine->sched_engine->lock); in mock_add_to_engine()
259 list_move_tail(&rq->sched.link, &rq->engine->sched_engine->requests); in mock_add_to_engine()
264 struct intel_engine_cs *engine, *locked; in mock_remove_from_engine() local
267 * Virtual engines complicate acquiring the engine timeline lock, in mock_remove_from_engine()
268 * as their rq->engine pointer is not stable until under that in mock_remove_from_engine()
269 * engine lock. The simple ploy we use is to take the lock then in mock_remove_from_engine()
270 * check that the rq still belongs to the newly locked engine. in mock_remove_from_engine()
273 locked = READ_ONCE(rq->engine); in mock_remove_from_engine()
275 while (unlikely(locked != (engine = READ_ONCE(rq->engine)))) { in mock_remove_from_engine()
277 spin_lock(&engine->sched_engine->lock); in mock_remove_from_engine()
278 locked = engine; in mock_remove_from_engine()
284 static void mock_reset_prepare(struct intel_engine_cs *engine) in mock_reset_prepare() argument
288 static void mock_reset_rewind(struct intel_engine_cs *engine, bool stalled) in mock_reset_rewind() argument
293 static void mock_reset_cancel(struct intel_engine_cs *engine) in mock_reset_cancel() argument
296 container_of(engine, typeof(*mock), base); in mock_reset_cancel()
302 spin_lock_irqsave(&engine->sched_engine->lock, flags); in mock_reset_cancel()
305 list_for_each_entry(rq, &engine->sched_engine->requests, sched.link) in mock_reset_cancel()
307 intel_engine_signal_breadcrumbs(engine); in mock_reset_cancel()
318 spin_unlock_irqrestore(&engine->sched_engine->lock, flags); in mock_reset_cancel()
321 static void mock_reset_finish(struct intel_engine_cs *engine) in mock_reset_finish() argument
325 static void mock_engine_release(struct intel_engine_cs *engine) in mock_engine_release() argument
328 container_of(engine, typeof(*mock), base); in mock_engine_release()
332 i915_sched_engine_put(engine->sched_engine); in mock_engine_release()
333 intel_breadcrumbs_put(engine->breadcrumbs); in mock_engine_release()
335 intel_context_unpin(engine->kernel_context); in mock_engine_release()
336 intel_context_put(engine->kernel_context); in mock_engine_release()
338 intel_engine_fini_retire(engine); in mock_engine_release()
345 struct mock_engine *engine; in mock_engine() local
350 engine = kzalloc(sizeof(*engine) + PAGE_SIZE, GFP_KERNEL); in mock_engine()
351 if (!engine) in mock_engine()
354 /* minimal engine setup for requests */ in mock_engine()
355 engine->base.i915 = i915; in mock_engine()
356 engine->base.gt = to_gt(i915); in mock_engine()
357 engine->base.uncore = to_gt(i915)->uncore; in mock_engine()
358 snprintf(engine->base.name, sizeof(engine->base.name), "%s", name); in mock_engine()
359 engine->base.id = id; in mock_engine()
360 engine->base.mask = BIT(id); in mock_engine()
361 engine->base.legacy_idx = INVALID_ENGINE; in mock_engine()
362 engine->base.instance = id; in mock_engine()
363 engine->base.status_page.addr = (void *)(engine + 1); in mock_engine()
365 engine->base.cops = &mock_context_ops; in mock_engine()
366 engine->base.request_alloc = mock_request_alloc; in mock_engine()
367 engine->base.emit_flush = mock_emit_flush; in mock_engine()
368 engine->base.emit_fini_breadcrumb = mock_emit_breadcrumb; in mock_engine()
369 engine->base.submit_request = mock_submit_request; in mock_engine()
370 engine->base.add_active_request = mock_add_to_engine; in mock_engine()
371 engine->base.remove_active_request = mock_remove_from_engine; in mock_engine()
373 engine->base.reset.prepare = mock_reset_prepare; in mock_engine()
374 engine->base.reset.rewind = mock_reset_rewind; in mock_engine()
375 engine->base.reset.cancel = mock_reset_cancel; in mock_engine()
376 engine->base.reset.finish = mock_reset_finish; in mock_engine()
378 engine->base.release = mock_engine_release; in mock_engine()
380 to_gt(i915)->engine[id] = &engine->base; in mock_engine()
381 to_gt(i915)->engine_class[0][id] = &engine->base; in mock_engine()
384 spin_lock_init(&engine->hw_lock); in mock_engine()
385 timer_setup(&engine->hw_delay, hw_delay_complete, 0); in mock_engine()
386 INIT_LIST_HEAD(&engine->hw_queue); in mock_engine()
388 intel_engine_add_user(&engine->base); in mock_engine()
390 return &engine->base; in mock_engine()
393 int mock_engine_init(struct intel_engine_cs *engine) in mock_engine_init() argument
397 INIT_LIST_HEAD(&engine->pinned_contexts_list); in mock_engine_init()
399 engine->sched_engine = i915_sched_engine_create(ENGINE_MOCK); in mock_engine_init()
400 if (!engine->sched_engine) in mock_engine_init()
402 engine->sched_engine->private_data = engine; in mock_engine_init()
404 intel_engine_init_execlists(engine); in mock_engine_init()
405 intel_engine_init__pm(engine); in mock_engine_init()
406 intel_engine_init_retire(engine); in mock_engine_init()
408 engine->breadcrumbs = intel_breadcrumbs_create(NULL); in mock_engine_init()
409 if (!engine->breadcrumbs) in mock_engine_init()
412 ce = create_kernel_context(engine); in mock_engine_init()
417 engine->status_page.vma = ce->timeline->hwsp_ggtt; in mock_engine_init()
419 engine->kernel_context = ce; in mock_engine_init()
423 intel_breadcrumbs_put(engine->breadcrumbs); in mock_engine_init()
425 i915_sched_engine_put(engine->sched_engine); in mock_engine_init()
429 void mock_engine_flush(struct intel_engine_cs *engine) in mock_engine_flush() argument
432 container_of(engine, typeof(*mock), base); in mock_engine_flush()
443 void mock_engine_reset(struct intel_engine_cs *engine) in mock_engine_reset() argument