[PATCH v4 13/14] drm/i915/gvt: Fix error handling in ppgtt_populate_spt_by_guest_entry
Du, Changbin
changbin.du at intel.com
Mon May 7 04:27:12 UTC 2018
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.
--
Thanks,
Changbin Du
More information about the intel-gvt-dev
mailing list