All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: Paulo Zanoni <przanoni@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH 6/7] drm/i915: add functions to disable and restore LCPLL
Date: Thu, 18 Jul 2013 16:33:53 -0700	[thread overview]
Message-ID: <20130718233353.GF4418@bwidawsk.net> (raw)
In-Reply-To: <20130718232641.GC4418@bwidawsk.net>

On Thu, Jul 18, 2013 at 04:26:42PM -0700, Ben Widawsky wrote:
> On Fri, Jul 12, 2013 at 02:19:41PM -0300, Paulo Zanoni wrote:
> > From: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > 
> > For now there are no callers, but these functions are going to be
> > needed for the code that allows Package C8+. Other future features may
> > also require this code.
> > 
> 
> The thing that's missing from the patches is any sort of assertions
> about things being on before the disable sequence. Is this something we
> don't need to address?
> 
> > Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_reg.h      |  7 +++
> >  drivers/gpu/drm/i915/intel_display.c | 95 ++++++++++++++++++++++++++++++++++++
> >  drivers/gpu/drm/i915/intel_drv.h     |  3 ++
> >  3 files changed, 105 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index be6164f..8e5a5ec 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -4930,7 +4930,14 @@
> >  #define  LCPLL_CLK_FREQ_450		(0<<26)
> >  #define  LCPLL_CD_CLOCK_DISABLE		(1<<25)
> >  #define  LCPLL_CD2X_CLOCK_DISABLE	(1<<23)
> > +#define  LCPLL_POWER_DOWN_ALLOW		(1<<22)
> >  #define  LCPLL_CD_SOURCE_FCLK		(1<<21)
> > +#define  LCPLL_CD_SOURCE_FCLK_DONE	(1<<19)
> 
> Hmm... the doc I am looking at says

Oops. The doc I was looking at had some different names for things, was
what I wanted to say.

