Lines Matching full:vgpu
39 void populate_pvinfo_page(struct intel_vgpu *vgpu) in populate_pvinfo_page() argument
41 struct drm_i915_private *i915 = vgpu->gvt->gt->i915; in populate_pvinfo_page()
43 vgpu_vreg64_t(vgpu, vgtif_reg(magic)) = VGT_MAGIC; in populate_pvinfo_page()
44 vgpu_vreg_t(vgpu, vgtif_reg(version_major)) = 1; in populate_pvinfo_page()
45 vgpu_vreg_t(vgpu, vgtif_reg(version_minor)) = 0; in populate_pvinfo_page()
46 vgpu_vreg_t(vgpu, vgtif_reg(display_ready)) = 0; in populate_pvinfo_page()
47 vgpu_vreg_t(vgpu, vgtif_reg(vgt_id)) = vgpu->id; in populate_pvinfo_page()
49 vgpu_vreg_t(vgpu, vgtif_reg(vgt_caps)) = VGT_CAPS_FULL_PPGTT; in populate_pvinfo_page()
50 vgpu_vreg_t(vgpu, vgtif_reg(vgt_caps)) |= VGT_CAPS_HWSP_EMULATION; in populate_pvinfo_page()
51 vgpu_vreg_t(vgpu, vgtif_reg(vgt_caps)) |= VGT_CAPS_HUGE_GTT; in populate_pvinfo_page()
53 vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.mappable_gmadr.base)) = in populate_pvinfo_page()
54 vgpu_aperture_gmadr_base(vgpu); in populate_pvinfo_page()
55 vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.mappable_gmadr.size)) = in populate_pvinfo_page()
56 vgpu_aperture_sz(vgpu); in populate_pvinfo_page()
57 vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.nonmappable_gmadr.base)) = in populate_pvinfo_page()
58 vgpu_hidden_gmadr_base(vgpu); in populate_pvinfo_page()
59 vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.nonmappable_gmadr.size)) = in populate_pvinfo_page()
60 vgpu_hidden_sz(vgpu); in populate_pvinfo_page()
62 vgpu_vreg_t(vgpu, vgtif_reg(avail_rs.fence_num)) = vgpu_fence_sz(vgpu); in populate_pvinfo_page()
64 vgpu_vreg_t(vgpu, vgtif_reg(cursor_x_hot)) = UINT_MAX; in populate_pvinfo_page()
65 vgpu_vreg_t(vgpu, vgtif_reg(cursor_y_hot)) = UINT_MAX; in populate_pvinfo_page()
67 gvt_dbg_core("Populate PVINFO PAGE for vGPU %d\n", vgpu->id); in populate_pvinfo_page()
69 vgpu_aperture_gmadr_base(vgpu), vgpu_aperture_sz(vgpu)); in populate_pvinfo_page()
71 vgpu_hidden_gmadr_base(vgpu), vgpu_hidden_sz(vgpu)); in populate_pvinfo_page()
72 gvt_dbg_core("fence size %d\n", vgpu_fence_sz(vgpu)); in populate_pvinfo_page()
78 * vGPU type name is defined as GVTg_Vx_y which contains the physical GPU
81 * Depening on the physical SKU resource, we might see vGPU types like
83 * vGPU on same physical GPU depending on available resource. Each vGPU
85 * many vGPU instance can be created for this type.
99 * intel_gvt_init_vgpu_types - initialize vGPU type list
102 * Initialize vGPU type list based on available resource.
163 * @vgpu: virtual GPU
168 void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu) in intel_gvt_activate_vgpu() argument
170 set_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); in intel_gvt_activate_vgpu()
175 * @vgpu: virtual GPU
181 void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu) in intel_gvt_deactivate_vgpu() argument
183 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_deactivate_vgpu()
185 clear_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); in intel_gvt_deactivate_vgpu()
187 if (atomic_read(&vgpu->submission.running_workload_num)) { in intel_gvt_deactivate_vgpu()
188 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_deactivate_vgpu()
189 intel_gvt_wait_vgpu_idle(vgpu); in intel_gvt_deactivate_vgpu()
190 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_deactivate_vgpu()
193 intel_vgpu_stop_schedule(vgpu); in intel_gvt_deactivate_vgpu()
195 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_deactivate_vgpu()
200 * @vgpu: virtual GPU
207 void intel_gvt_release_vgpu(struct intel_vgpu *vgpu) in intel_gvt_release_vgpu() argument
209 intel_gvt_deactivate_vgpu(vgpu); in intel_gvt_release_vgpu()
211 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_release_vgpu()
212 vgpu->d3_entered = false; in intel_gvt_release_vgpu()
213 intel_vgpu_clean_workloads(vgpu, ALL_ENGINES); in intel_gvt_release_vgpu()
214 intel_vgpu_dmabuf_cleanup(vgpu); in intel_gvt_release_vgpu()
215 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_release_vgpu()
220 * @vgpu: virtual GPU
225 void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu) in intel_gvt_destroy_vgpu() argument
227 struct intel_gvt *gvt = vgpu->gvt; in intel_gvt_destroy_vgpu()
230 drm_WARN(&i915->drm, test_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status), in intel_gvt_destroy_vgpu()
231 "vGPU is still active!\n"); in intel_gvt_destroy_vgpu()
235 * service if no active vgpu. in intel_gvt_destroy_vgpu()
238 idr_remove(&gvt->vgpu_idr, vgpu->id); in intel_gvt_destroy_vgpu()
241 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_destroy_vgpu()
242 intel_gvt_debugfs_remove_vgpu(vgpu); in intel_gvt_destroy_vgpu()
243 intel_vgpu_clean_sched_policy(vgpu); in intel_gvt_destroy_vgpu()
244 intel_vgpu_clean_submission(vgpu); in intel_gvt_destroy_vgpu()
245 intel_vgpu_clean_display(vgpu); in intel_gvt_destroy_vgpu()
246 intel_vgpu_clean_opregion(vgpu); in intel_gvt_destroy_vgpu()
247 intel_vgpu_reset_ggtt(vgpu, true); in intel_gvt_destroy_vgpu()
248 intel_vgpu_clean_gtt(vgpu); in intel_gvt_destroy_vgpu()
249 intel_vgpu_detach_regions(vgpu); in intel_gvt_destroy_vgpu()
250 intel_vgpu_free_resource(vgpu); in intel_gvt_destroy_vgpu()
251 intel_vgpu_clean_mmio(vgpu); in intel_gvt_destroy_vgpu()
252 intel_vgpu_dmabuf_cleanup(vgpu); in intel_gvt_destroy_vgpu()
253 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_destroy_vgpu()
269 struct intel_vgpu *vgpu; in intel_gvt_create_idle_vgpu() local
273 vgpu = vzalloc(sizeof(*vgpu)); in intel_gvt_create_idle_vgpu()
274 if (!vgpu) in intel_gvt_create_idle_vgpu()
277 vgpu->id = IDLE_VGPU_IDR; in intel_gvt_create_idle_vgpu()
278 vgpu->gvt = gvt; in intel_gvt_create_idle_vgpu()
279 mutex_init(&vgpu->vgpu_lock); in intel_gvt_create_idle_vgpu()
282 INIT_LIST_HEAD(&vgpu->submission.workload_q_head[i]); in intel_gvt_create_idle_vgpu()
284 ret = intel_vgpu_init_sched_policy(vgpu); in intel_gvt_create_idle_vgpu()
288 clear_bit(INTEL_VGPU_STATUS_ACTIVE, vgpu->status); in intel_gvt_create_idle_vgpu()
289 return vgpu; in intel_gvt_create_idle_vgpu()
292 vfree(vgpu); in intel_gvt_create_idle_vgpu()
298 * @vgpu: virtual GPU
303 void intel_gvt_destroy_idle_vgpu(struct intel_vgpu *vgpu) in intel_gvt_destroy_idle_vgpu() argument
305 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_destroy_idle_vgpu()
306 intel_vgpu_clean_sched_policy(vgpu); in intel_gvt_destroy_idle_vgpu()
307 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_destroy_idle_vgpu()
309 vfree(vgpu); in intel_gvt_destroy_idle_vgpu()
312 int intel_gvt_create_vgpu(struct intel_vgpu *vgpu, in intel_gvt_create_vgpu() argument
315 struct intel_gvt *gvt = vgpu->gvt; in intel_gvt_create_vgpu()
324 ret = idr_alloc(&gvt->vgpu_idr, vgpu, IDLE_VGPU_IDR + 1, GVT_MAX_VGPU, in intel_gvt_create_vgpu()
329 vgpu->id = ret; in intel_gvt_create_vgpu()
330 vgpu->sched_ctl.weight = conf->weight; in intel_gvt_create_vgpu()
331 mutex_init(&vgpu->vgpu_lock); in intel_gvt_create_vgpu()
332 mutex_init(&vgpu->dmabuf_lock); in intel_gvt_create_vgpu()
333 INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head); in intel_gvt_create_vgpu()
334 INIT_RADIX_TREE(&vgpu->page_track_tree, GFP_KERNEL); in intel_gvt_create_vgpu()
335 idr_init_base(&vgpu->object_idr, 1); in intel_gvt_create_vgpu()
336 intel_vgpu_init_cfg_space(vgpu, 1); in intel_gvt_create_vgpu()
337 vgpu->d3_entered = false; in intel_gvt_create_vgpu()
339 ret = intel_vgpu_init_mmio(vgpu); in intel_gvt_create_vgpu()
343 ret = intel_vgpu_alloc_resource(vgpu, conf); in intel_gvt_create_vgpu()
347 populate_pvinfo_page(vgpu); in intel_gvt_create_vgpu()
349 ret = intel_vgpu_init_gtt(vgpu); in intel_gvt_create_vgpu()
353 ret = intel_vgpu_init_opregion(vgpu); in intel_gvt_create_vgpu()
357 ret = intel_vgpu_init_display(vgpu, conf->edid); in intel_gvt_create_vgpu()
361 ret = intel_vgpu_setup_submission(vgpu); in intel_gvt_create_vgpu()
365 ret = intel_vgpu_init_sched_policy(vgpu); in intel_gvt_create_vgpu()
369 intel_gvt_debugfs_add_vgpu(vgpu); in intel_gvt_create_vgpu()
371 ret = intel_gvt_set_opregion(vgpu); in intel_gvt_create_vgpu()
376 ret = intel_gvt_set_edid(vgpu, PORT_B); in intel_gvt_create_vgpu()
378 ret = intel_gvt_set_edid(vgpu, PORT_D); in intel_gvt_create_vgpu()
382 intel_gvt_update_reg_whitelist(vgpu); in intel_gvt_create_vgpu()
387 intel_vgpu_clean_sched_policy(vgpu); in intel_gvt_create_vgpu()
389 intel_vgpu_clean_submission(vgpu); in intel_gvt_create_vgpu()
391 intel_vgpu_clean_display(vgpu); in intel_gvt_create_vgpu()
393 intel_vgpu_clean_opregion(vgpu); in intel_gvt_create_vgpu()
395 intel_vgpu_clean_gtt(vgpu); in intel_gvt_create_vgpu()
397 intel_vgpu_free_resource(vgpu); in intel_gvt_create_vgpu()
399 intel_vgpu_clean_mmio(vgpu); in intel_gvt_create_vgpu()
401 idr_remove(&gvt->vgpu_idr, vgpu->id); in intel_gvt_create_vgpu()
409 * @vgpu: virtual GPU
410 * @dmlr: vGPU Device Model Level Reset or GT Reset
414 * device model reset or GT reset. The caller should hold the vgpu lock.
416 * vGPU Device Model Level Reset (DMLR) simulates the PCI level reset to reset
417 * the whole vGPU to default state as when it is created. This vGPU function
419 * of vGPU FLR is that reuse a vGPU instance by virtual machines. When we
420 * assign a vGPU to a virtual machine we must isse such reset first.
424 * Unlike the FLR, GT reset only reset particular resource of a vGPU per
435 void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, in intel_gvt_reset_vgpu_locked() argument
438 struct intel_gvt *gvt = vgpu->gvt; in intel_gvt_reset_vgpu_locked()
443 gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n", in intel_gvt_reset_vgpu_locked()
444 vgpu->id, dmlr, engine_mask); in intel_gvt_reset_vgpu_locked()
446 vgpu->resetting_eng = resetting_eng; in intel_gvt_reset_vgpu_locked()
448 intel_vgpu_stop_schedule(vgpu); in intel_gvt_reset_vgpu_locked()
451 * scheduler when the reset is triggered by current vgpu. in intel_gvt_reset_vgpu_locked()
454 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_reset_vgpu_locked()
455 intel_gvt_wait_vgpu_idle(vgpu); in intel_gvt_reset_vgpu_locked()
456 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_reset_vgpu_locked()
459 intel_vgpu_reset_submission(vgpu, resetting_eng); in intel_gvt_reset_vgpu_locked()
462 intel_vgpu_select_submission_ops(vgpu, ALL_ENGINES, 0); in intel_gvt_reset_vgpu_locked()
464 intel_vgpu_invalidate_ppgtt(vgpu); in intel_gvt_reset_vgpu_locked()
467 if(!vgpu->d3_entered) { in intel_gvt_reset_vgpu_locked()
468 intel_vgpu_invalidate_ppgtt(vgpu); in intel_gvt_reset_vgpu_locked()
469 intel_vgpu_destroy_all_ppgtt_mm(vgpu); in intel_gvt_reset_vgpu_locked()
471 intel_vgpu_reset_ggtt(vgpu, true); in intel_gvt_reset_vgpu_locked()
472 intel_vgpu_reset_resource(vgpu); in intel_gvt_reset_vgpu_locked()
475 intel_vgpu_reset_mmio(vgpu, dmlr); in intel_gvt_reset_vgpu_locked()
476 populate_pvinfo_page(vgpu); in intel_gvt_reset_vgpu_locked()
479 intel_vgpu_reset_display(vgpu); in intel_gvt_reset_vgpu_locked()
480 intel_vgpu_reset_cfg_space(vgpu); in intel_gvt_reset_vgpu_locked()
482 vgpu->failsafe = false; in intel_gvt_reset_vgpu_locked()
487 if(vgpu->d3_entered) in intel_gvt_reset_vgpu_locked()
488 vgpu->d3_entered = false; in intel_gvt_reset_vgpu_locked()
490 vgpu->pv_notified = false; in intel_gvt_reset_vgpu_locked()
494 vgpu->resetting_eng = 0; in intel_gvt_reset_vgpu_locked()
495 gvt_dbg_core("reset vgpu%d done\n", vgpu->id); in intel_gvt_reset_vgpu_locked()
501 * @vgpu: virtual GPU
506 void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu) in intel_gvt_reset_vgpu() argument
508 mutex_lock(&vgpu->vgpu_lock); in intel_gvt_reset_vgpu()
509 intel_gvt_reset_vgpu_locked(vgpu, true, 0); in intel_gvt_reset_vgpu()
510 mutex_unlock(&vgpu->vgpu_lock); in intel_gvt_reset_vgpu()