From: Zhenyu Wang 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 Message-ID: <20161019102622.hux2juibcfaeowiy@zhen-hp.sh.intel.com> References: <20161019101147.17342-1-chris@chris-wilson.co.uk> <20161019101147.17342-11-chris@chris-wilson.co.uk> Reply-To: Zhenyu Wang Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1956117517==" Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB2096E8C4 for ; Wed, 19 Oct 2016 10:30:40 +0000 (UTC) In-Reply-To: <20161019101147.17342-11-chris@chris-wilson.co.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============1956117517== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sbculjrk2ifboyjx" Content-Disposition: inline --sbculjrk2ifboyjx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Chris Wilson Planned to fix these mapping too, obviously not fast than you.. Reviewed-by: Zhenyu Wang > --- > drivers/gpu/drm/i915/gvt/cmd_parser.c | 28 +++++++++------------------- > drivers/gpu/drm/i915/gvt/execlist.c | 2 +- > 2 files changed, 10 insertions(+), 20 deletions(-) >=20 > 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 =3D wa_ctx->indirect_ctx.guest_gma; > struct drm_i915_gem_object *obj; > int ret =3D 0; > - void *dest =3D NULL; > + void *map; > =20 > obj =3D i915_gem_object_create(dev, > roundup(ctx_size + CACHELINE_BYTES, > @@ -2723,18 +2723,12 @@ static int shadow_indirect_ctx(struct intel_shado= w_wa_ctx *wa_ctx) > if (IS_ERR(obj)) > return PTR_ERR(obj); > =20 > - ret =3D 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 =3D (void *)vmap_batch(obj, 0, ctx_size + CACHELINE_BYTES); > - if (!dest) { > + map =3D i915_gem_object_pin_map(obj, I915_MAP_WB); > + if (IS_ERR(map)) { > gvt_err("failed to vmap shadow indirect ctx\n"); > - ret =3D -ENOMEM; > - goto unpin_src; > + ret =3D PTR_ERR(map); > + goto put_obj; > } > =20 > ret =3D i915_gem_object_set_to_cpu_domain(obj, false); > @@ -2743,25 +2737,21 @@ static int shadow_indirect_ctx(struct intel_shado= w_wa_ctx *wa_ctx) > goto unmap_src; > } > =20 > - wa_ctx->indirect_ctx.shadow_va =3D dest; > - > - memset(dest, 0, round_up(ctx_size + CACHELINE_BYTES, PAGE_SIZE)); > - > ret =3D 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; > } > =20 > wa_ctx->indirect_ctx.obj =3D obj; > + wa_ctx->indirect_ctx.shadow_va =3D map; > return 0; > =20 > 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/g= vt/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 =3D=3D 0) > return; > =20 > + 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); > } > =20 > static int complete_execlist_workload(struct intel_vgpu_workload *worklo= ad) > --=20 > 2.9.3 >=20 > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --sbculjrk2ifboyjx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEABECAAYFAlgHSkkACgkQsQQaM014GCeTEwCeJcblGdx0ACmiqm8YB4CzGep/ 2uQAnjALfGczscz/eax4u28i9HjnUAjC =qHHO -----END PGP SIGNATURE----- --sbculjrk2ifboyjx-- --===============1956117517== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============1956117517==--