scheduler.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Zhi Wang <zhi.a.wang@intel.com>
  25. *
  26. * Contributors:
  27. * Ping Gao <ping.a.gao@intel.com>
  28. * Tina Zhang <tina.zhang@intel.com>
  29. * Chanbin Du <changbin.du@intel.com>
  30. * Min He <min.he@intel.com>
  31. * Bing Niu <bing.niu@intel.com>
  32. * Zhenyu Wang <zhenyuw@linux.intel.com>
  33. *
  34. */
  35. #include <linux/kthread.h>
  36. #include "i915_drv.h"
  37. #include "gvt.h"
  38. #define RING_CTX_OFF(x) \
  39. offsetof(struct execlist_ring_context, x)
  40. static void set_context_pdp_root_pointer(
  41. struct execlist_ring_context *ring_context,
  42. u32 pdp[8])
  43. {
  44. struct execlist_mmio_pair *pdp_pair = &ring_context->pdp3_UDW;
  45. int i;
  46. for (i = 0; i < 8; i++)
  47. pdp_pair[i].val = pdp[7 - i];
  48. }
  49. static int populate_shadow_context(struct intel_vgpu_workload *workload)
  50. {
  51. struct intel_vgpu *vgpu = workload->vgpu;
  52. struct intel_gvt *gvt = vgpu->gvt;
  53. int ring_id = workload->ring_id;
  54. struct i915_gem_context *shadow_ctx = workload->vgpu->shadow_ctx;
  55. struct drm_i915_gem_object *ctx_obj =
  56. shadow_ctx->engine[ring_id].state->obj;
  57. struct execlist_ring_context *shadow_ring_context;
  58. struct page *page;
  59. void *dst;
  60. unsigned long context_gpa, context_page_num;
  61. int i;
  62. gvt_dbg_sched("ring id %d workload lrca %x", ring_id,
  63. workload->ctx_desc.lrca);
  64. context_page_num = intel_lr_context_size(
  65. gvt->dev_priv->engine[ring_id]);
  66. context_page_num = context_page_num >> PAGE_SHIFT;
  67. if (IS_BROADWELL(gvt->dev_priv) && ring_id == RCS)
  68. context_page_num = 19;
  69. i = 2;
  70. while (i < context_page_num) {
  71. context_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm,
  72. (u32)((workload->ctx_desc.lrca + i) <<
  73. GTT_PAGE_SHIFT));
  74. if (context_gpa == INTEL_GVT_INVALID_ADDR) {
  75. gvt_vgpu_err("Invalid guest context descriptor\n");
  76. return -EINVAL;
  77. }
  78. page = i915_gem_object_get_page(ctx_obj, LRC_PPHWSP_PN + i);
  79. dst = kmap(page);
  80. intel_gvt_hypervisor_read_gpa(vgpu, context_gpa, dst,
  81. GTT_PAGE_SIZE);
  82. kunmap(page);
  83. i++;
  84. }
  85. page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN);
  86. shadow_ring_context = kmap(page);
  87. #define COPY_REG(name) \
  88. intel_gvt_hypervisor_read_gpa(vgpu, workload->ring_context_gpa \
  89. + RING_CTX_OFF(name.val), &shadow_ring_context->name.val, 4)
  90. COPY_REG(ctx_ctrl);
  91. COPY_REG(ctx_timestamp);
  92. if (ring_id == RCS) {
  93. COPY_REG(bb_per_ctx_ptr);
  94. COPY_REG(rcs_indirect_ctx);
  95. COPY_REG(rcs_indirect_ctx_offset);
  96. }
  97. #undef COPY_REG
  98. set_context_pdp_root_pointer(shadow_ring_context,
  99. workload->shadow_mm->shadow_page_table);
  100. intel_gvt_hypervisor_read_gpa(vgpu,
  101. workload->ring_context_gpa +
  102. sizeof(*shadow_ring_context),
  103. (void *)shadow_ring_context +
  104. sizeof(*shadow_ring_context),
  105. GTT_PAGE_SIZE - sizeof(*shadow_ring_context));
  106. kunmap(page);
  107. return 0;
  108. }
  109. static inline bool is_gvt_request(struct drm_i915_gem_request *req)
  110. {
  111. return i915_gem_context_force_single_submission(req->ctx);
  112. }
  113. static int shadow_context_status_change(struct notifier_block *nb,
  114. unsigned long action, void *data)
  115. {
  116. struct drm_i915_gem_request *req = (struct drm_i915_gem_request *)data;
  117. struct intel_gvt *gvt = container_of(nb, struct intel_gvt,
  118. shadow_ctx_notifier_block[req->engine->id]);
  119. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  120. struct intel_vgpu_workload *workload =
  121. scheduler->current_workload[req->engine->id];
  122. if (!is_gvt_request(req) || unlikely(!workload))
  123. return NOTIFY_OK;
  124. switch (action) {
  125. case INTEL_CONTEXT_SCHEDULE_IN:
  126. intel_gvt_load_render_mmio(workload->vgpu,
  127. workload->ring_id);
  128. atomic_set(&workload->shadow_ctx_active, 1);
  129. break;
  130. case INTEL_CONTEXT_SCHEDULE_OUT:
  131. intel_gvt_restore_render_mmio(workload->vgpu,
  132. workload->ring_id);
  133. /* If the status is -EINPROGRESS means this workload
  134. * doesn't meet any issue during dispatching so when
  135. * get the SCHEDULE_OUT set the status to be zero for
  136. * good. If the status is NOT -EINPROGRESS means there
  137. * is something wrong happened during dispatching and
  138. * the status should not be set to zero
  139. */
  140. if (workload->status == -EINPROGRESS)
  141. workload->status = 0;
  142. atomic_set(&workload->shadow_ctx_active, 0);
  143. break;
  144. default:
  145. WARN_ON(1);
  146. return NOTIFY_OK;
  147. }
  148. wake_up(&workload->shadow_ctx_status_wq);
  149. return NOTIFY_OK;
  150. }
  151. static int dispatch_workload(struct intel_vgpu_workload *workload)
  152. {
  153. int ring_id = workload->ring_id;
  154. struct i915_gem_context *shadow_ctx = workload->vgpu->shadow_ctx;
  155. struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv;
  156. struct intel_engine_cs *engine = dev_priv->engine[ring_id];
  157. struct drm_i915_gem_request *rq;
  158. struct intel_vgpu *vgpu = workload->vgpu;
  159. int ret;
  160. gvt_dbg_sched("ring id %d prepare to dispatch workload %p\n",
  161. ring_id, workload);
  162. shadow_ctx->desc_template &= ~(0x3 << GEN8_CTX_ADDRESSING_MODE_SHIFT);
  163. shadow_ctx->desc_template |= workload->ctx_desc.addressing_mode <<
  164. GEN8_CTX_ADDRESSING_MODE_SHIFT;
  165. mutex_lock(&dev_priv->drm.struct_mutex);
  166. /* pin shadow context by gvt even the shadow context will be pinned
  167. * when i915 alloc request. That is because gvt will update the guest
  168. * context from shadow context when workload is completed, and at that
  169. * moment, i915 may already unpined the shadow context to make the
  170. * shadow_ctx pages invalid. So gvt need to pin itself. After update
  171. * the guest context, gvt can unpin the shadow_ctx safely.
  172. */
  173. ret = engine->context_pin(engine, shadow_ctx);
  174. if (ret) {
  175. gvt_vgpu_err("fail to pin shadow context\n");
  176. workload->status = ret;
  177. mutex_unlock(&dev_priv->drm.struct_mutex);
  178. return ret;
  179. }
  180. rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx);
  181. if (IS_ERR(rq)) {
  182. gvt_vgpu_err("fail to allocate gem request\n");
  183. ret = PTR_ERR(rq);
  184. goto out;
  185. }
  186. gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq);
  187. workload->req = i915_gem_request_get(rq);
  188. ret = intel_gvt_scan_and_shadow_workload(workload);
  189. if (ret)
  190. goto out;
  191. if ((workload->ring_id == RCS) &&
  192. (workload->wa_ctx.indirect_ctx.size != 0)) {
  193. ret = intel_gvt_scan_and_shadow_wa_ctx(&workload->wa_ctx);
  194. if (ret)
  195. goto out;
  196. }
  197. ret = populate_shadow_context(workload);
  198. if (ret)
  199. goto out;
  200. if (workload->prepare) {
  201. ret = workload->prepare(workload);
  202. if (ret)
  203. goto out;
  204. }
  205. gvt_dbg_sched("ring id %d submit workload to i915 %p\n",
  206. ring_id, workload->req);
  207. ret = 0;
  208. workload->dispatched = true;
  209. out:
  210. if (ret)
  211. workload->status = ret;
  212. if (!IS_ERR_OR_NULL(rq))
  213. i915_add_request(rq);
  214. else
  215. engine->context_unpin(engine, shadow_ctx);
  216. mutex_unlock(&dev_priv->drm.struct_mutex);
  217. return ret;
  218. }
  219. static struct intel_vgpu_workload *pick_next_workload(
  220. struct intel_gvt *gvt, int ring_id)
  221. {
  222. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  223. struct intel_vgpu_workload *workload = NULL;
  224. mutex_lock(&gvt->lock);
  225. /*
  226. * no current vgpu / will be scheduled out / no workload
  227. * bail out
  228. */
  229. if (!scheduler->current_vgpu) {
  230. gvt_dbg_sched("ring id %d stop - no current vgpu\n", ring_id);
  231. goto out;
  232. }
  233. if (scheduler->need_reschedule) {
  234. gvt_dbg_sched("ring id %d stop - will reschedule\n", ring_id);
  235. goto out;
  236. }
  237. if (list_empty(workload_q_head(scheduler->current_vgpu, ring_id)))
  238. goto out;
  239. /*
  240. * still have current workload, maybe the workload disptacher
  241. * fail to submit it for some reason, resubmit it.
  242. */
  243. if (scheduler->current_workload[ring_id]) {
  244. workload = scheduler->current_workload[ring_id];
  245. gvt_dbg_sched("ring id %d still have current workload %p\n",
  246. ring_id, workload);
  247. goto out;
  248. }
  249. /*
  250. * pick a workload as current workload
  251. * once current workload is set, schedule policy routines
  252. * will wait the current workload is finished when trying to
  253. * schedule out a vgpu.
  254. */
  255. scheduler->current_workload[ring_id] = container_of(
  256. workload_q_head(scheduler->current_vgpu, ring_id)->next,
  257. struct intel_vgpu_workload, list);
  258. workload = scheduler->current_workload[ring_id];
  259. gvt_dbg_sched("ring id %d pick new workload %p\n", ring_id, workload);
  260. atomic_inc(&workload->vgpu->running_workload_num);
  261. out:
  262. mutex_unlock(&gvt->lock);
  263. return workload;
  264. }
  265. static void update_guest_context(struct intel_vgpu_workload *workload)
  266. {
  267. struct intel_vgpu *vgpu = workload->vgpu;
  268. struct intel_gvt *gvt = vgpu->gvt;
  269. int ring_id = workload->ring_id;
  270. struct i915_gem_context *shadow_ctx = workload->vgpu->shadow_ctx;
  271. struct drm_i915_gem_object *ctx_obj =
  272. shadow_ctx->engine[ring_id].state->obj;
  273. struct execlist_ring_context *shadow_ring_context;
  274. struct page *page;
  275. void *src;
  276. unsigned long context_gpa, context_page_num;
  277. int i;
  278. gvt_dbg_sched("ring id %d workload lrca %x\n", ring_id,
  279. workload->ctx_desc.lrca);
  280. context_page_num = intel_lr_context_size(
  281. gvt->dev_priv->engine[ring_id]);
  282. context_page_num = context_page_num >> PAGE_SHIFT;
  283. if (IS_BROADWELL(gvt->dev_priv) && ring_id == RCS)
  284. context_page_num = 19;
  285. i = 2;
  286. while (i < context_page_num) {
  287. context_gpa = intel_vgpu_gma_to_gpa(vgpu->gtt.ggtt_mm,
  288. (u32)((workload->ctx_desc.lrca + i) <<
  289. GTT_PAGE_SHIFT));
  290. if (context_gpa == INTEL_GVT_INVALID_ADDR) {
  291. gvt_vgpu_err("invalid guest context descriptor\n");
  292. return;
  293. }
  294. page = i915_gem_object_get_page(ctx_obj, LRC_PPHWSP_PN + i);
  295. src = kmap(page);
  296. intel_gvt_hypervisor_write_gpa(vgpu, context_gpa, src,
  297. GTT_PAGE_SIZE);
  298. kunmap(page);
  299. i++;
  300. }
  301. intel_gvt_hypervisor_write_gpa(vgpu, workload->ring_context_gpa +
  302. RING_CTX_OFF(ring_header.val), &workload->rb_tail, 4);
  303. page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN);
  304. shadow_ring_context = kmap(page);
  305. #define COPY_REG(name) \
  306. intel_gvt_hypervisor_write_gpa(vgpu, workload->ring_context_gpa + \
  307. RING_CTX_OFF(name.val), &shadow_ring_context->name.val, 4)
  308. COPY_REG(ctx_ctrl);
  309. COPY_REG(ctx_timestamp);
  310. #undef COPY_REG
  311. intel_gvt_hypervisor_write_gpa(vgpu,
  312. workload->ring_context_gpa +
  313. sizeof(*shadow_ring_context),
  314. (void *)shadow_ring_context +
  315. sizeof(*shadow_ring_context),
  316. GTT_PAGE_SIZE - sizeof(*shadow_ring_context));
  317. kunmap(page);
  318. }
  319. static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
  320. {
  321. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  322. struct intel_vgpu_workload *workload;
  323. struct intel_vgpu *vgpu;
  324. int event;
  325. mutex_lock(&gvt->lock);
  326. workload = scheduler->current_workload[ring_id];
  327. vgpu = workload->vgpu;
  328. /* For the workload w/ request, needs to wait for the context
  329. * switch to make sure request is completed.
  330. * For the workload w/o request, directly complete the workload.
  331. */
  332. if (workload->req) {
  333. struct drm_i915_private *dev_priv =
  334. workload->vgpu->gvt->dev_priv;
  335. struct intel_engine_cs *engine =
  336. dev_priv->engine[workload->ring_id];
  337. wait_event(workload->shadow_ctx_status_wq,
  338. !atomic_read(&workload->shadow_ctx_active));
  339. i915_gem_request_put(fetch_and_zero(&workload->req));
  340. if (!workload->status && !vgpu->resetting) {
  341. update_guest_context(workload);
  342. for_each_set_bit(event, workload->pending_events,
  343. INTEL_GVT_EVENT_MAX)
  344. intel_vgpu_trigger_virtual_event(vgpu, event);
  345. }
  346. mutex_lock(&dev_priv->drm.struct_mutex);
  347. /* unpin shadow ctx as the shadow_ctx update is done */
  348. engine->context_unpin(engine, workload->vgpu->shadow_ctx);
  349. mutex_unlock(&dev_priv->drm.struct_mutex);
  350. }
  351. gvt_dbg_sched("ring id %d complete workload %p status %d\n",
  352. ring_id, workload, workload->status);
  353. scheduler->current_workload[ring_id] = NULL;
  354. list_del_init(&workload->list);
  355. workload->complete(workload);
  356. atomic_dec(&vgpu->running_workload_num);
  357. wake_up(&scheduler->workload_complete_wq);
  358. mutex_unlock(&gvt->lock);
  359. }
  360. struct workload_thread_param {
  361. struct intel_gvt *gvt;
  362. int ring_id;
  363. };
  364. static DEFINE_MUTEX(scheduler_mutex);
  365. static int workload_thread(void *priv)
  366. {
  367. struct workload_thread_param *p = (struct workload_thread_param *)priv;
  368. struct intel_gvt *gvt = p->gvt;
  369. int ring_id = p->ring_id;
  370. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  371. struct intel_vgpu_workload *workload = NULL;
  372. struct intel_vgpu *vgpu = NULL;
  373. int ret;
  374. bool need_force_wake = IS_SKYLAKE(gvt->dev_priv)
  375. || IS_KABYLAKE(gvt->dev_priv);
  376. DEFINE_WAIT_FUNC(wait, woken_wake_function);
  377. kfree(p);
  378. gvt_dbg_core("workload thread for ring %d started\n", ring_id);
  379. while (!kthread_should_stop()) {
  380. add_wait_queue(&scheduler->waitq[ring_id], &wait);
  381. do {
  382. workload = pick_next_workload(gvt, ring_id);
  383. if (workload)
  384. break;
  385. wait_woken(&wait, TASK_INTERRUPTIBLE,
  386. MAX_SCHEDULE_TIMEOUT);
  387. } while (!kthread_should_stop());
  388. remove_wait_queue(&scheduler->waitq[ring_id], &wait);
  389. if (!workload)
  390. break;
  391. mutex_lock(&scheduler_mutex);
  392. gvt_dbg_sched("ring id %d next workload %p vgpu %d\n",
  393. workload->ring_id, workload,
  394. workload->vgpu->id);
  395. intel_runtime_pm_get(gvt->dev_priv);
  396. gvt_dbg_sched("ring id %d will dispatch workload %p\n",
  397. workload->ring_id, workload);
  398. if (need_force_wake)
  399. intel_uncore_forcewake_get(gvt->dev_priv,
  400. FORCEWAKE_ALL);
  401. mutex_lock(&gvt->lock);
  402. ret = dispatch_workload(workload);
  403. mutex_unlock(&gvt->lock);
  404. if (ret) {
  405. vgpu = workload->vgpu;
  406. gvt_vgpu_err("fail to dispatch workload, skip\n");
  407. goto complete;
  408. }
  409. gvt_dbg_sched("ring id %d wait workload %p\n",
  410. workload->ring_id, workload);
  411. i915_wait_request(workload->req, 0, MAX_SCHEDULE_TIMEOUT);
  412. complete:
  413. gvt_dbg_sched("will complete workload %p, status: %d\n",
  414. workload, workload->status);
  415. complete_current_workload(gvt, ring_id);
  416. if (need_force_wake)
  417. intel_uncore_forcewake_put(gvt->dev_priv,
  418. FORCEWAKE_ALL);
  419. intel_runtime_pm_put(gvt->dev_priv);
  420. mutex_unlock(&scheduler_mutex);
  421. }
  422. return 0;
  423. }
  424. void intel_gvt_wait_vgpu_idle(struct intel_vgpu *vgpu)
  425. {
  426. struct intel_gvt *gvt = vgpu->gvt;
  427. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  428. if (atomic_read(&vgpu->running_workload_num)) {
  429. gvt_dbg_sched("wait vgpu idle\n");
  430. wait_event(scheduler->workload_complete_wq,
  431. !atomic_read(&vgpu->running_workload_num));
  432. }
  433. }
  434. void intel_gvt_clean_workload_scheduler(struct intel_gvt *gvt)
  435. {
  436. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  437. struct intel_engine_cs *engine;
  438. enum intel_engine_id i;
  439. gvt_dbg_core("clean workload scheduler\n");
  440. for_each_engine(engine, gvt->dev_priv, i) {
  441. atomic_notifier_chain_unregister(
  442. &engine->context_status_notifier,
  443. &gvt->shadow_ctx_notifier_block[i]);
  444. kthread_stop(scheduler->thread[i]);
  445. }
  446. }
  447. int intel_gvt_init_workload_scheduler(struct intel_gvt *gvt)
  448. {
  449. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  450. struct workload_thread_param *param = NULL;
  451. struct intel_engine_cs *engine;
  452. enum intel_engine_id i;
  453. int ret;
  454. gvt_dbg_core("init workload scheduler\n");
  455. init_waitqueue_head(&scheduler->workload_complete_wq);
  456. for_each_engine(engine, gvt->dev_priv, i) {
  457. init_waitqueue_head(&scheduler->waitq[i]);
  458. param = kzalloc(sizeof(*param), GFP_KERNEL);
  459. if (!param) {
  460. ret = -ENOMEM;
  461. goto err;
  462. }
  463. param->gvt = gvt;
  464. param->ring_id = i;
  465. scheduler->thread[i] = kthread_run(workload_thread, param,
  466. "gvt workload %d", i);
  467. if (IS_ERR(scheduler->thread[i])) {
  468. gvt_err("fail to create workload thread\n");
  469. ret = PTR_ERR(scheduler->thread[i]);
  470. goto err;
  471. }
  472. gvt->shadow_ctx_notifier_block[i].notifier_call =
  473. shadow_context_status_change;
  474. atomic_notifier_chain_register(&engine->context_status_notifier,
  475. &gvt->shadow_ctx_notifier_block[i]);
  476. }
  477. return 0;
  478. err:
  479. intel_gvt_clean_workload_scheduler(gvt);
  480. kfree(param);
  481. param = NULL;
  482. return ret;
  483. }
  484. void intel_vgpu_clean_gvt_context(struct intel_vgpu *vgpu)
  485. {
  486. i915_gem_context_put_unlocked(vgpu->shadow_ctx);
  487. }
  488. int intel_vgpu_init_gvt_context(struct intel_vgpu *vgpu)
  489. {
  490. atomic_set(&vgpu->running_workload_num, 0);
  491. vgpu->shadow_ctx = i915_gem_context_create_gvt(
  492. &vgpu->gvt->dev_priv->drm);
  493. if (IS_ERR(vgpu->shadow_ctx))
  494. return PTR_ERR(vgpu->shadow_ctx);
  495. vgpu->shadow_ctx->engine[RCS].initialised = true;
  496. return 0;
  497. }