Lines Matching refs:vgpu
41 static int alloc_gm(struct intel_vgpu *vgpu, bool high_gm) in alloc_gm() argument
43 struct intel_gvt *gvt = vgpu->gvt; in alloc_gm()
51 node = &vgpu->gm.high_gm_node; in alloc_gm()
52 size = vgpu_hidden_sz(vgpu); in alloc_gm()
57 node = &vgpu->gm.low_gm_node; in alloc_gm()
58 size = vgpu_aperture_sz(vgpu); in alloc_gm()
79 static int alloc_vgpu_gm(struct intel_vgpu *vgpu) in alloc_vgpu_gm() argument
81 struct intel_gvt *gvt = vgpu->gvt; in alloc_vgpu_gm()
85 ret = alloc_gm(vgpu, false); in alloc_vgpu_gm()
89 ret = alloc_gm(vgpu, true); in alloc_vgpu_gm()
93 gvt_dbg_core("vgpu%d: alloc low GM start %llx size %llx\n", vgpu->id, in alloc_vgpu_gm()
94 vgpu_aperture_offset(vgpu), vgpu_aperture_sz(vgpu)); in alloc_vgpu_gm()
96 gvt_dbg_core("vgpu%d: alloc high GM start %llx size %llx\n", vgpu->id, in alloc_vgpu_gm()
97 vgpu_hidden_offset(vgpu), vgpu_hidden_sz(vgpu)); in alloc_vgpu_gm()
102 drm_mm_remove_node(&vgpu->gm.low_gm_node); in alloc_vgpu_gm()
107 static void free_vgpu_gm(struct intel_vgpu *vgpu) in free_vgpu_gm() argument
109 struct intel_gvt *gvt = vgpu->gvt; in free_vgpu_gm()
113 drm_mm_remove_node(&vgpu->gm.low_gm_node); in free_vgpu_gm()
114 drm_mm_remove_node(&vgpu->gm.high_gm_node); in free_vgpu_gm()
128 void intel_vgpu_write_fence(struct intel_vgpu *vgpu, in intel_vgpu_write_fence() argument
131 struct intel_gvt *gvt = vgpu->gvt; in intel_vgpu_write_fence()
139 if (drm_WARN_ON(&i915->drm, fence >= vgpu_fence_sz(vgpu))) in intel_vgpu_write_fence()
142 reg = vgpu->fence.regs[fence]; in intel_vgpu_write_fence()
157 static void _clear_vgpu_fence(struct intel_vgpu *vgpu) in _clear_vgpu_fence() argument
161 for (i = 0; i < vgpu_fence_sz(vgpu); i++) in _clear_vgpu_fence()
162 intel_vgpu_write_fence(vgpu, i, 0); in _clear_vgpu_fence()
165 static void free_vgpu_fence(struct intel_vgpu *vgpu) in free_vgpu_fence() argument
167 struct intel_gvt *gvt = vgpu->gvt; in free_vgpu_fence()
173 if (drm_WARN_ON(&gvt->gt->i915->drm, !vgpu_fence_sz(vgpu))) in free_vgpu_fence()
179 _clear_vgpu_fence(vgpu); in free_vgpu_fence()
180 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in free_vgpu_fence()
181 reg = vgpu->fence.regs[i]; in free_vgpu_fence()
183 vgpu->fence.regs[i] = NULL; in free_vgpu_fence()
190 static int alloc_vgpu_fence(struct intel_vgpu *vgpu) in alloc_vgpu_fence() argument
192 struct intel_gvt *gvt = vgpu->gvt; in alloc_vgpu_fence()
203 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in alloc_vgpu_fence()
208 vgpu->fence.regs[i] = reg; in alloc_vgpu_fence()
211 _clear_vgpu_fence(vgpu); in alloc_vgpu_fence()
220 for (i = 0; i < vgpu_fence_sz(vgpu); i++) { in alloc_vgpu_fence()
221 reg = vgpu->fence.regs[i]; in alloc_vgpu_fence()
225 vgpu->fence.regs[i] = NULL; in alloc_vgpu_fence()
232 static void free_resource(struct intel_vgpu *vgpu) in free_resource() argument
234 struct intel_gvt *gvt = vgpu->gvt; in free_resource()
236 gvt->gm.vgpu_allocated_low_gm_size -= vgpu_aperture_sz(vgpu); in free_resource()
237 gvt->gm.vgpu_allocated_high_gm_size -= vgpu_hidden_sz(vgpu); in free_resource()
238 gvt->fence.vgpu_allocated_fence_num -= vgpu_fence_sz(vgpu); in free_resource()
241 static int alloc_resource(struct intel_vgpu *vgpu, in alloc_resource() argument
244 struct intel_gvt *gvt = vgpu->gvt; in alloc_resource()
262 vgpu_aperture_sz(vgpu) = ALIGN(request, I915_GTT_PAGE_SIZE); in alloc_resource()
273 vgpu_hidden_sz(vgpu) = ALIGN(request, I915_GTT_PAGE_SIZE); in alloc_resource()
284 vgpu_fence_sz(vgpu) = request; in alloc_resource()
306 void intel_vgpu_free_resource(struct intel_vgpu *vgpu) in intel_vgpu_free_resource() argument
308 free_vgpu_gm(vgpu); in intel_vgpu_free_resource()
309 free_vgpu_fence(vgpu); in intel_vgpu_free_resource()
310 free_resource(vgpu); in intel_vgpu_free_resource()
320 void intel_vgpu_reset_resource(struct intel_vgpu *vgpu) in intel_vgpu_reset_resource() argument
322 struct intel_gvt *gvt = vgpu->gvt; in intel_vgpu_reset_resource()
326 _clear_vgpu_fence(vgpu); in intel_vgpu_reset_resource()
341 int intel_vgpu_alloc_resource(struct intel_vgpu *vgpu, in intel_vgpu_alloc_resource() argument
346 ret = alloc_resource(vgpu, param); in intel_vgpu_alloc_resource()
350 ret = alloc_vgpu_gm(vgpu); in intel_vgpu_alloc_resource()
354 ret = alloc_vgpu_fence(vgpu); in intel_vgpu_alloc_resource()
361 free_vgpu_gm(vgpu); in intel_vgpu_alloc_resource()
363 free_resource(vgpu); in intel_vgpu_alloc_resource()