[PATCH v4 13/14] drm/i915/gvt: Fix error handling in ppgtt_populate_spt_by_guest_entry

Zhenyu Wang zhenyuw at linux.intel.com
Mon May 7 05:55:25 UTC 2018


On 2018.05.07 12:27:12 +0800, Du, Changbin wrote:
> On Mon, May 07, 2018 at 11:38:14AM +0800, Zhenyu Wang wrote:
> > On 2018.05.07 11:29:34 +0800, Du, Changbin wrote:
> > > On Mon, May 07, 2018 at 11:17:31AM +0800, Zhenyu Wang wrote:
> > > > On 2018.05.04 17:50:39 +0800, changbin.du at intel.com wrote:
> > > > > From: Changbin Du <changbin.du at intel.com>
> > > > > 
> > > > > Don't forget to free allocated spt if shadowing failed.
> > > > > 
> > > > > Signed-off-by: Changbin Du <changbin.du at intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/i915/gvt/gtt.c | 31 ++++++++++++++++++++-----------
> > > > >  1 file changed, 20 insertions(+), 11 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
> > > > > index 2bf85be..4af6fee3 100644
> > > > > --- a/drivers/gpu/drm/i915/gvt/gtt.c
> > > > > +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> > > > > @@ -912,10 +912,17 @@ static void ppgtt_get_spt(struct intel_vgpu_ppgtt_spt *spt)
> > > > >  	int v = atomic_read(&spt->refcount);
> > > > >  
> > > > >  	trace_spt_refcount(spt->vgpu->id, "inc", spt, v, (v + 1));
> > > > > -
> > > > >  	atomic_inc(&spt->refcount);
> > > > >  }
> > > > >  
> > > > > +static int ppgtt_put_spt(struct intel_vgpu_ppgtt_spt *spt)
> > > > > +{
> > > > > +	int v = atomic_read(&spt->refcount);
> > > > > +
> > > > > +	trace_spt_refcount(spt->vgpu->id, "dec", spt, v, (v - 1));
> > > > > +	return atomic_dec_return(&spt->refcount);
> > > > > +}
> > > > 
> > > > Use atomic_fetch_dec()
> > > >
> > > Then it will be wrong. The caller expects the value after dec op.
> > >
> > 
> > I mean use fetch value for the trace and return dec value, better inline this as well.
> >
> But what's the benefit? You still need to read it again. I prefer to align it to
> existing ppgtt_get_spt. Will mark these two inline.
> 

To do dec and fetch old value in one call, ppgtt_get_spt can use atomic_fetch_inc()
instead too.

-- 
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/20180507/f807a91a/attachment.sig>


More information about the intel-gvt-dev mailing list