[Intel-gfx] [PATCH 03/28] drm/i915: Keep ggtt->probe() as a local

Chris Wilson chris at chris-wilson.co.uk
Wed Aug 3 14:07:24 UTC 2016


On Wed, Aug 03, 2016 at 05:00:01PM +0300, Joonas Lahtinen wrote:
> On ke, 2016-08-03 at 14:42 +0100, Chris Wilson wrote:
> > The ggtt->probe() vfunc is only called once during GGTT initialisation.
> > We can keep it in a local for the function, sparing a few bytes in our
> > i915_ggtt persistent struct.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/i915_gem_gtt.c | 15 ++++++++-------
> >  drivers/gpu/drm/i915/i915_gem_gtt.h |  2 --
> >  2 files changed, 8 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > index 3fc77776d89b..70178a77d0c8 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> > @@ -3215,13 +3215,17 @@ int i915_ggtt_probe_hw(struct drm_device *dev)
> >  {
> >  	struct drm_i915_private *dev_priv = to_i915(dev);
> >  	struct i915_ggtt *ggtt = &dev_priv->ggtt;
> > +	int (*probe)(struct i915_ggtt *ggtt);
> >  	int ret;
> >  
> > +	ggtt->base.dev = dev;
> > +	ggtt->base.is_ggtt = true;
> > +
> >  	if (INTEL_INFO(dev)->gen <= 5) {
> > -		ggtt->probe = i915_gmch_probe;
> > +		probe = i915_gmch_probe;
> >  		ggtt->base.cleanup = i915_gmch_remove;
> >  	} else if (INTEL_INFO(dev)->gen < 8) {
> > -		ggtt->probe = gen6_gmch_probe;
> > +		probe = gen6_gmch_probe;
> >  		ggtt->base.cleanup = gen6_gmch_remove;
> >  
> >  		if (HAS_EDRAM(dev))
> > @@ -3235,14 +3239,11 @@ int i915_ggtt_probe_hw(struct drm_device *dev)
> >  		else
> >  			ggtt->base.pte_encode = snb_pte_encode;
> >  	} else {
> > -		ggtt->probe = gen8_gmch_probe;
> > +		probe = gen8_gmch_probe;
> >  		ggtt->base.cleanup = gen6_gmch_remove;
> >  	}
> >  
> 
> I'm pretty sure I already saw a version of this with no function
> pointer at all? I preferred that version.

Yes, I do have a patch to change this around to avoid the vfunc, I was
just doing a little drive-by whilst in the vicinity. It's a bigger
patch though - but it's already rebased on top of this, so I'll send it
along.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list