Re: [PATCH 8/9] drm/i915/gtt: Make swapping the pd entry generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Chris Wilson (2019-06-11 20:50:09)
> Quoting Mika Kuoppala (2019-06-11 18:27:30)
> > Swapping a pd entry is same across the page directories, if
> > we succeed we need to increment the count and write the phys page
> > entry. Make a common function for it.
> > 
> > Signed-off-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxxxxxxxx>
> > ---
> >  drivers/gpu/drm/i915/i915_gem_gtt.c | 41 +++++++++++++++++++----------
> >  1 file changed, 27 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > index f1d7874834e2..9b0d0a077e31 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > @@ -752,6 +752,27 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
> >                        gen8_pde_encode(px_dma(to), I915_CACHE_LLC));    \
> >  })
> >  
> > +static void *__swap_pd_entry(struct i915_page_directory * const pd,
> > +                            const unsigned short pde,
> > +                            void * const old_val,
> > +                            void * const new_val,
> > +                            const u64 encoded_entry)
> 
> Mark this as inline and pass in the encode function, the compiler should
> do the rest.
> 
> > +{
> > +       void * const old = cmpxchg(&pd->entry[pde], old_val, new_val);
> > +
> > +       if (likely(old == old_val)) {
> > +               atomic_inc(&pd->used);
> 
> Hmm, looking at this again, this would be safer if atomic_inc was before
> the cmpxchg, with an atomic_dec on the fail path.

Actually already taken care of, the parent pins the child page directory
before entering.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux