Lines Matching full:vgpu

42 static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm)  in alloc_gm()  argument
44 struct intel_gvt *gvt = vgpu->gvt; in alloc_gm()
52 node = &vgpu->gm.high_gm_node; in alloc_gm()
53 size = vgpu_hidden_sz(vgpu); in alloc_gm()
58 node = &vgpu->gm.low_gm_node; in alloc_gm()
59 size = vgpu_aperture_sz(vgpu); in alloc_gm()
80 static int alloc_vgpu_gm(struct intel_vgpu *vgpu) in alloc_vgpu_gm() argument
82 struct intel_gvt *gvt = vgpu->gvt; in alloc_vgpu_gm()
86 ret = alloc_gm(vgpu, false); in alloc_vgpu_gm()
90 ret = alloc_gm(vgpu, true); in alloc_vgpu_gm()
94 gvt_dbg_core("vgpu%d: alloc low GM start %llx size %llx\n", vgpu->id, in alloc_vgpu_gm()
95 vgpu_aperture_offset(vgpu), vgpu_aperture_sz(vgpu)); in alloc_vgpu_gm()
97 gvt_dbg_core("vgpu%d: alloc high GM start %llx size %llx\n", vgpu->id, in alloc_vgpu_gm()
98 vgpu_hidden_offset(vgpu), vgpu_hidden_sz(vgpu)); in alloc_vgpu_gm()
103 drm_mm_remove_node(&vgpu->gm.low_gm_node); in alloc_vgpu_gm()
108 static void free_vgpu_gm(struct intel_vgpu *vgpu) in free_vgpu_gm() argument
110 struct intel_gvt *gvt = vgpu->gvt; in free_vgpu_gm()
114 drm_mm_remove_node(&vgpu->gm.low_gm_node); in free_vgpu_gm()
115 drm_mm_remove_node(&vgpu->gm.high_gm_node); in free_vgpu_gm()
120 * intel_vgpu_write_fence - write fence registers owned by a vGPU
121 * @vgpu: vGPU instance
122 * @fence: vGPU fence register number
125 * This function is used to write fence registers owned by a vGPU. The vGPU
129 void intel_vgpu_write_fence(struct intel_vgpu *vgpu, in intel_vgpu_write_fence() argument
132 struct intel_gvt *gvt = vgpu->gvt; in intel_vgpu_write_fence()
140 if (drm_WARN_ON(&i915->drm, fence >= vgpu_fence_sz(vgpu))) in intel_vgpu_write_fence()
143 reg = vgpu->fence.regs[fence]; in intel_vgpu_write_fence()
158 static void _clear_vgpu_fence(struct intel_vgpu *vgpu) in _clear_vgpu_fence() argument
162 for (i = 0; i < vgpu_fence_sz(vgpu); i++) in _clear_vgpu_fence()
163 intel_vgpu_write_fence(vgpu, i, 0); in _clear_vgpu_fence()
166 static void free_vgpu_fence(struct intel_vgpu *vgpu) in free_vgpu_fence() argument
168 struct intel_gvt *gvt = vgpu->gvt; in free_vgpu_fence()
174 if (drm_WARN_ON(&gvt->gt->i915->drm, !vgpu_fence_sz(vgpu))) in free_vgpu_fence()
180 _clear_vgpu_fence(vgpu); in free_vgpu_fence()
181 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in free_vgpu_fence()
182 reg = vgpu->fence.regs[i]; in free_vgpu_fence()
184 vgpu->fence.regs[i] = NULL; in free_vgpu_fence()
191 static int alloc_vgpu_fence(struct intel_vgpu *vgpu) in alloc_vgpu_fence() argument
193 struct intel_gvt *gvt = vgpu->gvt; in alloc_vgpu_fence()
204 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in alloc_vgpu_fence()
209 vgpu->fence.regs[i] = reg; in alloc_vgpu_fence()
212 _clear_vgpu_fence(vgpu); in alloc_vgpu_fence()
221 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in alloc_vgpu_fence()
222 reg = vgpu->fence.regs[i]; in alloc_vgpu_fence()
226 vgpu->fence.regs[i] = NULL; in alloc_vgpu_fence()
233 static void free_resource(struct intel_vgpu *vgpu) in free_resource() argument
235 struct intel_gvt *gvt = vgpu->gvt; in free_resource()
237 gvt->gm.vgpu_allocated_low_gm_size -= vgpu_aperture_sz(vgpu); in free_resource()
238 gvt->gm.vgpu_allocated_high_gm_size -= vgpu_hidden_sz(vgpu); in free_resource()
239 gvt->fence.vgpu_allocated_fence_num -= vgpu_fence_sz(vgpu); in free_resource()
242 static int alloc_resource(struct intel_vgpu *vgpu, in alloc_resource() argument
245 struct intel_gvt *gvt = vgpu->gvt; in alloc_resource()
250 gvt_vgpu_err("Invalid vGPU creation params\n"); in alloc_resource()
263 vgpu_aperture_sz(vgpu) = ALIGN(request, I915_GTT_PAGE_SIZE); in alloc_resource()
274 vgpu_hidden_sz(vgpu) = ALIGN(request, I915_GTT_PAGE_SIZE); in alloc_resource()
285 vgpu_fence_sz(vgpu) = request; in alloc_resource()
301 * intel_vgpu_free_resource() - free HW resource owned by a vGPU
302 * @vgpu: a vGPU
304 * This function is used to free the HW resource owned by a vGPU.
307 void intel_vgpu_free_resource(struct intel_vgpu *vgpu) in intel_vgpu_free_resource() argument
309 free_vgpu_gm(vgpu); in intel_vgpu_free_resource()
310 free_vgpu_fence(vgpu); in intel_vgpu_free_resource()
311 free_resource(vgpu); in intel_vgpu_free_resource()
315 * intel_vgpu_reset_resource - reset resource state owned by a vGPU
316 * @vgpu: a vGPU
318 * This function is used to reset resource state owned by a vGPU.
321 void intel_vgpu_reset_resource(struct intel_vgpu *vgpu) in intel_vgpu_reset_resource() argument
323 struct intel_gvt *gvt = vgpu->gvt; in intel_vgpu_reset_resource()
327 _clear_vgpu_fence(vgpu); in intel_vgpu_reset_resource()
331 * intel_vgpu_alloc_resource() - allocate HW resource for a vGPU
332 * @vgpu: vGPU
333 * @conf: vGPU creation params
335 * This function is used to allocate HW resource for a vGPU. User specifies
342 int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu, in intel_vgpu_alloc_resource() argument
347 ret = alloc_resource(vgpu, conf); in intel_vgpu_alloc_resource()
351 ret = alloc_vgpu_gm(vgpu); in intel_vgpu_alloc_resource()
355 ret = alloc_vgpu_fence(vgpu); in intel_vgpu_alloc_resource()
362 free_vgpu_gm(vgpu); in intel_vgpu_alloc_resource()
364 free_resource(vgpu); in intel_vgpu_alloc_resource()