From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915/cnl: use previous pll hw readout
Date: Fri, 22 Mar 2019 15:09:07 +0200 [thread overview]
Message-ID: <20190322130907.GO3888@intel.com> (raw)
In-Reply-To: <20190321220257.32638-3-lucas.demarchi@intel.com>
On Thu, Mar 21, 2019 at 03:02:56PM -0700, Lucas De Marchi wrote:
> By the time cnl_ddi_clock_get() is called we've just got the hw state
> from the pll registers. We don't need to read them again: we can rather
> reuse what was cached in the dpll_hw_state.
>
> This also affects the code for ICL since it partially reuses the CNL
> code. However the more intricate part on ICL is left for another patch.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> drivers/gpu/drm/i915/icl_dsi.c | 5 ++-
> drivers/gpu/drm/i915/intel_ddi.c | 53 +++++++++++++++++---------------
> drivers/gpu/drm/i915/intel_drv.h | 2 +-
> 3 files changed, 31 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/icl_dsi.c b/drivers/gpu/drm/i915/icl_dsi.c
> index beb30d9a855c..c7dcd783d986 100644
> --- a/drivers/gpu/drm/i915/icl_dsi.c
> +++ b/drivers/gpu/drm/i915/icl_dsi.c
> @@ -1179,11 +1179,10 @@ static void gen11_dsi_get_config(struct intel_encoder *encoder,
> {
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
> - u32 pll_id;
>
> /* FIXME: adapt icl_ddi_clock_get() for DSI and use that? */
> - pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
> - pipe_config->port_clock = cnl_calc_wrpll_link(dev_priv, pll_id);
> + pipe_config->port_clock =
> + cnl_calc_wrpll_link(dev_priv, &pipe_config->dpll_hw_state);
> pipe_config->base.adjusted_mode.crtc_clock = intel_dsi->pclk;
> pipe_config->output_types |= BIT(INTEL_OUTPUT_DSI);
> }
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 644541924208..fe52af9fa4aa 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1294,25 +1294,17 @@ static int skl_calc_wrpll_link(struct intel_dpll_hw_state *state)
> return dco_freq / (p0 * p1 * p2 * 5);
> }
>
> +
Stray newline.
> int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
> - enum intel_dpll_id pll_id)
> + struct intel_dpll_hw_state *state)
> {
> - u32 cfgcr0, cfgcr1;
> u32 p0, p1, p2, dco_freq, ref_clock;
>
> - if (INTEL_GEN(dev_priv) >= 11) {
> - cfgcr0 = I915_READ(ICL_DPLL_CFGCR0(pll_id));
> - cfgcr1 = I915_READ(ICL_DPLL_CFGCR1(pll_id));
> - } else {
> - cfgcr0 = I915_READ(CNL_DPLL_CFGCR0(pll_id));
> - cfgcr1 = I915_READ(CNL_DPLL_CFGCR1(pll_id));
> - }
> -
> - p0 = cfgcr1 & DPLL_CFGCR1_PDIV_MASK;
> - p2 = cfgcr1 & DPLL_CFGCR1_KDIV_MASK;
> + p0 = state->cfgcr1 & DPLL_CFGCR1_PDIV_MASK;
> + p2 = state->cfgcr1 & DPLL_CFGCR1_KDIV_MASK;
>
> - if (cfgcr1 & DPLL_CFGCR1_QDIV_MODE(1))
> - p1 = (cfgcr1 & DPLL_CFGCR1_QDIV_RATIO_MASK) >>
> + if (state->cfgcr1 & DPLL_CFGCR1_QDIV_MODE(1))
> + p1 = (state->cfgcr1 & DPLL_CFGCR1_QDIV_RATIO_MASK) >>
> DPLL_CFGCR1_QDIV_RATIO_SHIFT;
> else
> p1 = 1;
> @@ -1347,9 +1339,9 @@ int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
>
> ref_clock = cnl_hdmi_pll_ref_clock(dev_priv);
>
> - dco_freq = (cfgcr0 & DPLL_CFGCR0_DCO_INTEGER_MASK) * ref_clock;
> + dco_freq = (state->cfgcr0 & DPLL_CFGCR0_DCO_INTEGER_MASK) * ref_clock;
>
> - dco_freq += (((cfgcr0 & DPLL_CFGCR0_DCO_FRACTION_MASK) >>
> + dco_freq += (((state->cfgcr0 & DPLL_CFGCR0_DCO_FRACTION_MASK) >>
> DPLL_CFGCR0_DCO_FRACTION_SHIFT) * ref_clock) / 0x8000;
>
> if (WARN_ON(p0 == 0 || p1 == 0 || p2 == 0))
> @@ -1462,13 +1454,21 @@ static void icl_ddi_clock_get(struct intel_encoder *encoder,
> struct intel_crtc_state *pipe_config)
> {
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> + struct intel_dpll_hw_state *state;
> enum port port = encoder->port;
> int link_clock = 0;
> u32 pll_id;
>
> pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
> +
> + /* For DDI ports we always use a shared PLL. */
> + if (WARN_ON(!pipe_config->shared_dpll))
> + goto end;
> +
> + state = &pipe_config->dpll_hw_state;
No point in assigning this late.
> +
> if (intel_port_is_combophy(dev_priv, port)) {
> - link_clock = cnl_calc_wrpll_link(dev_priv, pll_id);
> + link_clock = cnl_calc_wrpll_link(dev_priv, state);
> } else {
> if (pll_id == DPLL_ID_ICL_TBTPLL)
> link_clock = icl_calc_tbt_pll_link(dev_priv, port);
> @@ -1476,7 +1476,9 @@ static void icl_ddi_clock_get(struct intel_encoder *encoder,
> link_clock = icl_calc_mg_pll_link(dev_priv, port);
> }
>
> +end:
> pipe_config->port_clock = link_clock;
> +
> ddi_dotclock_get(pipe_config);
> }
>
> @@ -1484,18 +1486,18 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder,
> struct intel_crtc_state *pipe_config)
> {
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> + struct intel_dpll_hw_state *state;
> int link_clock = 0;
> - u32 cfgcr0;
> - enum intel_dpll_id pll_id;
> -
> - pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
>
> - cfgcr0 = I915_READ(CNL_DPLL_CFGCR0(pll_id));
> + /* For DDI ports we always use a shared PLL. */
> + if (WARN_ON(!pipe_config->shared_dpll))
> + goto end;
>
> - if (cfgcr0 & DPLL_CFGCR0_HDMI_MODE) {
> - link_clock = cnl_calc_wrpll_link(dev_priv, pll_id);
> + state = &pipe_config->dpll_hw_state;
ditto
> + if (state->cfgcr0 & DPLL_CFGCR0_HDMI_MODE) {
> + link_clock = cnl_calc_wrpll_link(dev_priv, state);
> } else {
> - link_clock = cfgcr0 & DPLL_CFGCR0_LINK_RATE_MASK;
> + link_clock = state->cfgcr0 & DPLL_CFGCR0_LINK_RATE_MASK;
>
> switch (link_clock) {
> case DPLL_CFGCR0_LINK_RATE_810:
> @@ -1529,6 +1531,7 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder,
> link_clock *= 2;
> }
>
> +end:
> pipe_config->port_clock = link_clock;
>
> ddi_dotclock_get(pipe_config);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 4d7ae579fc92..65ab0f90ce6a 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1659,7 +1659,7 @@ int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder,
> bool enable);
> void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder);
> int cnl_calc_wrpll_link(struct drm_i915_private *dev_priv,
> - enum intel_dpll_id pll_id);
> + struct intel_dpll_hw_state *state);
>
> unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
> int color_plane, unsigned int height);
> --
> 2.20.1
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-03-22 13:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 22:02 [PATCH 0/3] Do not re-read dpll registers Lucas De Marchi
2019-03-21 22:02 ` [PATCH 1/3] drm/i915/skl: use previous pll hw readout Lucas De Marchi
2019-03-22 13:05 ` Ville Syrjälä
2019-03-21 22:02 ` [PATCH 2/3] drm/i915/cnl: " Lucas De Marchi
2019-03-22 13:09 ` Ville Syrjälä [this message]
2019-03-21 22:02 ` [PATCH 3/3] drm/i915/icl: " Lucas De Marchi
2019-03-22 13:09 ` Ville Syrjälä
2019-03-22 19:50 ` Lucas De Marchi
2019-03-22 20:15 ` Ville Syrjälä
2019-03-22 20:42 ` Lucas De Marchi
2019-03-22 1:37 ` ✗ Fi.CI.CHECKPATCH: warning for Do not re-read dpll registers Patchwork
2019-03-22 2:05 ` ✓ Fi.CI.BAT: success " Patchwork
2019-03-22 9:25 ` [PATCH 0/3] " Jani Nikula
2019-03-22 18:38 ` ✗ Fi.CI.IGT: failure for " Patchwork
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=20190322130907.GO3888@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucas.demarchi@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox