aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahesh Kumar <mahesh1.kumar@intel.com>2018-04-08 23:41:08 -0400
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-04-09 07:40:22 -0400
commite1f96a66e72569f6277262eef23614236cc6dc15 (patch)
treed8187b8722bb00f8cdbb84488a6635e9e2117e4c
parent08d0e875aefe72c63076a768a368126ea74a1e3e (diff)
drm/i915/skl: split skl_compute_ddb function
This patch splits skl_compute_wm/ddb functions into two parts. One adds all affected pipes after the commit to atomic_state structure and second part does compute the DDB. v2: Added reviewed by tag from Shashank Sharma v3: Added reviewed by from Juha-Pekka Heikkila v4: Rebased the series v5: Fixed checkpatch error. Changed *changed = true to (*changed) = true; Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Shashank Sharma <shashank.sharma@intel.com> Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com> Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1523245273-30264-10-git-send-email-vidya.srinivas@intel.com
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c157
1 files changed, 88 insertions, 69 deletions
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 9d5a7b3e9716..007a12ebe725 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -5059,69 +5059,16 @@ skl_ddb_add_affected_planes(struct intel_crtc_state *cstate)
5059static int 5059static int
5060skl_compute_ddb(struct drm_atomic_state *state) 5060skl_compute_ddb(struct drm_atomic_state *state)
5061{ 5061{
5062 struct drm_device *dev = state->dev; 5062 const struct drm_i915_private *dev_priv = to_i915(state->dev);
5063 struct drm_i915_private *dev_priv = to_i915(dev);
5064 struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 5063 struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
5065 struct intel_crtc *intel_crtc;
5066 struct skl_ddb_allocation *ddb = &intel_state->wm_results.ddb; 5064 struct skl_ddb_allocation *ddb = &intel_state->wm_results.ddb;
5067 uint32_t realloc_pipes = pipes_modified(state); 5065 struct intel_crtc *crtc;
5068 int ret; 5066 struct intel_crtc_state *cstate;
5069 5067 int ret, i;
5070 /*
5071 * If this is our first atomic update following hardware readout,
5072 * we can't trust the DDB that the BIOS programmed for us. Let's
5073 * pretend that all pipes switched active status so that we'll
5074 * ensure a full DDB recompute.
5075 */
5076 if (dev_priv->wm.distrust_bios_wm) {
5077 ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
5078 state->acquire_ctx);
5079 if (ret)
5080 return ret;
5081
5082 intel_state->active_pipe_changes = ~0;
5083
5084 /*
5085 * We usually only initialize intel_state->active_crtcs if we
5086 * we're doing a modeset; make sure this field is always
5087 * initialized during the sanitization process that happens
5088 * on the first commit too.
5089 */
5090 if (!intel_state->modeset)
5091 intel_state->active_crtcs = dev_priv->active_crtcs;
5092 }
5093
5094 /*
5095 * If the modeset changes which CRTC's are active, we need to
5096 * recompute the DDB allocation for *all* active pipes, even
5097 * those that weren't otherwise being modified in any way by this
5098 * atomic commit. Due to the shrinking of the per-pipe allocations
5099 * when new active CRTC's are added, it's possible for a pipe that
5100 * we were already using and aren't changing at all here to suddenly
5101 * become invalid if its DDB needs exceeds its new allocation.
5102 *
5103 * Note that if we wind up doing a full DDB recompute, we can't let
5104 * any other display updates race with this transaction, so we need
5105 * to grab the lock on *all* CRTC's.
5106 */
5107 if (intel_state->active_pipe_changes) {
5108 realloc_pipes = ~0;
5109 intel_state->wm_results.dirty_pipes = ~0;
5110 }
5111 5068
5112 /*
5113 * We're not recomputing for the pipes not included in the commit, so
5114 * make sure we start with the current state.
5115 */
5116 memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb)); 5069 memcpy(ddb, &dev_priv->wm.skl_hw.ddb, sizeof(*ddb));
5117 5070
5118 for_each_intel_crtc_mask(dev, intel_crtc, realloc_pipes) { 5071 for_each_new_intel_crtc_in_state(intel_state, crtc, cstate, i) {
5119 struct intel_crtc_state *cstate;
5120
5121 cstate = intel_atomic_get_crtc_state(state, intel_crtc);
5122 if (IS_ERR(cstate))
5123 return PTR_ERR(cstate);
5124
5125 ret = skl_allocate_pipe_ddb(cstate, ddb); 5072 ret = skl_allocate_pipe_ddb(cstate, ddb);
5126 if (ret) 5073 if (ret)
5127 return ret; 5074 return ret;
@@ -5183,23 +5130,23 @@ skl_print_wm_changes(const struct drm_atomic_state *state)
5183} 5130}
5184 5131
5185static int 5132static int
5186skl_compute_wm(struct drm_atomic_state *state) 5133skl_ddb_add_affected_pipes(struct drm_atomic_state *state, bool *changed)
5187{ 5134{
5188 struct drm_crtc *crtc;
5189 struct drm_crtc_state *cstate;
5190 struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
5191 struct skl_ddb_values *results = &intel_state->wm_results;
5192 struct drm_device *dev = state->dev; 5135 struct drm_device *dev = state->dev;
5193 struct skl_pipe_wm *pipe_wm; 5136 const struct drm_i915_private *dev_priv = to_i915(dev);
5194 bool changed = false; 5137 const struct drm_crtc *crtc;
5138 const struct drm_crtc_state *cstate;
5139 struct intel_crtc *intel_crtc;
5140 struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
5141 uint32_t realloc_pipes = pipes_modified(state);
5195 int ret, i; 5142 int ret, i;
5196 5143
5197 /* 5144 /*
5198 * When we distrust bios wm we always need to recompute to set the 5145 * When we distrust bios wm we always need to recompute to set the
5199 * expected DDB allocations for each CRTC. 5146 * expected DDB allocations for each CRTC.
5200 */ 5147 */
5201 if (to_i915(dev)->wm.distrust_bios_wm) 5148 if (dev_priv->wm.distrust_bios_wm)
5202 changed = true; 5149 (*changed) = true;
5203 5150
5204 /* 5151 /*
5205 * If this transaction isn't actually touching any CRTC's, don't 5152 * If this transaction isn't actually touching any CRTC's, don't
@@ -5210,14 +5157,86 @@ skl_compute_wm(struct drm_atomic_state *state)
5210 * hold _all_ CRTC state mutexes. 5157 * hold _all_ CRTC state mutexes.
5211 */ 5158 */
5212 for_each_new_crtc_in_state(state, crtc, cstate, i) 5159 for_each_new_crtc_in_state(state, crtc, cstate, i)
5213 changed = true; 5160 (*changed) = true;
5214 5161
5215 if (!changed) 5162 if (!*changed)
5216 return 0; 5163 return 0;
5217 5164
5165 /*
5166 * If this is our first atomic update following hardware readout,
5167 * we can't trust the DDB that the BIOS programmed for us. Let's
5168 * pretend that all pipes switched active status so that we'll
5169 * ensure a full DDB recompute.
5170 */
5171 if (dev_priv->wm.distrust_bios_wm) {
5172 ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
5173 state->acquire_ctx);
5174 if (ret)
5175 return ret;
5176
5177 intel_state->active_pipe_changes = ~0;
5178
5179 /*
5180 * We usually only initialize intel_state->active_crtcs if we
5181 * we're doing a modeset; make sure this field is always
5182 * initialized during the sanitization process that happens
5183 * on the first commit too.
5184 */
5185 if (!intel_state->modeset)
5186 intel_state->active_crtcs = dev_priv->active_crtcs;
5187 }
5188
5189 /*
5190 * If the modeset changes which CRTC's are active, we need to
5191 * recompute the DDB allocation for *all* active pipes, even
5192 * those that weren't otherwise being modified in any way by this
5193 * atomic commit. Due to the shrinking of the per-pipe allocations
5194 * when new active CRTC's are added, it's possible for a pipe that
5195 * we were already using and aren't changing at all here to suddenly
5196 * become invalid if its DDB needs exceeds its new allocation.
5197 *
5198 * Note that if we wind up doing a full DDB recompute, we can't let
5199 * any other display updates race with this transaction, so we need
5200 * to grab the lock on *all* CRTC's.
5201 */
5202 if (intel_state->active_pipe_changes) {
5203 realloc_pipes = ~0;
5204 intel_state->wm_results.dirty_pipes = ~0;
5205 }
5206
5207 /*
5208 * We're not recomputing for the pipes not included in the commit, so
5209 * make sure we start with the current state.
5210 */
5211 for_each_intel_crtc_mask(dev, intel_crtc, realloc_pipes) {
5212 struct intel_crtc_state *cstate;
5213
5214 cstate = intel_atomic_get_crtc_state(state, intel_crtc);
5215 if (IS_ERR(cstate))
5216 return PTR_ERR(cstate);
5217 }
5218
5219 return 0;
5220}
5221
5222static int
5223skl_compute_wm(struct drm_atomic_state *state)
5224{
5225 struct drm_crtc *crtc;
5226 struct drm_crtc_state *cstate;
5227 struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
5228 struct skl_ddb_values *results = &intel_state->wm_results;
5229 struct skl_pipe_wm *pipe_wm;
5230 bool changed = false;
5231 int ret, i;
5232
5218 /* Clear all dirty flags */ 5233 /* Clear all dirty flags */
5219 results->dirty_pipes = 0; 5234 results->dirty_pipes = 0;
5220 5235
5236 ret = skl_ddb_add_affected_pipes(state, &changed);
5237 if (ret || !changed)
5238 return ret;
5239
5221 ret = skl_compute_ddb(state); 5240 ret = skl_compute_ddb(state);
5222 if (ret) 5241 if (ret)
5223 return ret; 5242 return ret;