vgpu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. * Eddie Dong <eddie.dong@intel.com>
  25. * Kevin Tian <kevin.tian@intel.com>
  26. *
  27. * Contributors:
  28. * Ping Gao <ping.a.gao@intel.com>
  29. * Zhi Wang <zhi.a.wang@intel.com>
  30. * Bing Niu <bing.niu@intel.com>
  31. *
  32. */
  33. #include "i915_drv.h"
  34. #include "gvt.h"
  35. #include "i915_pvinfo.h"
  36. void populate_pvinfo_page(struct intel_vgpu *vgpu)
  37. {
  38. /* setup the ballooning information */
  39. vgpu_vreg64_t(vgpu, vgtif_reg(magic)) = VGT_MAGIC;
  40. vgpu_vreg_t(vgpu, vgtif_reg(version_major)) = 1;
  41. vgpu_vreg_t(vgpu, vgtif_reg(version_minor)) = 0;
  42. vgpu_vreg_t(vgpu, vgtif_reg(display_ready)) = 0;
  43. vgpu_vreg_t(vgpu, vgtif_reg(vgt_id)) = vgpu->id;
  44. vgpu_vreg_t(vgpu, vgtif_reg(vgt_caps)) = VGT_CAPS_FULL_48BIT_PPGTT;
  45. vgpu_vreg_t(vgpu, vgtif_reg(vgt_caps)) |= VGT_CAPS_HWSP_EMULATION;
  46. vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.mappable_gmadr.base)) =
  47. vgpu_aperture_gmadr_base(vgpu);
  48. vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.mappable_gmadr.size)) =
  49. vgpu_aperture_sz(vgpu);
  50. vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.nonmappable_gmadr.base)) =
  51. vgpu_hidden_gmadr_base(vgpu);
  52. vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.nonmappable_gmadr.size)) =
  53. vgpu_hidden_sz(vgpu);
  54. vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.fence_num)) = vgpu_fence_sz(vgpu);
  55. gvt_dbg_core("Populate PVINFO PAGE for vGPU %d\n", vgpu->id);
  56. gvt_dbg_core("aperture base [GMADR] 0x%llx size 0x%llx\n",
  57. vgpu_aperture_gmadr_base(vgpu), vgpu_aperture_sz(vgpu));
  58. gvt_dbg_core("hidden base [GMADR] 0x%llx size=0x%llx\n",
  59. vgpu_hidden_gmadr_base(vgpu), vgpu_hidden_sz(vgpu));
  60. gvt_dbg_core("fence size %d\n", vgpu_fence_sz(vgpu));
  61. WARN_ON(sizeof(struct vgt_if) != VGT_PVINFO_SIZE);
  62. }
  63. #define VGPU_MAX_WEIGHT 16
  64. #define VGPU_WEIGHT(vgpu_num) \
  65. (VGPU_MAX_WEIGHT / (vgpu_num))
  66. static struct {
  67. unsigned int low_mm;
  68. unsigned int high_mm;
  69. unsigned int fence;
  70. /* A vGPU with a weight of 8 will get twice as much GPU as a vGPU
  71. * with a weight of 4 on a contended host, different vGPU type has
  72. * different weight set. Legal weights range from 1 to 16.
  73. */
  74. unsigned int weight;
  75. enum intel_vgpu_edid edid;
  76. char *name;
  77. } vgpu_types[] = {
  78. /* Fixed vGPU type table */
  79. { MB_TO_BYTES(64), MB_TO_BYTES(384), 4, VGPU_WEIGHT(8), GVT_EDID_1024_768, "8" },
  80. { MB_TO_BYTES(128), MB_TO_BYTES(512), 4, VGPU_WEIGHT(4), GVT_EDID_1920_1200, "4" },
  81. { MB_TO_BYTES(256), MB_TO_BYTES(1024), 4, VGPU_WEIGHT(2), GVT_EDID_1920_1200, "2" },
  82. { MB_TO_BYTES(512), MB_TO_BYTES(2048), 4, VGPU_WEIGHT(1), GVT_EDID_1920_1200, "1" },
  83. };
  84. /**
  85. * intel_gvt_init_vgpu_types - initialize vGPU type list
  86. * @gvt : GVT device
  87. *
  88. * Initialize vGPU type list based on available resource.
  89. *
  90. */
  91. int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
  92. {
  93. unsigned int num_types;
  94. unsigned int i, low_avail, high_avail;
  95. unsigned int min_low;
  96. /* vGPU type name is defined as GVTg_Vx_y which contains
  97. * physical GPU generation type (e.g V4 as BDW server, V5 as
  98. * SKL server).
  99. *
  100. * Depend on physical SKU resource, might see vGPU types like
  101. * GVTg_V4_8, GVTg_V4_4, GVTg_V4_2, etc. We can create
  102. * different types of vGPU on same physical GPU depending on
  103. * available resource. Each vGPU type will have "avail_instance"
  104. * to indicate how many vGPU instance can be created for this
  105. * type.
  106. *
  107. */
  108. low_avail = gvt_aperture_sz(gvt) - HOST_LOW_GM_SIZE;
  109. high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE;
  110. num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]);
  111. gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type),
  112. GFP_KERNEL);
  113. if (!gvt->types)
  114. return -ENOMEM;
  115. min_low = MB_TO_BYTES(32);
  116. for (i = 0; i < num_types; ++i) {
  117. if (low_avail / vgpu_types[i].low_mm == 0)
  118. break;
  119. gvt->types[i].low_gm_size = vgpu_types[i].low_mm;
  120. gvt->types[i].high_gm_size = vgpu_types[i].high_mm;
  121. gvt->types[i].fence = vgpu_types[i].fence;
  122. if (vgpu_types[i].weight < 1 ||
  123. vgpu_types[i].weight > VGPU_MAX_WEIGHT)
  124. return -EINVAL;
  125. gvt->types[i].weight = vgpu_types[i].weight;
  126. gvt->types[i].resolution = vgpu_types[i].edid;
  127. gvt->types[i].avail_instance = min(low_avail / vgpu_types[i].low_mm,
  128. high_avail / vgpu_types[i].high_mm);
  129. if (IS_GEN8(gvt->dev_priv))
  130. sprintf(gvt->types[i].name, "GVTg_V4_%s",
  131. vgpu_types[i].name);
  132. else if (IS_GEN9(gvt->dev_priv))
  133. sprintf(gvt->types[i].name, "GVTg_V5_%s",
  134. vgpu_types[i].name);
  135. gvt_dbg_core("type[%d]: %s avail %u low %u high %u fence %u weight %u res %s\n",
  136. i, gvt->types[i].name,
  137. gvt->types[i].avail_instance,
  138. gvt->types[i].low_gm_size,
  139. gvt->types[i].high_gm_size, gvt->types[i].fence,
  140. gvt->types[i].weight,
  141. vgpu_edid_str(gvt->types[i].resolution));
  142. }
  143. gvt->num_types = i;
  144. return 0;
  145. }
  146. void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt)
  147. {
  148. kfree(gvt->types);
  149. }
  150. static void intel_gvt_update_vgpu_types(struct intel_gvt *gvt)
  151. {
  152. int i;
  153. unsigned int low_gm_avail, high_gm_avail, fence_avail;
  154. unsigned int low_gm_min, high_gm_min, fence_min;
  155. /* Need to depend on maxium hw resource size but keep on
  156. * static config for now.
  157. */
  158. low_gm_avail = gvt_aperture_sz(gvt) - HOST_LOW_GM_SIZE -
  159. gvt->gm.vgpu_allocated_low_gm_size;
  160. high_gm_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE -
  161. gvt->gm.vgpu_allocated_high_gm_size;
  162. fence_avail = gvt_fence_sz(gvt) - HOST_FENCE -
  163. gvt->fence.vgpu_allocated_fence_num;
  164. for (i = 0; i < gvt->num_types; i++) {
  165. low_gm_min = low_gm_avail / gvt->types[i].low_gm_size;
  166. high_gm_min = high_gm_avail / gvt->types[i].high_gm_size;
  167. fence_min = fence_avail / gvt->types[i].fence;
  168. gvt->types[i].avail_instance = min(min(low_gm_min, high_gm_min),
  169. fence_min);
  170. gvt_dbg_core("update type[%d]: %s avail %u low %u high %u fence %u\n",
  171. i, gvt->types[i].name,
  172. gvt->types[i].avail_instance, gvt->types[i].low_gm_size,
  173. gvt->types[i].high_gm_size, gvt->types[i].fence);
  174. }
  175. }
  176. /**
  177. * intel_gvt_active_vgpu - activate a virtual GPU
  178. * @vgpu: virtual GPU
  179. *
  180. * This function is called when user wants to activate a virtual GPU.
  181. *
  182. */
  183. void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu)
  184. {
  185. mutex_lock(&vgpu->gvt->lock);
  186. vgpu->active = true;
  187. mutex_unlock(&vgpu->gvt->lock);
  188. }
  189. /**
  190. * intel_gvt_deactive_vgpu - deactivate a virtual GPU
  191. * @vgpu: virtual GPU
  192. *
  193. * This function is called when user wants to deactivate a virtual GPU.
  194. * All virtual GPU runtime information will be destroyed.
  195. *
  196. */
  197. void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu)
  198. {
  199. struct intel_gvt *gvt = vgpu->gvt;
  200. mutex_lock(&gvt->lock);
  201. vgpu->active = false;
  202. if (atomic_read(&vgpu->submission.running_workload_num)) {
  203. mutex_unlock(&gvt->lock);
  204. intel_gvt_wait_vgpu_idle(vgpu);
  205. mutex_lock(&gvt->lock);
  206. }
  207. intel_vgpu_stop_schedule(vgpu);
  208. intel_vgpu_dmabuf_cleanup(vgpu);
  209. mutex_unlock(&gvt->lock);
  210. }
  211. /**
  212. * intel_gvt_destroy_vgpu - destroy a virtual GPU
  213. * @vgpu: virtual GPU
  214. *
  215. * This function is called when user wants to destroy a virtual GPU.
  216. *
  217. */
  218. void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
  219. {
  220. struct intel_gvt *gvt = vgpu->gvt;
  221. mutex_lock(&gvt->lock);
  222. WARN(vgpu->active, "vGPU is still active!\n");
  223. intel_gvt_debugfs_remove_vgpu(vgpu);
  224. idr_remove(&gvt->vgpu_idr, vgpu->id);
  225. if (idr_is_empty(&gvt->vgpu_idr))
  226. intel_gvt_clean_irq(gvt);
  227. intel_vgpu_clean_sched_policy(vgpu);
  228. intel_vgpu_clean_submission(vgpu);
  229. intel_vgpu_clean_display(vgpu);
  230. intel_vgpu_clean_opregion(vgpu);
  231. intel_vgpu_clean_gtt(vgpu);
  232. intel_gvt_hypervisor_detach_vgpu(vgpu);
  233. intel_vgpu_free_resource(vgpu);
  234. intel_vgpu_clean_mmio(vgpu);
  235. intel_vgpu_dmabuf_cleanup(vgpu);
  236. vfree(vgpu);
  237. intel_gvt_update_vgpu_types(gvt);
  238. mutex_unlock(&gvt->lock);
  239. }
  240. #define IDLE_VGPU_IDR 0
  241. /**
  242. * intel_gvt_create_idle_vgpu - create an idle virtual GPU
  243. * @gvt: GVT device
  244. *
  245. * This function is called when user wants to create an idle virtual GPU.
  246. *
  247. * Returns:
  248. * pointer to intel_vgpu, error pointer if failed.
  249. */
  250. struct intel_vgpu *intel_gvt_create_idle_vgpu(struct intel_gvt *gvt)
  251. {
  252. struct intel_vgpu *vgpu;
  253. enum intel_engine_id i;
  254. int ret;
  255. vgpu = vzalloc(sizeof(*vgpu));
  256. if (!vgpu)
  257. return ERR_PTR(-ENOMEM);
  258. vgpu->id = IDLE_VGPU_IDR;
  259. vgpu->gvt = gvt;
  260. for (i = 0; i < I915_NUM_ENGINES; i++)
  261. INIT_LIST_HEAD(&vgpu->submission.workload_q_head[i]);
  262. ret = intel_vgpu_init_sched_policy(vgpu);
  263. if (ret)
  264. goto out_free_vgpu;
  265. vgpu->active = false;
  266. return vgpu;
  267. out_free_vgpu:
  268. vfree(vgpu);
  269. return ERR_PTR(ret);
  270. }
  271. /**
  272. * intel_gvt_destroy_vgpu - destroy an idle virtual GPU
  273. * @vgpu: virtual GPU
  274. *
  275. * This function is called when user wants to destroy an idle virtual GPU.
  276. *
  277. */
  278. void intel_gvt_destroy_idle_vgpu(struct intel_vgpu *vgpu)
  279. {
  280. intel_vgpu_clean_sched_policy(vgpu);
  281. vfree(vgpu);
  282. }
  283. static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
  284. struct intel_vgpu_creation_params *param)
  285. {
  286. struct intel_vgpu *vgpu;
  287. int ret;
  288. gvt_dbg_core("handle %llu low %llu MB high %llu MB fence %llu\n",
  289. param->handle, param->low_gm_sz, param->high_gm_sz,
  290. param->fence_sz);
  291. vgpu = vzalloc(sizeof(*vgpu));
  292. if (!vgpu)
  293. return ERR_PTR(-ENOMEM);
  294. mutex_lock(&gvt->lock);
  295. ret = idr_alloc(&gvt->vgpu_idr, vgpu, IDLE_VGPU_IDR + 1, GVT_MAX_VGPU,
  296. GFP_KERNEL);
  297. if (ret < 0)
  298. goto out_free_vgpu;
  299. vgpu->id = ret;
  300. vgpu->handle = param->handle;
  301. vgpu->gvt = gvt;
  302. vgpu->sched_ctl.weight = param->weight;
  303. INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head);
  304. INIT_RADIX_TREE(&vgpu->page_track_tree, GFP_KERNEL);
  305. idr_init(&vgpu->object_idr);
  306. intel_vgpu_init_cfg_space(vgpu, param->primary);
  307. ret = intel_vgpu_init_mmio(vgpu);
  308. if (ret)
  309. goto out_clean_idr;
  310. ret = intel_vgpu_alloc_resource(vgpu, param);
  311. if (ret)
  312. goto out_clean_vgpu_mmio;
  313. populate_pvinfo_page(vgpu);
  314. ret = intel_gvt_hypervisor_attach_vgpu(vgpu);
  315. if (ret)
  316. goto out_clean_vgpu_resource;
  317. ret = intel_vgpu_init_gtt(vgpu);
  318. if (ret)
  319. goto out_detach_hypervisor_vgpu;
  320. ret = intel_vgpu_init_opregion(vgpu);
  321. if (ret)
  322. goto out_clean_gtt;
  323. ret = intel_vgpu_init_display(vgpu, param->resolution);
  324. if (ret)
  325. goto out_clean_opregion;
  326. ret = intel_vgpu_setup_submission(vgpu);
  327. if (ret)
  328. goto out_clean_display;
  329. ret = intel_vgpu_init_sched_policy(vgpu);
  330. if (ret)
  331. goto out_clean_submission;
  332. ret = intel_gvt_debugfs_add_vgpu(vgpu);
  333. if (ret)
  334. goto out_clean_sched_policy;
  335. ret = intel_gvt_hypervisor_set_opregion(vgpu);
  336. if (ret)
  337. goto out_clean_sched_policy;
  338. mutex_unlock(&gvt->lock);
  339. return vgpu;
  340. out_clean_sched_policy:
  341. intel_vgpu_clean_sched_policy(vgpu);
  342. out_clean_submission:
  343. intel_vgpu_clean_submission(vgpu);
  344. out_clean_display:
  345. intel_vgpu_clean_display(vgpu);
  346. out_clean_opregion:
  347. intel_vgpu_clean_opregion(vgpu);
  348. out_clean_gtt:
  349. intel_vgpu_clean_gtt(vgpu);
  350. out_detach_hypervisor_vgpu:
  351. intel_gvt_hypervisor_detach_vgpu(vgpu);
  352. out_clean_vgpu_resource:
  353. intel_vgpu_free_resource(vgpu);
  354. out_clean_vgpu_mmio:
  355. intel_vgpu_clean_mmio(vgpu);
  356. out_clean_idr:
  357. idr_remove(&gvt->vgpu_idr, vgpu->id);
  358. out_free_vgpu:
  359. vfree(vgpu);
  360. mutex_unlock(&gvt->lock);
  361. return ERR_PTR(ret);
  362. }
  363. /**
  364. * intel_gvt_create_vgpu - create a virtual GPU
  365. * @gvt: GVT device
  366. * @type: type of the vGPU to create
  367. *
  368. * This function is called when user wants to create a virtual GPU.
  369. *
  370. * Returns:
  371. * pointer to intel_vgpu, error pointer if failed.
  372. */
  373. struct intel_vgpu *intel_gvt_create_vgpu(struct intel_gvt *gvt,
  374. struct intel_vgpu_type *type)
  375. {
  376. struct intel_vgpu_creation_params param;
  377. struct intel_vgpu *vgpu;
  378. param.handle = 0;
  379. param.primary = 1;
  380. param.low_gm_sz = type->low_gm_size;
  381. param.high_gm_sz = type->high_gm_size;
  382. param.fence_sz = type->fence;
  383. param.weight = type->weight;
  384. param.resolution = type->resolution;
  385. /* XXX current param based on MB */
  386. param.low_gm_sz = BYTES_TO_MB(param.low_gm_sz);
  387. param.high_gm_sz = BYTES_TO_MB(param.high_gm_sz);
  388. vgpu = __intel_gvt_create_vgpu(gvt, &param);
  389. if (IS_ERR(vgpu))
  390. return vgpu;
  391. /* calculate left instance change for types */
  392. intel_gvt_update_vgpu_types(gvt);
  393. return vgpu;
  394. }
  395. /**
  396. * intel_gvt_reset_vgpu_locked - reset a virtual GPU by DMLR or GT reset
  397. * @vgpu: virtual GPU
  398. * @dmlr: vGPU Device Model Level Reset or GT Reset
  399. * @engine_mask: engines to reset for GT reset
  400. *
  401. * This function is called when user wants to reset a virtual GPU through
  402. * device model reset or GT reset. The caller should hold the gvt lock.
  403. *
  404. * vGPU Device Model Level Reset (DMLR) simulates the PCI level reset to reset
  405. * the whole vGPU to default state as when it is created. This vGPU function
  406. * is required both for functionary and security concerns.The ultimate goal
  407. * of vGPU FLR is that reuse a vGPU instance by virtual machines. When we
  408. * assign a vGPU to a virtual machine we must isse such reset first.
  409. *
  410. * Full GT Reset and Per-Engine GT Reset are soft reset flow for GPU engines
  411. * (Render, Blitter, Video, Video Enhancement). It is defined by GPU Spec.
  412. * Unlike the FLR, GT reset only reset particular resource of a vGPU per
  413. * the reset request. Guest driver can issue a GT reset by programming the
  414. * virtual GDRST register to reset specific virtual GPU engine or all
  415. * engines.
  416. *
  417. * The parameter dev_level is to identify if we will do DMLR or GT reset.
  418. * The parameter engine_mask is to specific the engines that need to be
  419. * resetted. If value ALL_ENGINES is given for engine_mask, it means
  420. * the caller requests a full GT reset that we will reset all virtual
  421. * GPU engines. For FLR, engine_mask is ignored.
  422. */
  423. void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
  424. unsigned int engine_mask)
  425. {
  426. struct intel_gvt *gvt = vgpu->gvt;
  427. struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
  428. unsigned int resetting_eng = dmlr ? ALL_ENGINES : engine_mask;
  429. gvt_dbg_core("------------------------------------------\n");
  430. gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n",
  431. vgpu->id, dmlr, engine_mask);
  432. vgpu->resetting_eng = resetting_eng;
  433. intel_vgpu_stop_schedule(vgpu);
  434. /*
  435. * The current_vgpu will set to NULL after stopping the
  436. * scheduler when the reset is triggered by current vgpu.
  437. */
  438. if (scheduler->current_vgpu == NULL) {
  439. mutex_unlock(&gvt->lock);
  440. intel_gvt_wait_vgpu_idle(vgpu);
  441. mutex_lock(&gvt->lock);
  442. }
  443. intel_vgpu_reset_submission(vgpu, resetting_eng);
  444. /* full GPU reset or device model level reset */
  445. if (engine_mask == ALL_ENGINES || dmlr) {
  446. intel_vgpu_select_submission_ops(vgpu, ALL_ENGINES, 0);
  447. intel_vgpu_invalidate_ppgtt(vgpu);
  448. /*fence will not be reset during virtual reset */
  449. if (dmlr) {
  450. intel_vgpu_reset_gtt(vgpu);
  451. intel_vgpu_reset_resource(vgpu);
  452. }
  453. intel_vgpu_reset_mmio(vgpu, dmlr);
  454. populate_pvinfo_page(vgpu);
  455. intel_vgpu_reset_display(vgpu);
  456. if (dmlr) {
  457. intel_vgpu_reset_cfg_space(vgpu);
  458. /* only reset the failsafe mode when dmlr reset */
  459. vgpu->failsafe = false;
  460. vgpu->pv_notified = false;
  461. }
  462. }
  463. vgpu->resetting_eng = 0;
  464. gvt_dbg_core("reset vgpu%d done\n", vgpu->id);
  465. gvt_dbg_core("------------------------------------------\n");
  466. }
  467. /**
  468. * intel_gvt_reset_vgpu - reset a virtual GPU (Function Level)
  469. * @vgpu: virtual GPU
  470. *
  471. * This function is called when user wants to reset a virtual GPU.
  472. *
  473. */
  474. void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu)
  475. {
  476. mutex_lock(&vgpu->gvt->lock);
  477. intel_gvt_reset_vgpu_locked(vgpu, true, 0);
  478. mutex_unlock(&vgpu->gvt->lock);
  479. }