All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection
Date: Wed, 1 May 2013 18:40:22 -0700	[thread overview]
Message-ID: <20130502014021.GA1229@bwidawsk.net> (raw)
In-Reply-To: <20130502012628.GA9668@bwidawsk.net>

On Wed, May 01, 2013 at 06:26:28PM -0700, Ben Widawsky wrote:
> On Wed, May 01, 2013 at 04:09:22PM -0700, Jesse Barnes wrote:
> > We need to catch the invalid case and override it.
> > 
> > Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> > ---
> >  drivers/gpu/drm/i915/intel_pm.c |   16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> > index 0f4b46e..0a3b0b3 100644
> > --- a/drivers/gpu/drm/i915/intel_pm.c
> > +++ b/drivers/gpu/drm/i915/intel_pm.c
> > @@ -2902,7 +2902,21 @@ static void valleyview_enable_rps(struct drm_device *dev)
> >  		   GEN7_RC_CTL_TO_MODE);
> >  
> >  	valleyview_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS, &val);
> > -	dev_priv->mem_freq = 800 + (266 * (val >> 6) & 3);
> > +	switch ((val >> 6) & 3) {
> > +	case 0:
> > +		dev_priv->mem_freq = 800;
> > +		break;
> > +	case 1:
> > +		dev_priv->mem_freq = 1066;
> > +		break;
> > +	case 2:
> > +		dev_priv->mem_freq = 1333;
> > +		break;
> > +	case 3:
> > +		DRM_ERROR("invalid mem freq, assuming 800MHz\n");
> > +		dev_priv->mem_freq = 800;
> > +		break;
> > +	}
> >  	DRM_DEBUG_DRIVER("DDR speed: %d MHz", dev_priv->mem_freq);
> >  
> >  	DRM_DEBUG_DRIVER("GPLL enabled? %s\n", val & 0x10 ? "yes" : "no");
> 
> 
> I guess it doesn't handle the last case, but:
> dev_priv->mem_freq = 800 + (266 * (val))) + val/2
> 

conveniently, I've given you the reason not to use this one... error
prone. It's missing a:
val = (val >> 6) & 3
before the math.

> or
> 
> u32 freqs[] = {800,1066,1333,800};
> dev_priv->mem_freq = freqs[(val >> 6) & 3];
> 
> Are two ways I would have used before making a switch block :P
> 
> Just a thought, but perhaps we don't want to enable RPS if we can't
> reliably figure out the memory freq. (case 3)
> 
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
> 
> -- 
> Ben Widawsky, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ben Widawsky, Intel Open Source Technology Center

  parent reply	other threads:[~2013-05-02  1:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 23:09 [PATCH 1/3] drm/i915: don't use stolen space on VLV Jesse Barnes
2013-05-01 23:09 ` [PATCH 2/3] drm/i915: read current freq from Punit " Jesse Barnes
2013-05-02  3:14   ` Kenneth Graunke
2013-05-01 23:09 ` [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection Jesse Barnes
2013-05-02  1:26   ` Ben Widawsky
2013-05-02  1:38     ` Kenneth Graunke
2013-05-02  1:45       ` Ben Widawsky
2013-05-02  3:16         ` Kenneth Graunke
2013-05-02  1:40     ` Ben Widawsky [this message]
2013-05-02  1:00 ` [PATCH 1/3] drm/i915: don't use stolen space on VLV Ben Widawsky
  -- strict thread matches above, loose matches on Subject: below --
2013-05-02  2:15 [PATCH 3/3] drm/i915: go back to switch for VLV mem freq detection Jesse Barnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130502014021.GA1229@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jbarnes@virtuousgeek.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.