public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Damien Lespiau <damien.lespiau@intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 57/66] drm/i915: State readout and cross-checking for ddi_pll_sel
Date: Tue, 20 May 2014 11:47:35 +0100	[thread overview]
Message-ID: <20140520104735.GF12931@strange.amr.corp.intel.com> (raw)
In-Reply-To: <1398376542-27825-58-git-send-email-daniel.vetter@ffwll.ch>

On Thu, Apr 24, 2014 at 11:55:33PM +0200, Daniel Vetter wrote:
> To make things a bit more manageable extract a new function for
> reading out common ddi port state. This means a bit of duplication
> between encoders and the core since both look at the same registers,
> but doesn't seem worth to make a fuzz about.
> 
> We can also remove the state readout code in intel_ddi_setup_hw_pll_state.
> That code is only called from the hardware take over and not the cross
> check code, and only after the crtc state is reconstructed. So we can
> rely on an accurate value of crtc->config.ddi_pll_sel already.
> 
> Compared to the old code also trust the hw state more and don't
> special-case port A - we want to cross-check the actual-state, not
> bake in our own assumptions about how this is supposed to all be
> linked up.
> 
> v2: Make use of the read-out ddi_pll_sel in intel_ddi_clock_get.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Moving things out of intel_ddi.c to intel_display.c seems to be the
opposite of what we want. I don't see why we couldn't leave the DDI
readout function inside intel_ddi.c?

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>

-- 
Damien

