From: Zhenyu Wang Subject: Re: [PATCH 07/12] drm/i915/gvt: Hold a reference on the request Date: Thu, 20 Oct 2016 15:33:34 +0800 Message-ID: <20161020073334.wc4pfjflh33k33pw@zhen-hp.sh.intel.com> References: <20161019101147.17342-1-chris@chris-wilson.co.uk> <20161019101147.17342-8-chris@chris-wilson.co.uk> <20161020002200.656623zjtjyddw44@zhen-hp.sh.intel.com> <20161020065218.GE19173@nuc-i3427.alporthouse.com> Reply-To: Zhenyu Wang Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0730098935==" Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 315956EA8C for ; Thu, 20 Oct 2016 07:37:55 +0000 (UTC) In-Reply-To: <20161020065218.GE19173@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0730098935== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4tgvagmuns2k2sgq" Content-Disposition: inline --4tgvagmuns2k2sgq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2016.10.20 07:52:18 +0100, Chris Wilson wrote: > On Thu, Oct 20, 2016 at 08:22:00AM +0800, Zhenyu Wang wrote: > > On 2016.10.19 11:11:42 +0100, Chris Wilson wrote: > > > The workload took a pointer to the request, and even waited upon, > > > without holding a reference on the request. Take that reference > > > explicitly and fix up the error path following request allocation that > > > missed flushing the request. > > >=20 > > > Signed-off-by: Chris Wilson > > > --- > > > drivers/gpu/drm/i915/gvt/scheduler.c | 24 +++++++++++++----------- > > > 1 file changed, 13 insertions(+), 11 deletions(-) > > >=20 > > > diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i= 915/gvt/scheduler.c > > > index b15cdf5978a9..224f19ae61ab 100644 > > > --- a/drivers/gpu/drm/i915/gvt/scheduler.c > > > +++ b/drivers/gpu/drm/i915/gvt/scheduler.c > > > @@ -163,6 +163,7 @@ static int dispatch_workload(struct intel_vgpu_wo= rkload *workload) > > > int ring_id =3D workload->ring_id; > > > struct i915_gem_context *shadow_ctx =3D workload->vgpu->shadow_ctx; > > > struct drm_i915_private *dev_priv =3D workload->vgpu->gvt->dev_priv; > > > + struct drm_i915_gem_request *rq; > > > int ret; > > > =20 > > > gvt_dbg_sched("ring id %d prepare to dispatch workload %p\n", > > > @@ -171,17 +172,16 @@ static int dispatch_workload(struct intel_vgpu_= workload *workload) > > > shadow_ctx->desc_template =3D workload->ctx_desc.addressing_mode << > > > GEN8_CTX_ADDRESSING_MODE_SHIFT; > > > =20 > > > - workload->req =3D i915_gem_request_alloc(dev_priv->engine[ring_id], > > > - shadow_ctx); > > > - if (IS_ERR_OR_NULL(workload->req)) { > > > + rq =3D i915_gem_request_alloc(dev_priv->engine[ring_id], shadow_ctx= ); > > > + if (IS_ERR(rq)) { > > > gvt_err("fail to allocate gem request\n"); > > > - workload->status =3D PTR_ERR(workload->req); > > > - workload->req =3D NULL; > > > + workload->status =3D PTR_ERR(rq); > > > return workload->status; > > > } > > > =20 > > > - gvt_dbg_sched("ring id %d get i915 gem request %p\n", > > > - ring_id, workload->req); > > > + gvt_dbg_sched("ring id %d get i915 gem request %p\n", ring_id, rq); > > > + > > > + workload->req =3D i915_gem_request_get(rq); > > > =20 > > > mutex_lock(&gvt->lock); > > > =20 > > > @@ -208,16 +208,16 @@ static int dispatch_workload(struct intel_vgpu_= workload *workload) > > > gvt_dbg_sched("ring id %d submit workload to i915 %p\n", > > > ring_id, workload->req); > > > =20 > > > - i915_add_request_no_flush(workload->req); > > > - > > > + i915_add_request_no_flush(rq); > > > workload->dispatched =3D true; > > > return 0; > > > err: > > > workload->status =3D ret; > > > - if (workload->req) > > > - workload->req =3D NULL; > > > + i915_gem_request_put(fetch_and_zero(&workload->req)); > > > > >=20 > > Looks we don't need put here as in error path from dispatch_workload() > > we will go with below put path too in main thread. >=20 > If we clear the request pointer, then we need the put. But yes, we don't > necessarily need to clear the pointer on error for the caller, as the > caller doesn't distinguish the error path and the no-op request can be > handled identically to a real request. Would you refresh this one? So I'd send out next pull request with this. thanks --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --4tgvagmuns2k2sgq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEABECAAYFAlgIc0kACgkQsQQaM014GCcFpwCgi9kJA/FEiDSJt4TV33EJMNTl DvoAnjslm4t3HUUs6wviXkRgkjpAzgNb =ICFr -----END PGP SIGNATURE----- --4tgvagmuns2k2sgq-- --===============0730098935== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============0730098935==--