[PATCH 1/6] drm/i915/gvt: Separate cmd scan from request allocation
Zhenyu Wang
zhenyuw at linux.intel.com
Fri Aug 11 02:24:07 UTC 2017
On 2017.08.10 23:31:35 +0800, fred gao wrote:
> @@ -253,10 +272,37 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
> goto out;
> }
>
> + /* pin shadow context by gvt even the shadow context will be pinned
> + * when i915 alloc request. That is because gvt will update the guest
> + * context from shadow context when workload is completed, and at that
> + * moment, i915 may already unpined the shadow context to make the
> + * shadow_ctx pages invalid. So gvt need to pin itself. After update
> + * the guest context, gvt can unpin the shadow_ctx safely.
> + */
> + ring = engine->context_pin(engine, shadow_ctx);
> + if (IS_ERR(ring)) {
> + ret = PTR_ERR(ring);
> + gvt_vgpu_err("fail to pin shadow context\n");
> + goto out;
> + }
> +
> ret = populate_shadow_context(workload);
> if (ret)
> goto out;
>
> + rq = i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx);
> + if (IS_ERR(rq)) {
> + gvt_vgpu_err("fail to allocate gem request\n");
> + ret = PTR_ERR(rq);
> + goto out;
> + }
> +
> + gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq);
> +
> + workload->req = i915_gem_request_get(rq);
> + ret = copy_workload_to_ring_buffer(workload);
> + if (ret)
> + goto out;
> workload->shadowed = true;
>
> out:
Still need to handle copy error here, so might pick some of your later patch here,
we need proper handling for new function.
> @@ -266,11 +312,7 @@ int intel_gvt_scan_and_shadow_workload(struct intel_vgpu_workload *workload)
> static int dispatch_workload(struct intel_vgpu_workload *workload)
> {
> int ring_id = workload->ring_id;
> - struct i915_gem_context *shadow_ctx = workload->vgpu->shadow_ctx;
> struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv;
> - struct intel_engine_cs *engine = dev_priv->engine[ring_id];
> - struct intel_vgpu *vgpu = workload->vgpu;
> - struct intel_ring *ring;
> int ret = 0;
>
> gvt_dbg_sched("ring id %d prepare to dispatch workload %p\n",
> @@ -288,20 +330,6 @@ static int dispatch_workload(struct intel_vgpu_workload *workload)
> goto out;
> }
>
> - /* pin shadow context by gvt even the shadow context will be pinned
> - * when i915 alloc request. That is because gvt will update the guest
> - * context from shadow context when workload is completed, and at that
> - * moment, i915 may already unpined the shadow context to make the
> - * shadow_ctx pages invalid. So gvt need to pin itself. After update
> - * the guest context, gvt can unpin the shadow_ctx safely.
> - */
> - ring = engine->context_pin(engine, shadow_ctx);
> - if (IS_ERR(ring)) {
> - ret = PTR_ERR(ring);
> - gvt_vgpu_err("fail to pin shadow context\n");
> - goto out;
> - }
> -
> out:
> if (ret)
> workload->status = ret;
> --
> 2.7.4
>
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170811/d5a29360/attachment.sig>
More information about the intel-gvt-dev
mailing list