All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anusha Srivatsa <anusha.srivatsa@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH] drm/i915/display: Add missing checks for cdclk crawling
Date: Wed,  9 Nov 2022 21:37:24 -0800	[thread overview]
Message-ID: <20221110053724.14701-1-anusha.srivatsa@intel.com> (raw)

cdclk_sanitize() function was written assuming vco was a signed integer.
vco gets assigned to -1 (essentially ~0) for the case where PLL
might be enabled and vco is not a frequency that will ever
get used. In such a scenario the right thing to do is disable the
PLL and re-enable it again with a valid frequency.
However the vco is declared as a unsigned variable.
With the above assumption, driver takes crawl path when not needed.
Add explicit check to not crawl in the case of an invalid PLL.

Cc: Matt Roper <matthew.d.roper@intel.com>
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 2 ++
 drivers/gpu/drm/i915/display/intel_cdclk.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
index 8a9031012d74..91112d266763 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -1962,6 +1962,8 @@ static bool intel_cdclk_can_crawl(struct drm_i915_private *dev_priv,
 	if (!HAS_CDCLK_CRAWL(dev_priv))
 		return false;
 
+	if (intel_pll_is_unknown(a->vco))
+		return false;
 	/*
 	 * The vco and cd2x divider will change independently
 	 * from each, so we disallow cd2x change when crawling.
diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.h b/drivers/gpu/drm/i915/display/intel_cdclk.h
index c674879a84a5..6eb83d806f11 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.h
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.h
@@ -80,6 +80,7 @@ intel_atomic_get_cdclk_state(struct intel_atomic_state *state);
 	to_intel_cdclk_state(intel_atomic_get_old_global_obj_state(state, &to_i915(state->base.dev)->display.cdclk.obj))
 #define intel_atomic_get_new_cdclk_state(state) \
 	to_intel_cdclk_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->display.cdclk.obj))
+#define intel_pll_is_unknown(vco)	((vco) == ~0)
 
 int intel_cdclk_init(struct drm_i915_private *dev_priv);
 
-- 
2.25.1


             reply	other threads:[~2022-11-10  5:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10  5:37 Anusha Srivatsa [this message]
2022-11-10 11:28 ` [Intel-gfx] [PATCH] drm/i915/display: Add missing checks for cdclk crawling Jani Nikula
2022-11-10 17:43   ` Matt Roper
2022-11-10 21:20 ` Ville Syrjälä
2022-11-10 21:23 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for " Patchwork
2022-11-10 21:42 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-11-11  6:13 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-11-11 19:26 [Intel-gfx] [PATCH] " Anusha Srivatsa
2022-11-11 19:39 ` Ville Syrjälä
2022-11-14 16:19   ` Srivatsa, Anusha

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=20221110053724.14701-1-anusha.srivatsa@intel.com \
    --to=anusha.srivatsa@intel.com \
    --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 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.