> 
> > +
> > +#define D_COMP				(MCHBAR_MIRROR_BASE_SNB + 0x5F0C)
> > +#define  D_COMP_RCOMP_IN_PROGRESS	(1<<9)
> > +#define  D_COMP_COMP_FORCE		(1<<8)
> > +#define  D_COMP_COMP_DISABLE		(1<<0)
> >  
> >  /* Pipe WM_LINETIME - watermark line time */
> >  #define PIPE_WM_LINETIME_A		0x45270
> > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> > index 059c9a8..ffb08bf 100644
> > --- a/drivers/gpu/drm/i915/intel_display.c
> > +++ b/drivers/gpu/drm/i915/intel_display.c
> > @@ -5922,6 +5922,101 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
> >  	return true;
> >  }
> >  
> > +/*
> > + * This function implements pieces of two sequences from BSpec:
> > + * - Sequence for display software to disable LCPLL
> > + * - Sequence for display software to allow package C8+
> > + * The steps implemented here are just the steps that actually touch the LCPLL
> > + * register. Callers should take care of disabling all the display engine
> > + * functions, doing the mode unset, fixing interrupts, etc.
> > + */
> > +void hsw_disable_lcpll(struct drm_i915_private *dev_priv,
> > +		       bool switch_to_fclk, bool allow_power_down)
> > +{
> > +	uint32_t val;
> > +
> > +	val = I915_READ(LCPLL_CTL);
> > +
> > +	if (switch_to_fclk) {
> > +		val |= LCPLL_CD_SOURCE_FCLK;
> > +		I915_WRITE(LCPLL_CTL, val);
> > +		POSTING_READ(LCPLL_CTL);
> > +
> > +		udelay(1);
> > +
> > +		val = I915_READ(LCPLL_CTL);
> > +		if (!(val & LCPLL_CD_SOURCE_FCLK_DONE))
> > +			DRM_ERROR("Switching to FCLK failed\n");
> 
> wait_for_us(..., 1)?
> 
> > +	}
> > +
> > +	val |= LCPLL_PLL_DISABLE;
> > +	I915_WRITE(LCPLL_CTL, val);
> > +	POSTING_READ(LCPLL_CTL);
> > +
> > +	if (wait_for((I915_READ(LCPLL_CTL) & LCPLL_PLL_LOCK) == 0, 1))
> > +		DRM_ERROR("LCPLL still locked\n");
> > +
> > +	val = I915_READ(D_COMP);
> > +	val |= D_COMP_COMP_DISABLE;
> > +	I915_WRITE(D_COMP, val);
> > +	POSTING_READ(D_COMP);
> > +
> > +	udelay(2);
> 
> ndelay(100)?
> 
> > +
> > +	val = I915_READ(D_COMP);
> > +	if (val & D_COMP_RCOMP_IN_PROGRESS)
> > +		DRM_ERROR("D_COMP RCOMP still in progress\n");
> 
> wait_for(..., 1)?
> 
> > +
> > +	if (allow_power_down) {
> > +		val = I915_READ(LCPLL_CTL);
> > +		val |= LCPLL_POWER_DOWN_ALLOW;
> > +		I915_WRITE(LCPLL_CTL, val);
> > +		POSTING_READ(LCPLL_CTL);
> > +	}
> > +}
> > +
> > +/*
> > + * Fully restores LCPLL, disallowing power down and switching back to LCPLL
> > + * source.
> > + */
> > +void hsw_restore_lcpll(struct drm_i915_private *dev_priv)
> > +{
> > +	uint32_t val;
> > +
> > +	val = I915_READ(LCPLL_CTL);
> > +
> 
> I think we could potentially exit early here if the PLL is already
> locked, and we're on CDclk. And indeed, I've already seen this case
> occur, but I'm not sure I will ever see that case again.
> 
> > +	if (val & LCPLL_POWER_DOWN_ALLOW) {
> > +		val &= ~LCPLL_POWER_DOWN_ALLOW;
> > +		I915_WRITE(LCPLL_CTL, val);
> > +	}
> > +
> > +	val = I915_READ(D_COMP);
> > +	val |= D_COMP_COMP_FORCE;
> > +	val &= ~D_COMP_COMP_DISABLE;
> > +	I915_WRITE(D_COMP, val);
> > +
> 
> I think you need a posting read here. I am not sure we're allowed to
> read LCPLL_CTL until we know the write has landed.
> 
> 
> > +	val = I915_READ(LCPLL_CTL);
> > +	val &= ~LCPLL_PLL_DISABLE;
> > +	I915_WRITE(LCPLL_CTL, val);
> > +	POSTING_READ(LCPLL_CTL);
>         ^ unnecessary POSTING_READ - but meh
> > +
> > +	if (wait_for(I915_READ(LCPLL_CTL) & LCPLL_PLL_LOCK, 5))
> > +		DRM_ERROR("LCPLL not locked yet\n");
> > +
> > +	if (val & LCPLL_CD_SOURCE_FCLK) {
> > +		val = I915_READ(LCPLL_CTL);
> > +		val &= ~LCPLL_CD_SOURCE_FCLK;
> > +		I915_WRITE(LCPLL_CTL, val);
> > +		POSTING_READ(LCPLL_CTL);
> > +
> > +		udelay(1);
> > +
> > +		val = I915_READ(LCPLL_CTL);
> > +		if (val & LCPLL_CD_SOURCE_FCLK_DONE)
> > +			DRM_ERROR("Switching back to LCPLL failed\n");
> > +	}
> > +}
> > +
> >  static void haswell_modeset_global_resources(struct drm_device *dev)
> >  {
> >  	bool enable = false;
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 5dfc1a0..15989d1 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -832,5 +832,8 @@ extern bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
> >  extern bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
> >  						 enum transcoder pch_transcoder,
> >  						 bool enable);
> > +extern void hsw_disable_lcpll(struct drm_i915_private *dev_priv,
> > +			      bool switch_to_fclk, bool allow_power_down);
> > +extern void hsw_restore_lcpll(struct drm_i915_private *dev_priv);
> >  
> >  #endif /* __INTEL_DRV_H__ */
> 
> I'm a bit torn as to whether or not it makes sense to extract the pure
> LCPLL disable from hsw_disable_lcpll. Did you think about this, could
> you explain the reason you decided against it? (I'm a bit partial since
> that was the way I had written it).
> 
> Does it every make sense to switch to fclk and not allow_power_down?
> 
> -- 
> 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

  reply	other threads:[~2013-07-18 23:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12 17:19 [PATCH 0/7] HSW/LPT clocking code additional sequences Paulo Zanoni
2013-07-12 17:19 ` [PATCH 1/7] drm/i915: remove SDV support from lpt_pch_init_refclk Paulo Zanoni
2013-07-13  5:11   ` Ben Widawsky
2013-07-12 17:19 ` [PATCH 2/7] drm/i915: extract FDI mPHY functions from lpt_init_pch_refclk Paulo Zanoni
2013-07-18 21:51   ` Paulo Zanoni
2013-07-12 17:19 ` [PATCH 3/7] drm/i915: extract lpt_enable_clkout_dp " Paulo Zanoni
2013-07-19  6:54   ` Daniel Vetter
2013-07-12 17:19 ` [PATCH 4/7] drm/i915: extend lpt_enable_clkout_dp Paulo Zanoni
2013-07-18 22:40   ` Ben Widawsky
2013-07-19 15:04     ` Paulo Zanoni
2013-07-19 21:53       ` [PATCH 1/5] " Paulo Zanoni
2013-07-12 17:19 ` [PATCH 5/7] drm/i915: disable CLKOUT_DP when it's not needed Paulo Zanoni
2013-07-12 18:23   ` Daniel Vetter
2013-07-12 18:24     ` Paulo Zanoni
2013-07-18 22:54   ` Ben Widawsky
2013-07-19 21:54     ` [PATCH 2/5] " Paulo Zanoni
2013-07-12 17:19 ` [PATCH 6/7] drm/i915: add functions to disable and restore LCPLL Paulo Zanoni
2013-07-18 21:53   ` Paulo Zanoni
2013-07-18 23:26   ` Ben Widawsky
2013-07-18 23:33     ` Ben Widawsky [this message]
2013-07-19 16:57       ` Paulo Zanoni
2013-07-19 18:22     ` Paulo Zanoni
2013-07-19 21:56       ` [PATCH 3/5] " Paulo Zanoni
2013-07-19 21:58         ` [PATCH 5/5] drm/i915: add HAS_LP_PCH check Paulo Zanoni
2013-07-22 17:10           ` Ben Widawsky
2013-07-22 22:44             ` Paulo Zanoni
2013-07-12 17:19 ` [PATCH 7/7] drm/i915: add some assertions to hsw_disable_lcpll Paulo Zanoni
2013-07-18 23:32   ` Ben Widawsky
2013-07-19 18:42     ` Paulo Zanoni
2013-07-18 23:33 ` [PATCH 0/7] HSW/LPT clocking code additional sequences Ben Widawsky

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=20130718233353.GF4418@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    --cc=przanoni@gmail.com \
    /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.