Commit 866955fa authored by Imre Deak's avatar Imre Deak

drm/i915: Sanitize the shared DPLL reserve/release interface

For consistency s/intel_get_shared_dpll()/intel_reserve_shared_dplls()/
to better match intel_release_shared_dplls(). Also, pass to the
reserve/release and get_dplls/put_dplls hooks the intel_atomic_state and
CRTC object, that way these functions can look up the old or new state
as needed.

Also release the PLLs from the atomic state via a new
put_dplls->intel_unreference_shared_dpll() call chain for better
symmetry with the reservation via the
get_dplls->intel_reference_shared_dpll() call chain.

Since nothing uses the PLL returned by intel_reserve_shared_dplls(),
make it return only a bool.

While at it also clarify the reserve/release function docbook headers
making it clear that multiple DPLLs will be reserved/released and
whether the new or old atomic CRTC state is affected.

This refactoring is also a preparation for a follow-up change that needs
to reserve multiple DPLLs.

Kudos to Ville for the idea to pass intel_atomic_state around, to make
things clearer locally where an object's old/new atomic state is
required.

No functional changes.

v2:
- Fix checkpatch issue: typo in code comment.
v3:
- Rebase on drm-tip.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190628143635.22066-17-imre.deak@intel.com
parent 4f36afb2
...@@ -9493,6 +9493,8 @@ static int ironlake_crtc_compute_clock(struct intel_crtc *crtc, ...@@ -9493,6 +9493,8 @@ static int ironlake_crtc_compute_clock(struct intel_crtc *crtc,
struct intel_crtc_state *crtc_state) struct intel_crtc_state *crtc_state)
{ {
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct intel_atomic_state *state =
to_intel_atomic_state(crtc_state->base.state);
const struct intel_limit *limit; const struct intel_limit *limit;
int refclk = 120000; int refclk = 120000;
...@@ -9534,7 +9536,7 @@ static int ironlake_crtc_compute_clock(struct intel_crtc *crtc, ...@@ -9534,7 +9536,7 @@ static int ironlake_crtc_compute_clock(struct intel_crtc *crtc,
ironlake_compute_dpll(crtc, crtc_state, NULL); ironlake_compute_dpll(crtc, crtc_state, NULL);
if (!intel_get_shared_dpll(crtc_state, NULL)) { if (!intel_reserve_shared_dplls(state, crtc, NULL)) {
DRM_DEBUG_KMS("failed to find PLL for pipe %c\n", DRM_DEBUG_KMS("failed to find PLL for pipe %c\n",
pipe_name(crtc->pipe)); pipe_name(crtc->pipe));
return -EINVAL; return -EINVAL;
...@@ -9915,7 +9917,7 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc, ...@@ -9915,7 +9917,7 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
struct intel_encoder *encoder = struct intel_encoder *encoder =
intel_get_crtc_new_encoder(state, crtc_state); intel_get_crtc_new_encoder(state, crtc_state);
if (!intel_get_shared_dpll(crtc_state, encoder)) { if (!intel_reserve_shared_dplls(state, crtc, encoder)) {
DRM_DEBUG_KMS("failed to find PLL for pipe %c\n", DRM_DEBUG_KMS("failed to find PLL for pipe %c\n",
pipe_name(crtc->pipe)); pipe_name(crtc->pipe));
return -EINVAL; return -EINVAL;
...@@ -13171,27 +13173,20 @@ static void update_scanline_offset(const struct intel_crtc_state *crtc_state) ...@@ -13171,27 +13173,20 @@ static void update_scanline_offset(const struct intel_crtc_state *crtc_state)
static void intel_modeset_clear_plls(struct intel_atomic_state *state) static void intel_modeset_clear_plls(struct intel_atomic_state *state)
{ {
struct drm_i915_private *dev_priv = to_i915(state->base.dev); struct drm_i915_private *dev_priv = to_i915(state->base.dev);
struct intel_crtc_state *old_crtc_state, *new_crtc_state; struct intel_crtc_state *new_crtc_state;
struct intel_crtc *crtc; struct intel_crtc *crtc;
int i; int i;
if (!dev_priv->display.crtc_compute_clock) if (!dev_priv->display.crtc_compute_clock)
return; return;
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
new_crtc_state, i) {
struct intel_shared_dpll *old_dpll =
old_crtc_state->shared_dpll;
if (!needs_modeset(new_crtc_state)) if (!needs_modeset(new_crtc_state))
continue; continue;
new_crtc_state->shared_dpll = NULL; new_crtc_state->shared_dpll = NULL;
if (!old_dpll) intel_release_shared_dplls(state, crtc);
continue;
intel_release_shared_dpll(old_dpll, crtc, &state->base);
} }
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
struct drm_atomic_state; struct drm_atomic_state;
struct drm_device; struct drm_device;
struct drm_i915_private; struct drm_i915_private;
struct intel_atomic_state;
struct intel_crtc; struct intel_crtc;
struct intel_crtc_state; struct intel_crtc_state;
struct intel_encoder; struct intel_encoder;
...@@ -195,7 +196,7 @@ struct intel_dpll_hw_state { ...@@ -195,7 +196,7 @@ struct intel_dpll_hw_state {
* future state which would be applied by an atomic mode set (stored in * future state which would be applied by an atomic mode set (stored in
* a struct &intel_atomic_state). * a struct &intel_atomic_state).
* *
* See also intel_get_shared_dpll() and intel_release_shared_dpll(). * See also intel_reserve_shared_dplls() and intel_release_shared_dplls().
*/ */
struct intel_shared_dpll_state { struct intel_shared_dpll_state {
/** /**
...@@ -331,11 +332,11 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv, ...@@ -331,11 +332,11 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv,
bool state); bool state);
#define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true) #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
#define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false) #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc_state *state, bool intel_reserve_shared_dplls(struct intel_atomic_state *state,
struct intel_encoder *encoder);
void intel_release_shared_dpll(struct intel_shared_dpll *dpll,
struct intel_crtc *crtc, struct intel_crtc *crtc,
struct drm_atomic_state *state); struct intel_encoder *encoder);
void intel_release_shared_dplls(struct intel_atomic_state *state,
struct intel_crtc *crtc);
void intel_prepare_shared_dpll(const struct intel_crtc_state *crtc_state); void intel_prepare_shared_dpll(const struct intel_crtc_state *crtc_state);
void intel_enable_shared_dpll(const struct intel_crtc_state *crtc_state); void intel_enable_shared_dpll(const struct intel_crtc_state *crtc_state);
void intel_disable_shared_dpll(const struct intel_crtc_state *crtc_state); void intel_disable_shared_dpll(const struct intel_crtc_state *crtc_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment