public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Don't try to use negative pll_id.
Date: Wed, 1 Nov 2017 20:56:55 +0200	[thread overview]
Message-ID: <20171101185655.GH10981@intel.com> (raw)
In-Reply-To: <20171101184458.31698-1-rodrigo.vivi@intel.com>

On Wed, Nov 01, 2017 at 11:44:58AM -0700, Rodrigo Vivi wrote:
> It is unlikely we are getting the -1 here.
> But if we propagate that pll_id -1 to the rest of the code
> we might have funny calculations on link_clock and who
> knows what registers we end up accessing.
> 
> Better to protect the code.
> 
> Also better with errno number instead of generic -1.
> 
> Cc: Manasi Navare <manasi.d.navare@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ddi.c      | 10 ++++++++++
>  drivers/gpu/drm/i915/intel_dpll_mgr.c |  2 +-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index ace674cd79b9..2c6abdbf33ea 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1283,6 +1283,11 @@ static void cnl_ddi_clock_get(struct intel_encoder *encoder,
>  
>  	pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
>  
> +	if (pll_id < 0) {
> +		DRM_ERROR("PLL not found\n");
> +		return;
> +	}
> +
>  	cfgcr0 = I915_READ(CNL_DPLL_CFGCR0(pll_id));

Don't we have the dpll state already read out?

crtc_state->dll_hw_state.cfgcr0 etc.?

>  
>  	if (cfgcr0 & DPLL_CFGCR0_HDMI_MODE) {
> @@ -1337,6 +1342,11 @@ static void skl_ddi_clock_get(struct intel_encoder *encoder,
>  
>  	pll_id = intel_get_shared_dpll_id(dev_priv, pipe_config->shared_dpll);
>  
> +	if (pll_id < 0) {
> +		DRM_ERROR("PLL not found\n");
> +		return;
> +	}
> +
>  	dpll_ctl1 = I915_READ(DPLL_CTRL1);
>  
>  	if (dpll_ctl1 & DPLL_CTRL1_HDMI_MODE(pll_id)) {
> diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> index a83bf1c38e05..c4a7f39e173a 100644
> --- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
> +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> @@ -102,7 +102,7 @@ intel_get_shared_dpll_id(struct drm_i915_private *dev_priv,
>  {
>  	if (WARN_ON(pll < dev_priv->shared_dplls||
>  		    pll > &dev_priv->shared_dplls[dev_priv->num_shared_dpll]))
> -		return -1;
> +		return -ENOENT;
>  
>  	return (enum intel_dpll_id) (pll - dev_priv->shared_dplls);
>  }
> -- 
> 2.13.6
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-01 18:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-01 18:44 [PATCH] drm/i915: Don't try to use negative pll_id Rodrigo Vivi
2017-11-01 18:56 ` Ville Syrjälä [this message]
2017-11-01 19:13   ` Rodrigo Vivi
2017-11-01 19:26     ` Ville Syrjälä
2017-11-01 19:08 ` Manasi Navare
2017-11-01 19:36   ` Rodrigo Vivi
2017-11-01 20:11 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-01 21:11 ` ✗ Fi.CI.IGT: failure " 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=20171101185655.GH10981@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@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