All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhenyu Wang <zhenyuw@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 10/12] drm/i915/gvt: Use common mapping routines for indirect_ctx object
Date: Wed, 19 Oct 2016 18:26:22 +0800	[thread overview]
Message-ID: <20161019102622.hux2juibcfaeowiy@zhen-hp.sh.intel.com> (raw)
In-Reply-To: <20161019101147.17342-11-chris@chris-wilson.co.uk>


[-- Attachment #1.1: Type: text/plain, Size: 3590 bytes --]

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@chris-wilson.co.uk>

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

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

> ---
>  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@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Open Source Technology Center, Intel ltd.

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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

  reply	other threads:[~2016-10-19 10:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 10:11 gvt gem fixes Chris Wilson
2016-10-19 10:11 ` [PATCH 01/12] drm/i915/gvt: s/drm_gem_object_unreference/i915_gem_object_put/ Chris Wilson
2016-10-19 10:11 ` [PATCH 02/12] drm/i915/gvt: Add runtime pm around fences Chris Wilson
2016-10-19 10:11 ` [PATCH 03/12] drm/i915/gvt: i915_gem_object_create() returns an error pointer Chris Wilson
2016-10-19 10:11 ` [PATCH 04/12] drm/i915: Catch premature unpinning of pages Chris Wilson
2016-10-19 10:26   ` Joonas Lahtinen
2016-10-19 10:11 ` [PATCH 05/12] drm/i915/gvt: Use the returned VMA to provide the virtual address Chris Wilson
2016-10-19 10:11 ` [PATCH 06/12] drm/i915/gvt: Remove dangerous unpin of backing storage of bound GPU object Chris Wilson
2016-10-19 10:11 ` [PATCH 07/12] drm/i915/gvt: Hold a reference on the request Chris Wilson
2016-10-19 10:32   ` Zhenyu Wang
2016-10-19 10:53     ` Chris Wilson
2016-10-20  0:22   ` Zhenyu Wang
2016-10-20  6:52     ` Chris Wilson
2016-10-20  7:33       ` Zhenyu Wang
2016-10-19 10:11 ` [PATCH 08/12] drm/i915/gvt: Stop checking for impossible interrupts from a kthread Chris Wilson
2016-10-19 10:11 ` [PATCH 09/12] drm/i915/gvt: Stop waiting whilst holding struct_mutex Chris Wilson
2016-10-19 10:11 ` [PATCH 10/12] drm/i915/gvt: Use common mapping routines for indirect_ctx object Chris Wilson
2016-10-19 10:26   ` Zhenyu Wang [this message]
2016-10-19 10:11 ` [PATCH 11/12] drm/i915/gvt: Use common mapping routines for shadow_bb object Chris Wilson
2016-10-19 10:11 ` [PATCH 12/12] drm/i915/gvt: Remove defunct vmap_batch() Chris Wilson
2016-10-19 10:45 ` gvt gem fixes Zhenyu Wang
2016-10-19 11:02   ` Chris Wilson
2016-10-20  0:33     ` Zhenyu Wang
2016-10-20  7:02       ` Daniel Vetter
2016-10-20  7:15         ` Zhenyu Wang
2016-10-20  9:13           ` Daniel Vetter
2016-10-19 13:54 ` ✗ Fi.CI.BAT: warning for series starting with [01/12] drm/i915/gvt: s/drm_gem_object_unreference/i915_gem_object_put/ Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019102622.hux2juibcfaeowiy@zhen-hp.sh.intel.com \
    --to=zhenyuw@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.