> ---
>  drivers/gpu/drm/i915/i915_reg.h      |  1 +
>  drivers/gpu/drm/i915/intel_ddi.c     | 40 +-----------------------------
>  drivers/gpu/drm/i915/intel_display.c | 48 ++++++++++++++++++++++++------------
>  3 files changed, 34 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 64d40f22e708..4c1cefb5f3eb 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -5366,6 +5366,7 @@ enum punit_power_well {
>  #define  TRANS_DDI_FUNC_ENABLE		(1<<31)
>  /* Those bits are ignored by pipe EDP since it can only connect to DDI A */
>  #define  TRANS_DDI_PORT_MASK		(7<<28)
> +#define  TRANS_DDI_PORT_SHIFT		28
>  #define  TRANS_DDI_SELECT_PORT(x)	((x)<<28)
>  #define  TRANS_DDI_PORT_NONE		(0<<28)
>  #define  TRANS_DDI_MODE_SELECT_MASK	(7<<24)
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 2adcc917806e..571cfe431558 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -481,11 +481,10 @@ static void intel_ddi_clock_get(struct intel_encoder *encoder,
>  				struct intel_crtc_config *pipe_config)
>  {
>  	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
> -	enum port port = intel_ddi_get_encoder_port(encoder);
>  	int link_clock = 0;
>  	u32 val, pll;
>  
> -	val = I915_READ(PORT_CLK_SEL(port));
> +	val = pipe_config->ddi_pll_sel;
>  	switch (val & PORT_CLK_SEL_MASK) {
>  	case PORT_CLK_SEL_LCPLL_810:
>  		link_clock = 81000;
> @@ -987,40 +986,6 @@ static bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
>  	return intel_ddi_get_port_state(encoder, pipe, port);
>  }
>  
> -static uint32_t intel_ddi_get_crtc_pll(struct drm_i915_private *dev_priv,
> -				       enum pipe pipe)
> -{
> -	uint32_t temp, ret;
> -	enum port port = I915_MAX_PORTS;
> -	enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
> -								      pipe);
> -	int i;
> -
> -	if (cpu_transcoder == TRANSCODER_EDP) {
> -		port = PORT_A;
> -	} else {
> -		temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
> -		temp &= TRANS_DDI_PORT_MASK;
> -
> -		for (i = PORT_B; i <= PORT_E; i++)
> -			if (temp == TRANS_DDI_SELECT_PORT(i))
> -				port = i;
> -	}
> -
> -	if (port == I915_MAX_PORTS) {
> -		WARN(1, "Pipe %c enabled on an unknown port\n",
> -		     pipe_name(pipe));
> -		ret = PORT_CLK_SEL_NONE;
> -	} else {
> -		ret = I915_READ(PORT_CLK_SEL(port));
> -		DRM_DEBUG_KMS("Pipe %c connected to port %c using clock "
> -			      "0x%08x\n", pipe_name(pipe), port_name(port),
> -			      ret);
> -	}
> -
> -	return ret;
> -}
> -
>  void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
> @@ -1039,9 +1004,6 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
>  			continue;
>  		}
>  
> -		intel_crtc->config.ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
> -								 pipe);
> -
>  		switch (intel_crtc->config.ddi_pll_sel) {
>  		case PORT_CLK_SEL_WRPLL1:
>  			dev_priv->ddi_plls.wrpll1_refcount++;
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 728b5a25cb80..1601da1b57a1 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -7006,6 +7006,35 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
>  	return 0;
>  }
>  
> +static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
> +				       struct intel_crtc_config *pipe_config)
> +{
> +	struct drm_device *dev = crtc->base.dev;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	enum port port;
> +	uint32_t tmp;
> +
> +	tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe_config->cpu_transcoder));
> +
> +	port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
> +
> +	pipe_config->ddi_pll_sel = I915_READ(PORT_CLK_SEL(port));
> +	/*
> +	 * Haswell has only FDI/PCH transcoder A. It is which is connected to
> +	 * DDI E. So just check whether this pipe is wired to DDI E and whether
> +	 * the PCH transcoder is on.
> +	 */
> +	if ((port == PORT_E) && I915_READ(LPT_TRANSCONF) & TRANS_ENABLE) {
> +		pipe_config->has_pch_encoder = true;
> +
> +		tmp = I915_READ(FDI_RX_CTL(PIPE_A));
> +		pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >>
> +					  FDI_DP_PORT_WIDTH_SHIFT) + 1;
> +
> +		ironlake_get_fdi_m_n_config(crtc, pipe_config);
> +	}
> +}
> +
>  static bool haswell_get_pipe_config(struct intel_crtc *crtc,
>  				    struct intel_crtc_config *pipe_config)
>  {
> @@ -7051,22 +7080,7 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
>  	if (!(tmp & PIPECONF_ENABLE))
>  		return false;
>  
> -	/*
> -	 * Haswell has only FDI/PCH transcoder A. It is which is connected to
> -	 * DDI E. So just check whether this pipe is wired to DDI E and whether
> -	 * the PCH transcoder is on.
> -	 */
> -	tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe_config->cpu_transcoder));
> -	if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(PORT_E) &&
> -	    I915_READ(LPT_TRANSCONF) & TRANS_ENABLE) {
> -		pipe_config->has_pch_encoder = true;
> -
> -		tmp = I915_READ(FDI_RX_CTL(PIPE_A));
> -		pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >>
> -					  FDI_DP_PORT_WIDTH_SHIFT) + 1;
> -
> -		ironlake_get_fdi_m_n_config(crtc, pipe_config);
> -	}
> +	haswell_get_ddi_port_state(crtc, pipe_config);
>  
>  	intel_get_pipe_timings(crtc, pipe_config);
>  
> @@ -9521,6 +9535,8 @@ intel_pipe_config_compare(struct drm_device *dev,
>  
>  	PIPE_CONF_CHECK_I(double_wide);
>  
> +	PIPE_CONF_CHECK_X(ddi_pll_sel);
> +
>  	PIPE_CONF_CHECK_I(shared_dpll);
>  	PIPE_CONF_CHECK_X(dpll_hw_state.dpll);
>  	PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md);
> -- 
> 1.8.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2014-05-20 10:47 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 21:54 [PATCH 00/66] runtime pm for DPMS Daniel Vetter
2014-04-24 21:54 ` [PATCH 01/66] drm/i915: Make encoder->mode_set callbacks optional Daniel Vetter
2014-04-24 21:54 ` [PATCH 02/66] drm/i915/dvo: Remove ->mode_set callback Daniel Vetter
2014-04-24 21:54 ` [PATCH 03/66] drm/i915/tv: extract set_tv_mode_timings Daniel Vetter
2014-04-24 21:54 ` [PATCH 04/66] drm/i915/tv: extract set_color_conversion Daniel Vetter
2014-04-24 21:54 ` [PATCH 05/66] drm/i915/tv: De-magic device check Daniel Vetter
2014-04-24 21:54 ` [PATCH 06/66] drm/i915/tv: Rip out pipe-disabling nonsense from ->mode_set Daniel Vetter
2014-04-24 21:54 ` [PATCH 07/66] drm/i915/tv: Remove ->mode_set callback Daniel Vetter
2014-04-24 21:54 ` [PATCH 08/66] drm/i915/crt: " Daniel Vetter
2014-04-24 21:54 ` [PATCH 09/66] drm/i915/sdvo: " Daniel Vetter
2014-04-24 21:54 ` [PATCH 10/66] drm/i915/hdmi: Enable hdmi mode on g4x, too Daniel Vetter
2014-04-24 21:54 ` [PATCH 11/66] drm/i915: Track hdmi mode in the pipe config Daniel Vetter
2014-04-24 21:54 ` [PATCH 12/66] drm/i915/sdvo: Use pipe_config->limited_color_range consistently Daniel Vetter
2014-04-24 21:54 ` [PATCH 13/66] drm/i915: state readout and cross checking for limited_color_range Daniel Vetter
2014-04-24 21:54 ` [PATCH 14/66] drm/i915/sdvo: use config->has_hdmi_sink Daniel Vetter
2014-04-24 21:54 ` [PATCH 15/66] drm/i915: Simplify audio handling on DDI ports Daniel Vetter
2014-04-24 21:54 ` [PATCH 16/66] drm/i915: Track has_audio in the pipe config Daniel Vetter
2014-04-24 21:54 ` [PATCH 17/66] drm/i915/dp: Move port A pll setup to g4x_pre_enable_dp Daniel Vetter
2014-04-24 21:54 ` [PATCH 18/66] drm/i915/dp: Remove ->mode_set callback Daniel Vetter
2014-04-24 21:54 ` [PATCH 19/66] drm/i915/hdmi: Remove redundant IS_VLV checks Daniel Vetter
2014-04-24 21:54 ` [PATCH 20/66] drm/i915/hdmi: Remove ->mode_set callback Daniel Vetter
2014-04-24 21:54 ` [PATCH 21/66] drm/i915/lvds: " Daniel Vetter
2014-04-24 21:54 ` [PATCH 22/66] drm/i915/ddi: " Daniel Vetter
2014-04-24 21:54 ` [PATCH 23/66] drm/i915/dsi: " Daniel Vetter
2014-05-20 11:59   ` Kumar, Shobhit
2014-05-20 12:07     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 24/66] drm/i915: Stop calling encoder->mode_set Daniel Vetter
2014-05-16 10:04   ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 25/66] drm/i915: Make ->update_primary_plane infallible Daniel Vetter
2014-04-24 21:55 ` [PATCH 26/66] drm/i915: More cargo-culted locking for intel_update_fbc Daniel Vetter
2014-04-24 21:55 ` [PATCH 27/66] drm/i915: Sprinkle intel_edp_psr_update over crtc_enable/disable Daniel Vetter
2014-04-24 21:55 ` [PATCH 28/66] drm/i915: Inline set_base into crtc_mode_set Daniel Vetter
2014-04-24 21:55 ` [PATCH 29/66] drm/i915: Move fb pinning into __intel_set_mode Daniel Vetter
2014-04-24 21:55 ` [PATCH 30/66] drm/i915: Shovel hw setup code out of i9xx_crtc_mode_set Daniel Vetter
2014-04-24 21:55 ` [PATCH 31/66] drm/i915: Move lowfreq_avail around a bit in ilk/hsw_crtc_mode_set Daniel Vetter
2014-04-24 21:55 ` [PATCH 32/66] drm/i915: Shovel hw setup code out of ilk_crtc_mode_set Daniel Vetter
2014-04-24 21:55 ` [PATCH 33/66] drm/i915: Shovel hw setup code out of hsw_crtc_mode_set Daniel Vetter
2014-04-24 21:55 ` [PATCH 34/66] drm/i915: Extract i9xx_set_pll_dividers Daniel Vetter
2014-04-24 21:55 ` [PATCH 35/66] drm/i915: Extract vlv_prepare_pll Daniel Vetter
2014-04-24 21:55 ` [PATCH 36/66] drm/i915: Only update shared dpll state when needed Daniel Vetter
2014-05-20 10:18   ` Damien Lespiau
2014-05-20 11:17     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 37/66] drm/i915: Extract intel_prepare_shared_dpll Daniel Vetter
2014-05-20 10:28   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 38/66] drm/i915: s/ironlake_/intel_ for the enable_share_dpll function Daniel Vetter
2014-05-20 10:29   ` Damien Lespiau
2014-05-20 13:16     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 39/66] drm/i915: Check hw state in assert_can_disable_lcpll Daniel Vetter
2014-05-22 18:10   ` Paulo Zanoni
2014-05-22 19:26     ` Daniel Vetter
2014-05-22 20:10       ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 40/66] drm/i915: Remove spll_refcount for hsw Daniel Vetter
2014-05-22 18:41   ` Paulo Zanoni
2014-05-22 19:41     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 41/66] drm/i915: Clean up WRPLL/SPLL #defines Daniel Vetter
2014-05-22 18:29   ` Paulo Zanoni
2014-04-24 21:55 ` [PATCH 42/66] drm/i915: Make intel_wait_for_pipe_off static Daniel Vetter
2014-05-22 18:36   ` Paulo Zanoni
2014-04-24 21:55 ` [PATCH 43/66] drm/i915: Disable pipe before ports on ilk Daniel Vetter
2014-05-22 19:25   ` Paulo Zanoni
2014-05-22 20:26     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 44/66] drm/i915: Pass port explicitly to intel_ddi_get_hw_state Daniel Vetter
2014-05-22 19:38   ` Paulo Zanoni
2014-05-22 20:30     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 45/66] drm/i915: Unexport intel_ddi_connector_get_hw_state Daniel Vetter
2014-05-22 20:13   ` Paulo Zanoni
2014-05-22 20:49   ` [PATCH] " Daniel Vetter
2014-04-24 21:55 ` [PATCH 46/66] drm/i915: Move hsw_fdi_link_train into intel_crt.c Daniel Vetter
2014-05-22 20:28   ` Paulo Zanoni
2014-05-22 21:57     ` Daniel Vetter
2014-05-27 17:31       ` Jesse Barnes
2014-05-27 18:00         ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 47/66] drm/i915: Move pch fifo underrun report enabling to hsw_crt_pre_enable Daniel Vetter
2014-05-22 20:38   ` Paulo Zanoni
2014-05-22 22:03     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 48/66] drm/i915: Move the SPLL enabling into hsw_crt_pre_enable Daniel Vetter
2014-04-24 21:55 ` [PATCH 49/66] drm/i915: Move lpt_pch_enable int hsw_crt_enable Daniel Vetter
2014-04-24 21:55 ` [PATCH 50/66] drm/i915: Move the pch fifo underrun handling into hsw_crt_disable Daniel Vetter
2014-04-24 21:55 ` [PATCH 51/66] drm/i915: Move lpt_disable_pch_transcoder into the hsw crt encoder Daniel Vetter
2014-04-24 21:55 ` [PATCH 52/66] drm/i915: Move pch fifo underrun report re-enabling into hsw_crt_post_disable Daniel Vetter
2014-04-24 21:55 ` [PATCH 53/66] drm/i915: Move the hsw fdi disabling " Daniel Vetter
2014-04-24 21:55 ` [PATCH 54/66] drm/i915: Move SPLL " Daniel Vetter
2014-04-24 21:55 ` [PATCH 55/66] drm/i915: Add a debugfs file for the shared dpll state Daniel Vetter
2014-05-20 10:33   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 56/66] drm/i915: Move ddi_pll_sel into the pipe config Daniel Vetter
2014-05-20 10:36   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 57/66] drm/i915: State readout and cross-checking for ddi_pll_sel Daniel Vetter
2014-05-20 10:47   ` Damien Lespiau [this message]
2014-05-20 11:24     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 58/66] drm/i915: Precompute static ddi_pll_sel values in encoders Daniel Vetter
2014-05-20 10:56   ` Damien Lespiau
2014-05-20 11:27     ` Daniel Vetter
2014-04-24 21:55 ` [PATCH 59/66] drm/i915: Basic shared dpll support for WRPLLs Daniel Vetter
2014-05-20 11:06   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 60/66] drm/i915: Document that the pll->mode_set hook is optional Daniel Vetter
2014-05-20 11:08   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 61/66] drm/i915: State readout support for WRPLLs Daniel Vetter
2014-05-20 11:16   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 62/66] drm/i915: ->disable hook " Daniel Vetter
2014-05-20 11:20   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 63/66] drm/i915: ->enable " Daniel Vetter
2014-05-20 11:29   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 64/66] drm/i915: Switch to common shared dpll framework " Daniel Vetter
2014-05-20 11:38   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 65/66] drm/i915: Only touch WRPLL hw state in enable/disable hooks Daniel Vetter
2014-05-20 11:39   ` Damien Lespiau
2014-04-24 21:55 ` [PATCH 66/66] drm/i915: runtime PM support for DPMS Daniel Vetter
2014-05-16 21:48   ` Jesse Barnes
2014-05-16 22:19     ` Daniel Vetter
2014-05-16 22:23       ` Jesse Barnes
2014-05-23 14:00   ` Paulo Zanoni
2014-06-02 16:09   ` Daniel Vetter
2014-04-25  8:45 ` [PATCH 00/66] runtime pm " Daniel Vetter
2014-04-30 15:36   ` Shobhit Kumar
2014-04-30 17:29     ` Daniel Vetter
2014-04-30 16:38   ` Imre Deak
2014-04-30 17:30     ` Daniel Vetter
2014-05-16  8:39     ` Naresh Kumar Kachhi
2014-05-17  4:37       ` Akash Goel
2014-05-07 13:49   ` Imre Deak
2014-05-20 11:52   ` Kumar, Shobhit

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=20140520104735.GF12931@strange.amr.corp.intel.com \
    --to=damien.lespiau@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox