Re: [PATCH 10/12] drm/i915/gvt: Use common mapping routines for indirect_ctx object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2016.10.19 11:11:45 +0100, Chris Wilson wrote:
> We have the ability to map an object, so use it rather than opencode it
> badly.
> 
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

Planned to fix these mapping too, obviously not fast than you..

Reviewed-by: Zhenyu Wang <zhenyuw@xxxxxxxxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/gvt/cmd_parser.c | 28 +++++++++-------------------
>  drivers/gpu/drm/i915/gvt/execlist.c   |  2 +-
>  2 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> index 464fc3c9935b..2b166094444b 100644
> --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
> +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> @@ -2715,7 +2715,7 @@ static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
>  	unsigned long guest_gma = wa_ctx->indirect_ctx.guest_gma;
>  	struct drm_i915_gem_object *obj;
>  	int ret = 0;
> -	void *dest = NULL;
> +	void *map;
>  
>  	obj = i915_gem_object_create(dev,
>  				     roundup(ctx_size + CACHELINE_BYTES,
> @@ -2723,18 +2723,12 @@ static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
>  	if (IS_ERR(obj))
>  		return PTR_ERR(obj);
>  
> -	ret = i915_gem_object_get_pages(obj);
> -	if (ret)
> -		goto put_obj;
> -
> -	i915_gem_object_pin_pages(obj);
> -
>  	/* get the va of the shadow batch buffer */
> -	dest = (void *)vmap_batch(obj, 0, ctx_size + CACHELINE_BYTES);
> -	if (!dest) {
> +	map = i915_gem_object_pin_map(obj, I915_MAP_WB);
> +	if (IS_ERR(map)) {
>  		gvt_err("failed to vmap shadow indirect ctx\n");
> -		ret = -ENOMEM;
> -		goto unpin_src;
> +		ret = PTR_ERR(map);
> +		goto put_obj;
>  	}
>  
>  	ret = i915_gem_object_set_to_cpu_domain(obj, false);
> @@ -2743,25 +2737,21 @@ static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
>  		goto unmap_src;
>  	}
>  
> -	wa_ctx->indirect_ctx.shadow_va = dest;
> -
> -	memset(dest, 0, round_up(ctx_size + CACHELINE_BYTES, PAGE_SIZE));
> -
>  	ret = copy_gma_to_hva(wa_ctx->workload->vgpu,
>  				wa_ctx->workload->vgpu->gtt.ggtt_mm,
> -				guest_gma, guest_gma + ctx_size, dest);
> +				guest_gma, guest_gma + ctx_size,
> +				map);
>  	if (ret) {
>  		gvt_err("fail to copy guest indirect ctx\n");
>  		goto unmap_src;
>  	}
>  
>  	wa_ctx->indirect_ctx.obj = obj;
> +	wa_ctx->indirect_ctx.shadow_va = map;
>  	return 0;
>  
>  unmap_src:
> -	vunmap(dest);
> -unpin_src:
> -	i915_gem_object_unpin_pages(wa_ctx->indirect_ctx.obj);
> +	i915_gem_object_unpin_map(obj);
>  put_obj:
>  	i915_gem_object_put(wa_ctx->indirect_ctx.obj);
>  	return ret;
> diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c
> index b79d148a4e32..d8a6d6366899 100644
> --- a/drivers/gpu/drm/i915/gvt/execlist.c
> +++ b/drivers/gpu/drm/i915/gvt/execlist.c
> @@ -517,8 +517,8 @@ static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
>  	if (wa_ctx->indirect_ctx.size == 0)
>  		return;
>  
> +	i915_gem_object_unpin_map(wa_ctx->indirect_ctx.obj);
>  	i915_gem_object_put(wa_ctx->indirect_ctx.obj);
> -	kvfree(wa_ctx->indirect_ctx.shadow_va);
>  }
>  
>  static int complete_execlist_workload(struct intel_vgpu_workload *workload)
> -- 
> 2.9.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux