Skip to contentSkip to conversation

Convert to atomic, part 4.

RFC PATCH NAK Maarten Lankhorst 3 participants 17 messages Jun 19, 2015 – Jun 23, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Convert to atomic, part 4.

The only thing missing after part 3 is restoring atomic readout and making suspend/restore. With fixes for all identified causes of regressions from atomic suspend being done in convert to atomic, part 3 it's time to worry about getting atomic suspend/restore working again.

I do this in a few steps, first I re-introduce the old commit for hw state readout, with fixes. After that I convert the atomic readout to a full initial modeset, and finally I try to re-enable fastboot optimizations again by default, in a less hacky way.

This is a RFC because of the following possible issues:
- mode->clock may not be read out correctly. It can differ slightly from the actually set value, which forces a modeset anyway when it could be avoided.
- Not tested with DRRS support on DP, might be broken with fastboot?

Maarten Lankhorst (7):
drm/i915: Do not update pfit state when toggling crtc enabled. drm/i915: Read hw state into an atomic state struct, try 2. All changes from try2.
drm/i915: enable fastboot for everyone
drm/i915: Update power domains only on affected crtc's. drm/i915: Always reset in intel_crtc_restore_mode drm/i915: Make intel_display_suspend atomic, try 2.

 drivers/gpu/drm/i915/i915_dma.c      |   12 +-
 drivers/gpu/drm/i915/i915_drv.c      |    2 +-
 drivers/gpu/drm/i915/i915_drv.h      |    7 +-
 drivers/gpu/drm/i915/i915_params.c   |    5 -
 drivers/gpu/drm/i915/intel_atomic.c  |   23 +-
 drivers/gpu/drm/i915/intel_display.c | 1302 ++++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dp.c      |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |   21 +-
 drivers/gpu/drm/i915/intel_fbdev.c   |   22 +-
 drivers/gpu/drm/i915/intel_lvds.c    |    2 +-
 10 files changed, 786 insertions(+), 612 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC PATCH 1/7 drm/i915: Do not update pfit state when toggling crtc enabled.

This must be done in advance, and during crtc_disable all scalers can be force disabled.

This means intel_atomic_setup_scalers is only called in 1 place now, during crtc_check.

---
 drivers/gpu/drm/i915/intel_atomic.c  | 14 ++------
 drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dp.c      |  2 +-
 drivers/gpu/drm/i915/intel_drv.h     |  2 +-
 4 files changed, 47 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +3 -11
index 0aeced82201e..429677a111d5 100644
@@ -272,17 +272,12 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 	struct drm_plane *plane = NULL;
 	struct intel_plane *intel_plane;
 	struct intel_plane_state *plane_state = NULL;
-	struct intel_crtc_scaler_state *scaler_state;
-	struct drm_atomic_state *drm_state;
+	struct intel_crtc_scaler_state *scaler_state =
+		&crtc_state->scaler_state;
+	struct drm_atomic_state *drm_state = crtc_state->base.state;
 	int num_scalers_need;
 	int i, j;
 
-	if (INTEL_INFO(dev)->gen < 9 || !intel_crtc || !crtc_state)
-		return 0;
-
-	scaler_state = &crtc_state->scaler_state;
-	drm_state = crtc_state->base.state;
-
 	num_scalers_need = hweight32(scaler_state->scaler_users);
 	DRM_DEBUG_KMS("crtc_state = %p need = %d avail = %d scaler_users = 0x%x\n",
 		crtc_state, num_scalers_need, intel_crtc->num_scalers,
@@ -327,9 +322,6 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 			name = "PLANE";
 			idx = plane->base.id;
 
-			if (!drm_state)
-				continue;
-
 			/* plane scaler case: assign as a plane scaler */
 			/* find the plane that set the bit as scaler_user */
 			plane = drm_state->planes[i];
drivers/gpu/drm/i915/intel_display.c +42 -25

138 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dp.c +1 -1
index 6141a702ba36..daf47b1de76c 100644
@@ -1377,7 +1377,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
 
 		if (INTEL_INFO(dev)->gen >= 9) {
 			int ret;
-			ret = skl_update_scaler_crtc(pipe_config, 0);
+			ret = skl_update_scaler_crtc(pipe_config);
 			if (ret)
 				return ret;
 		}
drivers/gpu/drm/i915/intel_drv.h +1 -1
index 853bfd98ef72..4b185564aeea 100644
@@ -1149,7 +1149,7 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
 
-int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
+int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
 
 unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

RFC PATCH 2/7 drm/i915: Read hw state into an atomic state struct, try 2.

In reply to Maarten Lankhorst

To make this work we load the new hardware state into the atomic_state, then swap it with the sw state.

This lets us change the force restore path in setup_hw_state() to use a single call to intel_mode_set() to restore all the previous state.

As a nice bonus this kills off encoder->new_encoder, connector->new_enabled and crtc->new_enabled. They were used only to restore the state after a modeset.

Change since try1:
- Fix the regressions caused by not updating drm core sw state.

---
 drivers/gpu/drm/i915/intel_atomic.c  |   2 +-
 drivers/gpu/drm/i915/intel_display.c | 381 ++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_drv.h     |  14 +-
 3 files changed, 243 insertions(+), 154 deletions(-)
drivers/gpu/drm/i915/intel_atomic.c +1 -1
index 429677a111d5..4d87574a2032 100644
@@ -398,7 +398,7 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 	return 0;
 }
 
-static void
+void
 intel_atomic_duplicate_dpll_state(struct drm_i915_private *dev_priv,
 				  struct intel_shared_dpll_config *shared_dpll)
 {
drivers/gpu/drm/i915/intel_display.c +240 -141

589 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +2 -12
index 4b185564aeea..bc7d0a003c8e 100644
@@ -130,11 +130,6 @@ struct intel_fbdev {
 
 struct intel_encoder {
 	struct drm_encoder base;
-	/*
-	 * The new crtc this encoder will be driven from. Only differs from
-	 * base->crtc while a modeset is in progress.
-	 */
-	struct intel_crtc *new_crtc;
 
 	enum intel_output_type type;
 	unsigned int cloneable;
@@ -195,12 +190,6 @@ struct intel_connector {
 	 */
 	struct intel_encoder *encoder;
 
-	/*
-	 * The new encoder this connector will be driven. Only differs from
-	 * encoder while a modeset is in progress.
-	 */
-	struct intel_encoder *new_encoder;
-
 	/* Reads out the current hw, returning true if the connector is enabled
 	 * and active (i.e. dpms ON state). */
 	bool (*get_hw_state)(struct intel_connector *);
@@ -541,7 +530,6 @@ struct intel_crtc {
 
 	struct intel_initial_plane_config plane_config;
 	struct intel_crtc_state *config;
-	bool new_enabled;
 
 	/* reset counter value when the last flip was submitted */
 	unsigned int reset_counter;
@@ -1418,6 +1406,8 @@ struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
 void intel_atomic_state_clear(struct drm_atomic_state *);
 struct intel_shared_dpll_config *
 intel_atomic_get_shared_dpll_state(struct drm_atomic_state *s);
+void intel_atomic_duplicate_dpll_state(struct drm_i915_private *,
+				       struct intel_shared_dpll_config *);
 
 static inline struct intel_crtc_state *
 intel_atomic_get_crtc_state(struct drm_atomic_state *state,
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [RFC PATCH 2/7] drm/i915: Read hw state into an atomic state struct, try 2.

Hi,

drivers/gpu/drm/i915/intel_display.c void intel_modeset_setup_hw_state(struct drm_device *dev, · line 15613

Quoted 8 lines · Maarten Lankhorst
drivers/gpu/drm/i915/intel_display.c +8 -0
+               if (crtc->state->enable) {
+                       intel_mode_from_pipe_config(&crtc->mode,
+                               to_intel_crtc_state(crtc->state));
+                       intel_mode_from_pipe_config(&crtc->state->adjusted_mode,
+                               to_intel_crtc_state(crtc->state));
+
+                       if (drm_atomic_set_mode_for_crtc(crtc->state, &crtc->mode) < 0)
+                               drm_mode_copy(&crtc->state->mode, &crtc->mode);

I've never really understood why this is here. There are only two ways in which set_mode_for_crtc can fail: either the mode fails validation (fixed in the patch I sent you the other day, which it seems like you've now pulled in), or -ENOMEM. The first one we shouldn't really be papering over - and I haven't seen it happen since that patch - and the second one isn't really recoverable anyway. Plus I would argue that breaking the state like that is pretty bad.

Cheers,
Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [RFC PATCH 2/7] drm/i915: Read hw state into an atomic state struct, try 2.

In reply to Maarten Lankhorst
Quoted 32 lines · Maarten Lankhorst

/* Scan out the current hw modeset state, sanitizes it and maps it into the drm

drivers/gpu/drm/i915/intel_display.c +7 -17
@@ -15491,37 +15569,61 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
 				  bool force_restore)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum pipe pipe;
-	struct intel_crtc *crtc;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
 	struct intel_encoder *encoder;
+	struct drm_atomic_state *state;
+	struct intel_shared_dpll_config shared_dplls[I915_NUM_PLLS];
 	int i;
 
-	intel_modeset_readout_hw_state(dev);
-
-	/*
-	 * Now that we have the config, copy it to each CRTC struct
-	 * Note that this could go away if we move to using crtc_config
-	 * checking everywhere.
-	 */
-	for_each_intel_crtc(dev, crtc) {
-		if (crtc->active && i915.fastboot) {
-			intel_mode_from_pipe_config(&crtc->base.mode,
-						    crtc->config);
-			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
-				      crtc->base.base.id);
-			drm_mode_debug_printmodeline(&crtc->base.mode);
-		}
+	state = intel_modeset_readout_hw_state(dev);
+	if (IS_ERR(state)) {
+		DRM_ERROR("Failed to read out hw state\n");

drivers/gpu/drm/i915/intel_display.c void intel_modeset_setup_hw_state(struct drm_device *dev, · line 15591

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
+		return;
 	}
 
+	drm_atomic_helper_swap_state(dev, state);
+
+	/* swap sw/hw dpll state */
+	intel_atomic_duplicate_dpll_state(dev_priv, shared_dplls);
+	intel_shared_dpll_commit(state);
+	memcpy(to_intel_atomic_state(state)->shared_dpll,
+	       shared_dplls, sizeof(*shared_dplls) * dev_priv->num_shared_dpll);

This is imo way too much open-coding of stuff that's already there. What I had in mind for force_restore was a generic helper to duplicate all the state objects into a drm_atomic_state, without calling any of the ->atomic_check functions or anything. Then the sequence for restoring state would be.

1. saved_state = drm_atomic_helper_duplicate_state()
2. intel_readout_hw_sate() <- this would just update ->state and sanitize it.
3. drm_atomic_commit(saved_state) wrapped in a WARN_ON to make sure it always works.

Ofc we still need the ww-mutex deadlock avoidance wrapped around this, but since atomic_commit will first compute all derived state there's no need to duplicate all the i915-internal state too. That should all work like with any other normal modeset.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [RFC PATCH 2/7] drm/i915: Read hw state into an atomic state struct, try 2.

Op 22-06-15 om 17:31 schreef Daniel Vetter:

Quoted 49 lines · Maarten Lankhorst
Quoted 32 lines

/* Scan out the current hw modeset state, sanitizes it and maps it into the drm

drivers/gpu/drm/i915/intel_display.c +7 -17
@@ -15491,37 +15569,61 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
 				  bool force_restore)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum pipe pipe;
-	struct intel_crtc *crtc;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
 	struct intel_encoder *encoder;
+	struct drm_atomic_state *state;
+	struct intel_shared_dpll_config shared_dplls[I915_NUM_PLLS];
 	int i;
 
-	intel_modeset_readout_hw_state(dev);
-
-	/*
-	 * Now that we have the config, copy it to each CRTC struct
-	 * Note that this could go away if we move to using crtc_config
-	 * checking everywhere.
-	 */
-	for_each_intel_crtc(dev, crtc) {
-		if (crtc->active && i915.fastboot) {
-			intel_mode_from_pipe_config(&crtc->base.mode,
-						    crtc->config);
-			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
-				      crtc->base.base.id);
-			drm_mode_debug_printmodeline(&crtc->base.mode);
-		}
+	state = intel_modeset_readout_hw_state(dev);
+	if (IS_ERR(state)) {
+		DRM_ERROR("Failed to read out hw state\n");

drivers/gpu/drm/i915/intel_display.c void intel_modeset_setup_hw_state(struct drm_device *dev, · line 15591

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
+		return;
 	}
 
+	drm_atomic_helper_swap_state(dev, state);
+
+	/* swap sw/hw dpll state */
+	intel_atomic_duplicate_dpll_state(dev_priv, shared_dplls);
+	intel_shared_dpll_commit(state);
+	memcpy(to_intel_atomic_state(state)->shared_dpll,
+	       shared_dplls, sizeof(*shared_dplls) * dev_priv->num_shared_dpll);

This is imo way too much open-coding of stuff that's already there. What I had in mind for force_restore was a generic helper to duplicate all the state objects into a drm_atomic_state, without calling any of the ->atomic_check functions or anything. Then the sequence for restoring state would be.

Quoted 5 lines

1. saved_state = drm_atomic_helper_duplicate_state()
2. intel_readout_hw_sate() <- this would just update ->state and sanitize it.
3. drm_atomic_commit(saved_state) wrapped in a WARN_ON to make sure it always works.

Well, for !force_restore we want to do an initial sanitizing modeset too, but with the full disabled state as reference point. I'm not sure dupe state followed by a swap, is different from save old state, and read out to current state.

Quoted 4 lines

Ofc we still need the ww-mutex deadlock avoidance wrapped around this, but since atomic_commit will first compute all derived state there's no need to duplicate all the i915-internal state too. That should all work like with any other normal modeset.

No need to wrap, readout touches everything so lock_all is fine.

~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

Re: [RFC PATCH 2/7] drm/i915: Read hw state into an atomic state struct, try 2.

Quoted 50 lines · Maarten Lankhorst

Op 22-06-15 om 17:31 schreef Daniel Vetter:

Quoted 49 lines · Maarten Lankhorst
Quoted 32 lines

/* Scan out the current hw modeset state, sanitizes it and maps it into the drm

drivers/gpu/drm/i915/intel_display.c +7 -17
@@ -15491,37 +15569,61 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
 				  bool force_restore)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum pipe pipe;
-	struct intel_crtc *crtc;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
 	struct intel_encoder *encoder;
+	struct drm_atomic_state *state;
+	struct intel_shared_dpll_config shared_dplls[I915_NUM_PLLS];
 	int i;
 
-	intel_modeset_readout_hw_state(dev);
-
-	/*
-	 * Now that we have the config, copy it to each CRTC struct
-	 * Note that this could go away if we move to using crtc_config
-	 * checking everywhere.
-	 */
-	for_each_intel_crtc(dev, crtc) {
-		if (crtc->active && i915.fastboot) {
-			intel_mode_from_pipe_config(&crtc->base.mode,
-						    crtc->config);
-			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
-				      crtc->base.base.id);
-			drm_mode_debug_printmodeline(&crtc->base.mode);
-		}
+	state = intel_modeset_readout_hw_state(dev);
+	if (IS_ERR(state)) {
+		DRM_ERROR("Failed to read out hw state\n");

drivers/gpu/drm/i915/intel_display.c void intel_modeset_setup_hw_state(struct drm_device *dev, · line 15591

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -0
+		return;
 	}
 
+	drm_atomic_helper_swap_state(dev, state);
+
+	/* swap sw/hw dpll state */
+	intel_atomic_duplicate_dpll_state(dev_priv, shared_dplls);
+	intel_shared_dpll_commit(state);
+	memcpy(to_intel_atomic_state(state)->shared_dpll,
+	       shared_dplls, sizeof(*shared_dplls) * dev_priv->num_shared_dpll);

This is imo way too much open-coding of stuff that's already there. What I had in mind for force_restore was a generic helper to duplicate all the state objects into a drm_atomic_state, without calling any of the ->atomic_check functions or anything. Then the sequence for restoring state would be.

Quoted 7 lines
Quoted 5 lines

1. saved_state = drm_atomic_helper_duplicate_state()
2. intel_readout_hw_sate() <- this would just update ->state and sanitize it.
3. drm_atomic_commit(saved_state) wrapped in a WARN_ON to make sure it always works.

Well, for !force_restore we want to do an initial sanitizing modeset too, but with the full disabled state as reference point. I'm not sure dupe state followed by a swap, is different from save old state, and read out to current state.

You also dupe internal state like dplls, that's what a helper-level duplicat state would avoid. And imo that's cleaner. ->atomic_check should then grab all the internal states needed, if any are necessary. The goal really is to avoid another special case with too much knowledge of i915 internals, which atomic really should allow us to do.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

RFC PATCH 3/7 All changes from try2.

In reply to Maarten Lankhorst

Always read out plane state, and do an initial modeset in modeset_gem_init.

---
 drivers/gpu/drm/i915/i915_dma.c      |  12 +-
 drivers/gpu/drm/i915/i915_drv.c      |   2 +-
 drivers/gpu/drm/i915/i915_drv.h      |   7 +-
 drivers/gpu/drm/i915/intel_atomic.c  |   7 -
 drivers/gpu/drm/i915/intel_display.c | 501 ++++++++++++++++++-----------------
 drivers/gpu/drm/i915/intel_drv.h     |   3 +-
 drivers/gpu/drm/i915/intel_fbdev.c   |  12 +-
 drivers/gpu/drm/i915/intel_lvds.c    |   2 +-
 8 files changed, 280 insertions(+), 266 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +9 -3
index 88795d2f1819..ede07f6fe7f7 100644
@@ -393,6 +393,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
 static int i915_load_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_atomic_state *state;
 	int ret;
 
 	ret = intel_parse_bios(dev);
@@ -431,13 +432,18 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
 	/* Important: The output setup functions called by modeset_init need
 	 * working irqs for e.g. gmbus and dp aux transfers. */
-	intel_modeset_init(dev);
+	state = intel_modeset_init(dev);
 
 	ret = i915_gem_init(dev);
-	if (ret)
+	if (ret) {
+		if (state) {
+			drm_atomic_state_free(state);
+			drm_modeset_unlock_all(dev);
+		}
 		goto cleanup_irq;
+	}
 
-	intel_modeset_gem_init(dev);
+	intel_modeset_gem_init(dev, state);
 
 	/* Always safe in the mode setting case. */
 	/* FIXME: do pre/post-mode set stuff in core KMS code */
drivers/gpu/drm/i915/i915_drv.c +1 -1
index 78ef0bb53c36..a29b24bca25e 100644
@@ -758,7 +758,7 @@ static int i915_drm_resume(struct drm_device *dev)
 	spin_unlock_irq(&dev_priv->irq_lock);
 
 	drm_modeset_lock_all(dev);
-	intel_modeset_setup_hw_state(dev, true);
+	intel_display_resume(dev);
 	drm_modeset_unlock_all(dev);
 
 	intel_dp_mst_resume(dev);
drivers/gpu/drm/i915/i915_drv.h +3 -4
index d9410bd4ab59..e67d2f1e3ab8 100644
@@ -3233,13 +3233,12 @@ static inline void intel_unregister_dsm_handler(void) { return; }
 
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
-extern void intel_modeset_init(struct drm_device *dev);
-extern void intel_modeset_gem_init(struct drm_device *dev);
+extern struct drm_atomic_state *intel_modeset_init(struct drm_device *dev);
+extern void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *);
 extern void intel_modeset_cleanup(struct drm_device *dev);
 extern void intel_connector_unregister(struct intel_connector *);
 extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state);
-extern void intel_modeset_setup_hw_state(struct drm_device *dev,
-					 bool force_restore);
+extern void intel_display_resume(struct drm_device *dev);
 extern void i915_redisable_vga(struct drm_device *dev);
 extern void i915_redisable_vga_power_on(struct drm_device *dev);
 extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
drivers/gpu/drm/i915/intel_atomic.c +0 -7
index 4d87574a2032..f36fcc7ceecb 100644
@@ -98,13 +98,6 @@ int intel_atomic_check(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	if (crtc_state &&
-	    crtc_state->quirks & PIPE_CONFIG_QUIRK_INITIAL_PLANES) {
-		ret = drm_atomic_add_affected_planes(state, &nuclear_crtc->base);
-		if (ret)
-			return ret;
-	}
-
 	ret = drm_atomic_helper_check_planes(dev, state);
 	if (ret)
 		return ret;
drivers/gpu/drm/i915/intel_display.c +260 -241

814 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +1 -2
index bc7d0a003c8e..ea380b83eb5d 100644
@@ -330,7 +330,7 @@ struct intel_crtc_state {
 	 */
 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS	(1<<0) /* unreliable sync mode.flags */
 #define PIPE_CONFIG_QUIRK_INHERITED_MODE	(1<<1) /* mode inherited from firmware */
-#define PIPE_CONFIG_QUIRK_INITIAL_PLANES	(1<<2) /* planes are in unknown state */
+#define PIPE_CONFIG_QUIRK_WRONG_PLANE		(1<<2) /* intel_crtc->plane is wrong */
 	unsigned long quirks;
 
 	/* Pipe source size (ie. panel fitter input size)
@@ -528,7 +528,6 @@ struct intel_crtc {
 	uint32_t cursor_size;
 	uint32_t cursor_base;
 
-	struct intel_initial_plane_config plane_config;
 	struct intel_crtc_state *config;
 
 	/* reset counter value when the last flip was submitted */
drivers/gpu/drm/i915/intel_fbdev.c +5 -7
index 6372cfc7d053..6ac4990a0c11 100644
@@ -582,7 +582,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 	struct intel_framebuffer *fb = NULL;
 	struct drm_crtc *crtc;
 	struct intel_crtc *intel_crtc;
-	struct intel_initial_plane_config *plane_config = NULL;
 	unsigned int max_size = 0;
 
 	if (!i915.fastboot)
@@ -590,20 +589,21 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 
 	/* Find the largest fb */
 	for_each_crtc(dev, crtc) {
+		struct intel_framebuffer *plane_fb =
+			to_intel_framebuffer(crtc->primary->state->fb);
 		intel_crtc = to_intel_crtc(crtc);
 
-		if (!intel_crtc->active || !crtc->primary->fb) {
+		if (!intel_crtc->active || !plane_fb) {
 			DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
 				      pipe_name(intel_crtc->pipe));
 			continue;
 		}
 
-		if (intel_crtc->plane_config.size > max_size) {
+		if (plane_fb->obj->base.size > max_size) {
 			DRM_DEBUG_KMS("found possible fb from plane %c\n",
 				      pipe_name(intel_crtc->pipe));
-			plane_config = &intel_crtc->plane_config;
 			fb = to_intel_framebuffer(crtc->primary->fb);
-			max_size = plane_config->size;
+			max_size = fb->obj->base.size;
 		}
 	}
 
@@ -638,7 +638,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 			DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
 				      pipe_name(intel_crtc->pipe),
 				      cur_size, fb->base.pitches[0]);
-			plane_config = NULL;
 			fb = NULL;
 			break;
 		}
@@ -659,7 +658,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 			DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
 				      pipe_name(intel_crtc->pipe),
 				      cur_size, max_size);
-			plane_config = NULL;
 			fb = NULL;
 			break;
 		}
drivers/gpu/drm/i915/intel_lvds.c +1 -1
index 161ab26f81fb..78d86ae01621 100644
@@ -452,7 +452,7 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
 	 */
 	if (!HAS_PCH_SPLIT(dev)) {
 		drm_modeset_lock_all(dev);
-		intel_modeset_setup_hw_state(dev, true);
+		intel_display_resume(dev);
 		drm_modeset_unlock_all(dev);
 	}
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

RFC PATCH 4/7 drm/i915: enable fastboot for everyone

In reply to Maarten Lankhorst

Now that we read out the full atomic state we can force fastboot without hacks. The only thing that we worry about is preventing a modeset. This can be easily done by calculating if sw state matches hw state, with exception for pfit and pipe size. Since the original fastboot code only touched pipe size and panel fitter we keep those, and compare full sw state against hw state.

---
 drivers/gpu/drm/i915/i915_params.c   |   5 -
 drivers/gpu/drm/i915/intel_display.c | 271 ++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_fbdev.c   |  10 +-
 3 files changed, 169 insertions(+), 117 deletions(-)
drivers/gpu/drm/i915/i915_params.c +0 -5
index 8ac5a1b29ac0..9b344a956ba6 100644
@@ -41,7 +41,6 @@ struct i915_params i915 __read_mostly = {
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
 	.enable_ips = 1,
-	.fastboot = 0,
 	.prefault_disable = 0,
 	.load_detect_test = 0,
 	.reset = true,
@@ -137,10 +136,6 @@ MODULE_PARM_DESC(disable_power_well,
 module_param_named(enable_ips, i915.enable_ips, int, 0600);
 MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
 
-module_param_named(fastboot, i915.fastboot, bool, 0600);
-MODULE_PARM_DESC(fastboot,
-	"Try to skip unnecessary mode sets at boot time (default: false)");
-
 module_param_named_unsafe(prefault_disable, i915.prefault_disable, bool, 0600);
 MODULE_PARM_DESC(prefault_disable,
 	"Disable page prefaulting for pread/pwrite/reloc (default:false). "
drivers/gpu/drm/i915/intel_display.c +168 -103

391 lines not on this page · raw message

drivers/gpu/drm/i915/intel_fbdev.c +1 -9
index 6ac4990a0c11..2c494d78652a 100644
@@ -486,15 +486,10 @@ retry:
 			 * config, not the input mode, which is what crtc->mode
 			 * usually contains. But since our current fastboot
 			 * code puts a mode derived from the post-pfit timings
-			 * into crtc->mode this works out correctly. We don't
-			 * use hwmode anywhere right now, so use it for this
-			 * since the fb helper layer wants a pointer to
-			 * something we own.
+			 * into crtc->mode this works out correctly.
 			 */
 			DRM_DEBUG_KMS("looking for current mode on connector %s\n",
 				      connector->name);
-			intel_mode_from_pipe_config(&encoder->crtc->hwmode,
-						    to_intel_crtc(encoder->crtc)->config);
 			modes[i] = &encoder->crtc->hwmode;
 		}
 		crtcs[i] = new_crtc;
@@ -584,9 +579,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 	struct intel_crtc *intel_crtc;
 	unsigned int max_size = 0;
 
-	if (!i915.fastboot)
-		return false;
-
 	/* Find the largest fb */
 	for_each_crtc(dev, crtc) {
 		struct intel_framebuffer *plane_fb =
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

Re: [RFC PATCH 4/7] drm/i915: enable fastboot for everyone

Quoted 49 lines · Maarten Lankhorst

Now that we read out the full atomic state we can force fastboot without hacks. The only thing that we worry about is preventing a modeset. This can be easily done by calculating if sw state matches hw state, with exception for pfit and pipe size. Since the original fastboot code only touched pipe size and panel fitter we keep those, and compare full sw state against hw state.

---
 drivers/gpu/drm/i915/i915_params.c   |   5 -
 drivers/gpu/drm/i915/intel_display.c | 271 ++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_fbdev.c   |  10 +-
 3 files changed, 169 insertions(+), 117 deletions(-)
drivers/gpu/drm/i915/i915_params.c +0 -5
index 8ac5a1b29ac0..9b344a956ba6 100644
@@ -41,7 +41,6 @@ struct i915_params i915 __read_mostly = {
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
 	.enable_ips = 1,
-	.fastboot = 0,
 	.prefault_disable = 0,
 	.load_detect_test = 0,
 	.reset = true,
@@ -137,10 +136,6 @@ MODULE_PARM_DESC(disable_power_well,
 module_param_named(enable_ips, i915.enable_ips, int, 0600);
 MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
 
-module_param_named(fastboot, i915.fastboot, bool, 0600);
-MODULE_PARM_DESC(fastboot,
-	"Try to skip unnecessary mode sets at boot time (default: false)");
-
 module_param_named_unsafe(prefault_disable, i915.prefault_disable, bool, 0600);
 MODULE_PARM_DESC(prefault_disable,
 	"Disable page prefaulting for pread/pwrite/reloc (default:false). "
drivers/gpu/drm/i915/intel_display.c +1 -0
index 9b2acc7b4e29..de975ef09e23 100644
@@ -110,6 +110,7 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr
 static int i9xx_get_refclk(const struct intel_crtc_state *crtc_state,
 			   int num_connectors);
 static void intel_pre_disable_primary(struct drm_crtc *crtc);
+static void skylake_pfit_enable(struct intel_crtc *crtc);
 static struct drm_atomic_state *
 intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore);
 

drivers/gpu/drm/i915/intel_display.c static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) · line 3294

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
@@ -3289,14 +3290,17 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
 	return pending;
 }
 
-static void intel_update_pipe_size(struct intel_crtc *crtc)
+static void intel_update_fastboot(struct intel_crtc *crtc,
+				  struct intel_crtc_state *old_crtc_state)

That's not a useful rename imo - updating pfit/pipe_size clearly tells us what's going on, fastboot is much more a marketing thing really. And I expect that eventually we'll have to grow a lot more update code to fix up fastboot.

Quoted 83 lines
drivers/gpu/drm/i915/intel_display.c +19 -32
 {
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	const struct drm_display_mode *adjusted_mode;
+	struct intel_crtc_state *pipe_config =
+		to_intel_crtc_state(crtc->base.state);
 
-	if (!i915.fastboot)
-		return;
+	DRM_DEBUG_KMS("Applying fastboot quirks, %ix%i -> %ix%i\n",
+		      old_crtc_state->pipe_src_w, old_crtc_state->pipe_src_h,
+		      pipe_config->pipe_src_w, pipe_config->pipe_src_h);
 
 	/*
 	 * Update pipe size and adjust fitter if needed: the reason for this is
@@ -3305,27 +3309,27 @@ static void intel_update_pipe_size(struct intel_crtc *crtc)
 	 * fastboot case, we'll flip, but if we don't update the pipesrc and
 	 * pfit state, we'll end up with a big fb scanned out into the wrong
 	 * sized surface.
-	 *
-	 * To fix this properly, we need to hoist the checks up into
-	 * compute_mode_changes (or above), check the actual pfit state and
-	 * whether the platform allows pfit disable with pipe active, and only
-	 * then update the pipesrc and pfit state, even on the flip path.
 	 */
 
-	adjusted_mode = &crtc->config->base.adjusted_mode;
-
 	I915_WRITE(PIPESRC(crtc->pipe),
-		   ((adjusted_mode->crtc_hdisplay - 1) << 16) |
-		   (adjusted_mode->crtc_vdisplay - 1));
-	if (!crtc->config->pch_pfit.enabled &&
-	    (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) ||
-	     intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) {
+		   ((pipe_config->pipe_src_w - 1) << 16) |
+		   (pipe_config->pipe_src_h - 1));
+
+	/* on skylake this is done by detaching scalers */
+	if (INTEL_INFO(dev)->gen == 9) {
+		skl_detach_scalers(crtc);
+
+		if (pipe_config->pch_pfit.enabled)
+			skylake_pfit_enable(crtc);
+	}
+	else if (!pipe_config->pch_pfit.enabled &&
+	    old_crtc_state->pch_pfit.enabled) {
+		DRM_DEBUG_KMS("Disabling panel fitter\n");
+
 		I915_WRITE(PF_CTL(crtc->pipe), 0);
 		I915_WRITE(PF_WIN_POS(crtc->pipe), 0);
 		I915_WRITE(PF_WIN_SZ(crtc->pipe), 0);
 	}
-	crtc->config->pipe_src_w = adjusted_mode->crtc_hdisplay;
-	crtc->config->pipe_src_h = adjusted_mode->crtc_vdisplay;
 }
 
 static void intel_fdi_normal_train(struct drm_crtc *crtc)
@@ -12244,19 +12248,6 @@ encoder_retry:
 	DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n",
 		      base_bpp, pipe_config->pipe_bpp, pipe_config->dither);
 
-	/* Check if we need to force a modeset */
-	if (pipe_config->has_audio !=
-	    to_intel_crtc_state(crtc->state)->has_audio) {
-		pipe_config->base.mode_changed = true;
-		ret = drm_atomic_add_affected_planes(state, crtc);
-	}
-
-	/*
-	 * Note we have an issue here with infoframes: current code
-	 * only updates them on the full mode set path per hw
-	 * requirements.  So here we should be checking for any
-	 * required changes and forcing a mode set.
-	 */
 fail:
 	return ret;
 }
@@ -12500,29 +12491,21 @@ intel_pipe_config_compare(struct drm_device *dev,
 				      DRM_MODE_FLAG_NVSYNC);
 	}
 
-	PIPE_CONF_CHECK_I(pipe_src_w);
-	PIPE_CONF_CHECK_I(pipe_src_h);

drivers/gpu/drm/i915/intel_display.c intel_pipe_config_compare(struct drm_device *dev, · line 12494

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +0 -9
-
-	/*
-	 * FIXME: BIOS likes to set up a cloned config with lvds+external
-	 * screen. Since we don't yet re-compute the pipe config when moving
-	 * just the lvds port away to another pipe the sw tracking won't match.
-	 *
-	 * Proper atomic modesets with recomputed global state will fix this.
-	 * Until then just don't check gmch state for inherited modes.
-	 */
 	if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_INHERITED_MODE)) {

This seems like a separate change - with recomputing state on all pipes unconditionally we should be able to drop this?

Quoted 59 lines
drivers/gpu/drm/i915/intel_display.c +17 -22
-		PIPE_CONF_CHECK_I(gmch_pfit.control);
-		/* pfit ratios are autocomputed by the hw on gen4+ */
-		if (INTEL_INFO(dev)->gen < 4)
-			PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
-		PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
-	}
+		PIPE_CONF_CHECK_I(pipe_src_w);
+		PIPE_CONF_CHECK_I(pipe_src_h);
+
+		PIPE_CONF_CHECK_I(pch_pfit.enabled);
+		if (current_config->pch_pfit.enabled) {
+			PIPE_CONF_CHECK_I(pch_pfit.pos);
+			PIPE_CONF_CHECK_I(pch_pfit.size);
 
-	PIPE_CONF_CHECK_I(pch_pfit.enabled);
-	if (current_config->pch_pfit.enabled) {
-		PIPE_CONF_CHECK_I(pch_pfit.pos);
-		PIPE_CONF_CHECK_I(pch_pfit.size);
+			PIPE_CONF_CHECK_I(gmch_pfit.control);
+			/* pfit ratios are autocomputed by the hw on gen4+ */
+			if (INTEL_INFO(dev)->gen < 4)
+				PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
+			PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
+		}
 	}
 
 	PIPE_CONF_CHECK_I(scaler_state.scaler_id);
@@ -13057,26 +13040,18 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 		return ret;
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!crtc_state->enable) {
-			if (needs_modeset(crtc_state))
-				any_ms = true;
+		if (!needs_modeset(crtc_state))
 			continue;
-		}
 
-		if (!needs_modeset(crtc_state)) {
-			ret = drm_atomic_add_affected_connectors(state, crtc);
-			if (ret)
-				return ret;
-		}
+		any_ms = true;
+		if (!crtc_state->enable)
+			continue;
 
 		ret = intel_modeset_pipe_config(crtc,
 					to_intel_crtc_state(crtc_state));
 		if (ret)
 			return ret;
 
-		if (needs_modeset(crtc_state))
-			any_ms = true;
-
 		intel_dump_pipe_config(to_intel_crtc(crtc),
 				       to_intel_crtc_state(crtc_state),
 				       "[modeset]");

drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_atomic_state *state) · line 13128

Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
@@ -13147,7 +13122,10 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 		if (needs_modeset(crtc->state) && crtc->state->active) {
 			update_scanline_offset(to_intel_crtc(crtc));
 			dev_priv->display.crtc_enable(crtc);
-		}
+		} else if (to_intel_crtc_state(crtc_state)->quirks &
+			   PIPE_CONFIG_QUIRK_INHERITED_MODE)
+			/* force hw readout check */
+			any_ms = true;

Imo this should be a separate patch since forcing a modeset check after the initial takeover is a good thing. Also maybe do a s/any_ms/do_modeset_checks/ for clarity of what this does.

Quoted 33 lines
drivers/gpu/drm/i915/intel_display.c +2 -6
 		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 	}
@@ -13430,8 +13408,6 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 	if (ret)
 		goto out;
 
-	intel_update_pipe_size(to_intel_crtc(set->crtc));
-
 	ret = intel_set_mode_checked(state);
 	if (ret) {
 		DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
@@ -13718,10 +13694,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	if (state->visible)
-		/* FIXME: kill this fastboot hack */
-		intel_update_pipe_size(intel_crtc);
-
 	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
 }
 
@@ -13741,6 +13713,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_crtc_state *old_intel_state =
+		to_intel_crtc_state(old_crtc_state);
 
 	if (!needs_modeset(crtc->state))
 		intel_pre_plane_update(intel_crtc);

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13735

Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
@@ -13756,7 +13730,10 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
 
-	if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
+	if (!needs_modeset(crtc->state) && crtc->state->active &&
+	    old_intel_state->quirks & PIPE_CONFIG_QUIRK_INHERITED_MODE)
+		intel_update_fastboot(intel_crtc, old_intel_state);

Nack, fastboot only for the initial mode is not what I want. We should be able to speed up _any_ modeset where we just disable the pfit. Allowing fast pfit removal unconditionally will also allow us to easily test this part of fastboot with an igt, which I'd also like to see.

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13737

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
+	else if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
 		skl_detach_scalers(intel_crtc);

Also I think it'd be clearer if we have state flags (like for the pageflip stuff) in crtc_state to enable these fixup functions on an as-needed basis.

Quoted 80 lines
drivers/gpu/drm/i915/intel_display.c +74 -0
 }
 
@@ -15096,6 +15073,114 @@ intel_check_plane_mapping(struct intel_crtc *crtc)
 	return true;
 }
 
+static bool
+intel_compare_m_n(unsigned int m, unsigned int n,
+		  unsigned int m2, unsigned int n2)
+{
+	if (m == m2 && n == n2)
+		return true;
+
+	if (!m || !n || !m2 || !n2)
+		return false;
+
+	if (m > m2) {
+		while (m > m2) {
+			m >>= 1;
+			n >>= 1;
+		}
+	} else if (m < m2) {
+		while (m < m2) {
+			m2 >>= 1;
+			n2 >>= 1;
+		}
+	}
+
+	return m == m2 && n == n2;
+}
+
+static bool
+intel_compare_link_m_n(const struct intel_link_m_n *m_n,
+		       const struct intel_link_m_n *m2_n2)
+{
+	if (m_n->tu == m2_n2->tu &&
+	    intel_compare_m_n(m_n->gmch_m, m_n->gmch_n,
+			      m2_n2->gmch_m, m2_n2->gmch_n) &&
+	    intel_compare_m_n(m_n->link_m, m_n->link_n,
+			      m2_n2->link_m, m2_n2->link_n))
+		return true;
+
+	return false;
+}
+
+static void intel_fastboot_calc_modeset(struct intel_crtc *crtc,
+					struct intel_crtc_state *hw_state,
+					struct intel_crtc_state *pipe_config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct intel_crtc_state sw_state;
+
+	if (needs_modeset(&pipe_config->base)) {
+		DRM_DEBUG_KMS("Skipping fastboot checks, modeset forced\n");
+		return;
+	}
+
+	memset(&sw_state, 0, sizeof(sw_state));
+	sw_state.base = pipe_config->base;
+	sw_state.scaler_state = pipe_config->scaler_state;
+	sw_state.shared_dpll = pipe_config->shared_dpll;
+	sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
+	sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
+	intel_modeset_pipe_config(&crtc->base, &sw_state);
+	sw_state.quirks = hw_state->quirks & PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS;
+
+	if (intel_compare_link_m_n(&sw_state.fdi_m_n, &hw_state->fdi_m_n))
+		sw_state.fdi_m_n = hw_state->fdi_m_n;
+
+	if (INTEL_INFO(dev)->gen < 8) {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n))
+			sw_state.dp_m_n = hw_state->dp_m_n;
+
+		if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+					   &hw_state->dp_m2_n2))
+			sw_state.dp_m2_n2 = hw_state->dp_m2_n2;
+	} else {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n)) {

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15159

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+			sw_state.dp_m_n = hw_state->dp_m_n;
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		} else if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+						  &hw_state->dp_m_n)) {
+			sw_state.dp_m2_n2 = hw_state->dp_m_n;
+
+			hw_state->dp_m_n = sw_state.dp_m_n;
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		}
+	}

Not too happy with splitting up the modeset state compare code like this. If we add enum mode { EXACT, COMPATIBLE } to intel_pipe_config_compare we could tie things together well and have all the pipe config code grouped in one place. But then the _compare() is a bit misleading since it'd also update the sw_state, so maybe better to call it compare_and_ajust.

The macros would then either copy the hw_state to sw_state (if it's some intermediate state we don't care about) or compare it (with maybe some adjustments made). But I'd really like to have all that compare/adjust logic in one place if possible.

Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +11 -0
+
+	/* Check if we need to force a modeset */
+	if (!intel_pipe_config_compare(dev, &sw_state, hw_state, true)) {
+		DRM_INFO("[CRTC:%i] sw state incompatible, forcing modeset\n",
+			 crtc->base.base.id);
+		pipe_config->base.mode_changed = true;
+	} else {
+		DRM_INFO("[CRTC:%i] sw state and hw state fastboot compatible\n",
+			 crtc->base.base.id);
+
+		*pipe_config = sw_state;

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15180

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+		intel_dump_pipe_config(crtc, pipe_config,
+				       "[new fastboot state]");
+
+		/* prevent a modeset by patching up mode struct */
+
+		hw_state->base.mode.type = pipe_config->base.mode.type =
+		hw_state->base.adjusted_mode.type = pipe_config->base.adjusted_mode.type;
+
+		/* clock readout can be approximate, just copy it. */
+		hw_state->base.mode.clock = pipe_config->base.mode.clock = pipe_config->base.adjusted_mode.clock;

Why do we still need this? If we use intel_pipe_config_compare to compute mode_changed then we hopefully don't need to hack around things any more. I guess this is where we need your plan to split out connector_changed from mode_changed and then replace the mode_changed computed by the helpers by what intel_pipe_config_compare things is justified.

Quoted 101 lines
drivers/gpu/drm/i915/intel_display.c +14 -31
+	}
+}
+
 static void intel_sanitize_crtc(struct intel_crtc *crtc,
 				struct intel_crtc_state *pipe_config,
 				bool force_restore)
@@ -15135,37 +15220,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc,
 		pipe_config->base.active = !!enable;
 	}
 
-	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE) {
-		if (force_restore || i915.fastboot)
-			pipe_config->base.mode_changed = true;
-		else
-			pipe_config->base.active = false;
-	}
-
-	/* XXX: This is needs to be modified for making fastboot possible
-	 * by default without requiring a modeset.
-	 */
-	if (hw_state->base.active && pipe_config->base.active) {
-		struct intel_crtc_state sw_state;
-
-		memset(&sw_state, 0, sizeof(sw_state));
-		sw_state.base = pipe_config->base;
-		sw_state.scaler_state = pipe_config->scaler_state;
-		sw_state.shared_dpll = pipe_config->shared_dpll;
-		sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
-		sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
-
-		intel_modeset_pipe_config(&crtc->base, &sw_state);
-
-		/* Check if we need to force a modeset */
-		if (!intel_pipe_config_compare(dev, &sw_state, hw_state, !i915.fastboot)) {
-			DRM_DEBUG_KMS("sw and hw state differ, forcing modeset\n");
-			pipe_config->base.mode_changed = true;
-		} else {
-			*pipe_config = sw_state;
-		}
-	}
+	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE)
+		pipe_config->base.mode_changed = true;
 
+	else if (hw_state->base.active && pipe_config->base.active)
+		intel_fastboot_calc_modeset(crtc, hw_state, pipe_config);
 
 	if (dev_priv->quirks & QUIRK_PIPEA_FORCE && !hw_state->base.active &&
 	    crtc->pipe == PIPE_A && !pipe_config->base.active) {
@@ -15584,6 +15643,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		crtc_state->planes_changed = false;
 
 		if (crtc->state->enable) {
+			memset(&crtc->mode, 0, sizeof(crtc->mode));
 			intel_mode_from_pipe_config(&crtc->mode,
 				to_intel_crtc_state(crtc->state));
 			intel_mode_from_pipe_config(&crtc->state->adjusted_mode,
@@ -15678,9 +15738,12 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		int j;
 		struct drm_plane *primary = c->primary;
 
+		if (!c->state->active)
+			continue;
+
 		obj = intel_fb_obj(primary->state->fb);
 		if (obj == NULL)
-			goto disable;
+			continue;
 
 		mutex_lock(&dev->struct_mutex);
 		ret = intel_pin_and_fence_fb_obj(primary, primary->state->fb,
@@ -15715,6 +15778,8 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		 */
 
 disable:
+		DRM_DEBUG_KMS("[CRTC:%i] No fb or forced inactive, disabling.\n",
+			      c->base.id);
 		crtc_state->active = crtc_state->enable = false;
 
 		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
drivers/gpu/drm/i915/intel_fbdev.c +1 -6
index 6ac4990a0c11..2c494d78652a 100644
@@ -486,15 +486,10 @@ retry:
 			 * config, not the input mode, which is what crtc->mode
 			 * usually contains. But since our current fastboot
 			 * code puts a mode derived from the post-pfit timings
-			 * into crtc->mode this works out correctly. We don't
-			 * use hwmode anywhere right now, so use it for this
-			 * since the fb helper layer wants a pointer to
-			 * something we own.
+			 * into crtc->mode this works out correctly.
 			 */
 			DRM_DEBUG_KMS("looking for current mode on connector %s\n",
 				      connector->name);
-			intel_mode_from_pipe_config(&encoder->crtc->hwmode,
-						    to_intel_crtc(encoder->crtc)->config);
 			modes[i] = &encoder->crtc->hwmode;
 		}
 		crtcs[i] = new_crtc;

drivers/gpu/drm/i915/intel_fbdev.c static bool intel_fbdev_init_bios(struct drm_device *dev, · line 588

Quoted 5 lines
drivers/gpu/drm/i915/intel_fbdev.c +0 -2
@@ -584,9 +579,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 	struct intel_crtc *intel_crtc;
 	unsigned int max_size = 0;
 
-	if (!i915.fastboot)
-		return false;

I think it'd be useful to split the fbdev part of the fastboot removal out into a separate patch. Or do I miss a depency here? Assuming ofc that we enable the pfit trick for modesets in general.
-Daniel

Quoted 11 lines
drivers/gpu/drm/i915/intel_fbdev.c +0 -1
-
 	/* Find the largest fb */
 	for_each_crtc(dev, crtc) {
 		struct intel_framebuffer *plane_fb =
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

Re: [RFC PATCH 4/7] drm/i915: enable fastboot for everyone

Op 22-06-15 om 17:21 schreef Daniel Vetter:

Quoted 142 lines · Maarten Lankhorst
Quoted 49 lines

Now that we read out the full atomic state we can force fastboot without hacks. The only thing that we worry about is preventing a modeset. This can be easily done by calculating if sw state matches hw state, with exception for pfit and pipe size. Since the original fastboot code only touched pipe size and panel fitter we keep those, and compare full sw state against hw state.

---
 drivers/gpu/drm/i915/i915_params.c   |   5 -
 drivers/gpu/drm/i915/intel_display.c | 271 ++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_fbdev.c   |  10 +-
 3 files changed, 169 insertions(+), 117 deletions(-)
drivers/gpu/drm/i915/i915_params.c +0 -5
index 8ac5a1b29ac0..9b344a956ba6 100644
@@ -41,7 +41,6 @@ struct i915_params i915 __read_mostly = {
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
 	.enable_ips = 1,
-	.fastboot = 0,
 	.prefault_disable = 0,
 	.load_detect_test = 0,
 	.reset = true,
@@ -137,10 +136,6 @@ MODULE_PARM_DESC(disable_power_well,
 module_param_named(enable_ips, i915.enable_ips, int, 0600);
 MODULE_PARM_DESC(enable_ips, "Enable IPS (default: true)");
 
-module_param_named(fastboot, i915.fastboot, bool, 0600);
-MODULE_PARM_DESC(fastboot,
-	"Try to skip unnecessary mode sets at boot time (default: false)");
-
 module_param_named_unsafe(prefault_disable, i915.prefault_disable, bool, 0600);
 MODULE_PARM_DESC(prefault_disable,
 	"Disable page prefaulting for pread/pwrite/reloc (default:false). "
drivers/gpu/drm/i915/intel_display.c +1 -0
index 9b2acc7b4e29..de975ef09e23 100644
@@ -110,6 +110,7 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr
 static int i9xx_get_refclk(const struct intel_crtc_state *crtc_state,
 			   int num_connectors);
 static void intel_pre_disable_primary(struct drm_crtc *crtc);
+static void skylake_pfit_enable(struct intel_crtc *crtc);
 static struct drm_atomic_state *
 intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore);
 

drivers/gpu/drm/i915/intel_display.c static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) · line 3294

Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +2 -1
@@ -3289,14 +3290,17 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
 	return pending;
 }
 
-static void intel_update_pipe_size(struct intel_crtc *crtc)
+static void intel_update_fastboot(struct intel_crtc *crtc,
+				  struct intel_crtc_state *old_crtc_state)

That's not a useful rename imo - updating pfit/pipe_size clearly tells us what's going on, fastboot is much more a marketing thing really. And I expect that eventually we'll have to grow a lot more update code to fix up fastboot.

Quoted 81 lines
drivers/gpu/drm/i915/intel_display.c +19 -30
 {
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	const struct drm_display_mode *adjusted_mode;
+	struct intel_crtc_state *pipe_config =
+		to_intel_crtc_state(crtc->base.state);
 
-	if (!i915.fastboot)
-		return;
+	DRM_DEBUG_KMS("Applying fastboot quirks, %ix%i -> %ix%i\n",
+		      old_crtc_state->pipe_src_w, old_crtc_state->pipe_src_h,
+		      pipe_config->pipe_src_w, pipe_config->pipe_src_h);
 
 	/*
 	 * Update pipe size and adjust fitter if needed: the reason for this is
@@ -3305,27 +3309,27 @@ static void intel_update_pipe_size(struct intel_crtc *crtc)
 	 * fastboot case, we'll flip, but if we don't update the pipesrc and
 	 * pfit state, we'll end up with a big fb scanned out into the wrong
 	 * sized surface.
-	 *
-	 * To fix this properly, we need to hoist the checks up into
-	 * compute_mode_changes (or above), check the actual pfit state and
-	 * whether the platform allows pfit disable with pipe active, and only
-	 * then update the pipesrc and pfit state, even on the flip path.
 	 */
 
-	adjusted_mode = &crtc->config->base.adjusted_mode;
-
 	I915_WRITE(PIPESRC(crtc->pipe),
-		   ((adjusted_mode->crtc_hdisplay - 1) << 16) |
-		   (adjusted_mode->crtc_vdisplay - 1));
-	if (!crtc->config->pch_pfit.enabled &&
-	    (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) ||
-	     intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) {
+		   ((pipe_config->pipe_src_w - 1) << 16) |
+		   (pipe_config->pipe_src_h - 1));
+
+	/* on skylake this is done by detaching scalers */
+	if (INTEL_INFO(dev)->gen == 9) {
+		skl_detach_scalers(crtc);
+
+		if (pipe_config->pch_pfit.enabled)
+			skylake_pfit_enable(crtc);
+	}
+	else if (!pipe_config->pch_pfit.enabled &&
+	    old_crtc_state->pch_pfit.enabled) {
+		DRM_DEBUG_KMS("Disabling panel fitter\n");
+
 		I915_WRITE(PF_CTL(crtc->pipe), 0);
 		I915_WRITE(PF_WIN_POS(crtc->pipe), 0);
 		I915_WRITE(PF_WIN_SZ(crtc->pipe), 0);
 	}
-	crtc->config->pipe_src_w = adjusted_mode->crtc_hdisplay;
-	crtc->config->pipe_src_h = adjusted_mode->crtc_vdisplay;
 }
 
 static void intel_fdi_normal_train(struct drm_crtc *crtc)
@@ -12244,19 +12248,6 @@ encoder_retry:
 	DRM_DEBUG_KMS("plane bpp: %i, pipe bpp: %i, dithering: %i\n",
 		      base_bpp, pipe_config->pipe_bpp, pipe_config->dither);
 
-	/* Check if we need to force a modeset */
-	if (pipe_config->has_audio !=
-	    to_intel_crtc_state(crtc->state)->has_audio) {
-		pipe_config->base.mode_changed = true;
-		ret = drm_atomic_add_affected_planes(state, crtc);
-	}
-
-	/*
-	 * Note we have an issue here with infoframes: current code
-	 * only updates them on the full mode set path per hw
-	 * requirements.  So here we should be checking for any
-	 * required changes and forcing a mode set.
-	 */
 fail:
 	return ret;
 }
@@ -12500,29 +12491,21 @@ intel_pipe_config_compare(struct drm_device *dev,
 				      DRM_MODE_FLAG_NVSYNC);
 	}
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_display.c intel_pipe_config_compare(struct drm_device *dev, · line 12494

Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +0 -11
-	PIPE_CONF_CHECK_I(pipe_src_w);
-	PIPE_CONF_CHECK_I(pipe_src_h);
-
-	/*
-	 * FIXME: BIOS likes to set up a cloned config with lvds+external
-	 * screen. Since we don't yet re-compute the pipe config when moving
-	 * just the lvds port away to another pipe the sw tracking won't match.
-	 *
-	 * Proper atomic modesets with recomputed global state will fix this.
-	 * Until then just don't check gmch state for inherited modes.
-	 */
 	if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_INHERITED_MODE)) {

This seems like a separate change - with recomputing state on all pipes unconditionally we should be able to drop this?

We repurpose inherited mode here to skip some checks on first boot that will be patched up on first atomic commit.

Quoted 62 lines
Quoted 62 lines
drivers/gpu/drm/i915/intel_display.c +17 -22
-		PIPE_CONF_CHECK_I(gmch_pfit.control);
-		/* pfit ratios are autocomputed by the hw on gen4+ */
-		if (INTEL_INFO(dev)->gen < 4)
-			PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
-		PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
-	}
+		PIPE_CONF_CHECK_I(pipe_src_w);
+		PIPE_CONF_CHECK_I(pipe_src_h);
+
+		PIPE_CONF_CHECK_I(pch_pfit.enabled);
+		if (current_config->pch_pfit.enabled) {
+			PIPE_CONF_CHECK_I(pch_pfit.pos);
+			PIPE_CONF_CHECK_I(pch_pfit.size);
 
-	PIPE_CONF_CHECK_I(pch_pfit.enabled);
-	if (current_config->pch_pfit.enabled) {
-		PIPE_CONF_CHECK_I(pch_pfit.pos);
-		PIPE_CONF_CHECK_I(pch_pfit.size);
+			PIPE_CONF_CHECK_I(gmch_pfit.control);
+			/* pfit ratios are autocomputed by the hw on gen4+ */
+			if (INTEL_INFO(dev)->gen < 4)
+				PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
+			PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
+		}
 	}
 
 	PIPE_CONF_CHECK_I(scaler_state.scaler_id);
@@ -13057,26 +13040,18 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 		return ret;
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!crtc_state->enable) {
-			if (needs_modeset(crtc_state))
-				any_ms = true;
+		if (!needs_modeset(crtc_state))
 			continue;
-		}
 
-		if (!needs_modeset(crtc_state)) {
-			ret = drm_atomic_add_affected_connectors(state, crtc);
-			if (ret)
-				return ret;
-		}
+		any_ms = true;
+		if (!crtc_state->enable)
+			continue;
 
 		ret = intel_modeset_pipe_config(crtc,
 					to_intel_crtc_state(crtc_state));
 		if (ret)
 			return ret;
 
-		if (needs_modeset(crtc_state))
-			any_ms = true;
-
 		intel_dump_pipe_config(to_intel_crtc(crtc),
 				       to_intel_crtc_state(crtc_state),
 				       "[modeset]");
@@ -13147,7 +13122,10 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 		if (needs_modeset(crtc->state) && crtc->state->active) {
 			update_scanline_offset(to_intel_crtc(crtc));
 			dev_priv->display.crtc_enable(crtc);
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_atomic_state *state) · line 13128

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
-		}
+		} else if (to_intel_crtc_state(crtc_state)->quirks &
+			   PIPE_CONFIG_QUIRK_INHERITED_MODE)
+			/* force hw readout check */
+			any_ms = true;

Imo this should be a separate patch since forcing a modeset check after the initial takeover is a good thing. Also maybe do a s/any_ms/do_modeset_checks/ for clarity of what this does.

It's used for other reasons too, like updating power domains when crtc states change. So do_modeset_checks would be misleading.

Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_display.c +2 -6
 		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 	}
@@ -13430,8 +13408,6 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 	if (ret)
 		goto out;
 
-	intel_update_pipe_size(to_intel_crtc(set->crtc));
-
 	ret = intel_set_mode_checked(state);
 	if (ret) {
 		DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
@@ -13718,10 +13694,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	if (state->visible)
-		/* FIXME: kill this fastboot hack */
-		intel_update_pipe_size(intel_crtc);
-
 	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
 }
 
@@ -13741,6 +13713,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_crtc_state *old_intel_state =
+		to_intel_crtc_state(old_crtc_state);
 
 	if (!needs_modeset(crtc->state))
 		intel_pre_plane_update(intel_crtc);
@@ -13756,7 +13730,10 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13735

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
-	if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
+	if (!needs_modeset(crtc->state) && crtc->state->active &&
+	    old_intel_state->quirks & PIPE_CONFIG_QUIRK_INHERITED_MODE)
+		intel_update_fastboot(intel_crtc, old_intel_state);

Nack, fastboot only for the initial mode is not what I want. We should be able to speed up _any_ modeset where we just disable the pfit. Allowing fast pfit removal unconditionally will also allow us to easily test this part of fastboot with an igt, which I'd also like to see.

You're right, but I think because this needs more infrastructure. I only want to convert fastboot at first. For MST we might also need a variant which only performs a pipe modeset, rather than a full modeset. Still there are cases where we will need to force a modeset regardless, for example when device frequency changes.

In either case this probably requires a lot of code may differ on each platform. :(

Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13737

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
+	else if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
 		skl_detach_scalers(intel_crtc);

Also I think it'd be clearer if we have state flags (like for the pageflip stuff) in crtc_state to enable these fixup functions on an as-needed basis.

I think this call should be moved to the plane commit function instead, with a single detach_scaler to disable the relevant scaler, if the scaler's not used afterwards.

fastboot updates would disable it for the crtc, eliminating the need to call it separately.

Quoted 87 lines
Quoted 87 lines
drivers/gpu/drm/i915/intel_display.c +81 -0
 }
 
@@ -15096,6 +15073,114 @@ intel_check_plane_mapping(struct intel_crtc *crtc)
 	return true;
 }
 
+static bool
+intel_compare_m_n(unsigned int m, unsigned int n,
+		  unsigned int m2, unsigned int n2)
+{
+	if (m == m2 && n == n2)
+		return true;
+
+	if (!m || !n || !m2 || !n2)
+		return false;
+
+	if (m > m2) {
+		while (m > m2) {
+			m >>= 1;
+			n >>= 1;
+		}
+	} else if (m < m2) {
+		while (m < m2) {
+			m2 >>= 1;
+			n2 >>= 1;
+		}
+	}
+
+	return m == m2 && n == n2;
+}
+
+static bool
+intel_compare_link_m_n(const struct intel_link_m_n *m_n,
+		       const struct intel_link_m_n *m2_n2)
+{
+	if (m_n->tu == m2_n2->tu &&
+	    intel_compare_m_n(m_n->gmch_m, m_n->gmch_n,
+			      m2_n2->gmch_m, m2_n2->gmch_n) &&
+	    intel_compare_m_n(m_n->link_m, m_n->link_n,
+			      m2_n2->link_m, m2_n2->link_n))
+		return true;
+
+	return false;
+}
+
+static void intel_fastboot_calc_modeset(struct intel_crtc *crtc,
+					struct intel_crtc_state *hw_state,
+					struct intel_crtc_state *pipe_config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct intel_crtc_state sw_state;
+
+	if (needs_modeset(&pipe_config->base)) {
+		DRM_DEBUG_KMS("Skipping fastboot checks, modeset forced\n");
+		return;
+	}
+
+	memset(&sw_state, 0, sizeof(sw_state));
+	sw_state.base = pipe_config->base;
+	sw_state.scaler_state = pipe_config->scaler_state;
+	sw_state.shared_dpll = pipe_config->shared_dpll;
+	sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
+	sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
+	intel_modeset_pipe_config(&crtc->base, &sw_state);
+	sw_state.quirks = hw_state->quirks & PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS;
+
+	if (intel_compare_link_m_n(&sw_state.fdi_m_n, &hw_state->fdi_m_n))
+		sw_state.fdi_m_n = hw_state->fdi_m_n;
+
+	if (INTEL_INFO(dev)->gen < 8) {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n))
+			sw_state.dp_m_n = hw_state->dp_m_n;
+
+		if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+					   &hw_state->dp_m2_n2))
+			sw_state.dp_m2_n2 = hw_state->dp_m2_n2;
+	} else {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n)) {
+			sw_state.dp_m_n = hw_state->dp_m_n;
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		} else if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+						  &hw_state->dp_m_n)) {
+			sw_state.dp_m2_n2 = hw_state->dp_m_n;
+
+			hw_state->dp_m_n = sw_state.dp_m_n;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15159

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		}
+	}

Not too happy with splitting up the modeset state compare code like this. If we add enum mode { EXACT, COMPATIBLE } to intel_pipe_config_compare we could tie things together well and have all the pipe config code grouped in one place. But then the _compare() is a bit misleading since it'd also update the sw_state, so maybe better to call it compare_and_ajust.

Or pass a bool adjust, since checking state after a modeset needs to match exactly, and no adjustment can be done.

Quoted 23 lines

The macros would then either copy the hw_state to sw_state (if it's some intermediate state we don't care about) or compare it (with maybe some adjustments made). But I'd really like to have all that compare/adjust logic in one place if possible.

Quoted 18 lines
drivers/gpu/drm/i915/intel_display.c +18 -0
+
+	/* Check if we need to force a modeset */
+	if (!intel_pipe_config_compare(dev, &sw_state, hw_state, true)) {
+		DRM_INFO("[CRTC:%i] sw state incompatible, forcing modeset\n",
+			 crtc->base.base.id);
+		pipe_config->base.mode_changed = true;
+	} else {
+		DRM_INFO("[CRTC:%i] sw state and hw state fastboot compatible\n",
+			 crtc->base.base.id);
+
+		*pipe_config = sw_state;
+		intel_dump_pipe_config(crtc, pipe_config,
+				       "[new fastboot state]");
+
+		/* prevent a modeset by patching up mode struct */
+
+		hw_state->base.mode.type = pipe_config->base.mode.type =
+		hw_state->base.adjusted_mode.type = pipe_config->base.adjusted_mode.type;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15180

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+
+		/* clock readout can be approximate, just copy it. */
+		hw_state->base.mode.clock = pipe_config->base.mode.clock = pipe_config->base.adjusted_mode.clock;

Why do we still need this? If we use intel_pipe_config_compare to compute mode_changed then we hopefully don't need to hack around things any more. I guess this is where we need your plan to split out connector_changed from mode_changed and then replace the mode_changed computed by the helpers by what intel_pipe_config_compare things is justified.

My display has a slightly different clock and mode->type in edid. Patching this up prevented the modeset. There can also be other reasons for modeset, like CDCLK changes.

Quoted 104 lines
Quoted 104 lines
drivers/gpu/drm/i915/intel_display.c +14 -31
+	}
+}
+
 static void intel_sanitize_crtc(struct intel_crtc *crtc,
 				struct intel_crtc_state *pipe_config,
 				bool force_restore)
@@ -15135,37 +15220,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc,
 		pipe_config->base.active = !!enable;
 	}
 
-	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE) {
-		if (force_restore || i915.fastboot)
-			pipe_config->base.mode_changed = true;
-		else
-			pipe_config->base.active = false;
-	}
-
-	/* XXX: This is needs to be modified for making fastboot possible
-	 * by default without requiring a modeset.
-	 */
-	if (hw_state->base.active && pipe_config->base.active) {
-		struct intel_crtc_state sw_state;
-
-		memset(&sw_state, 0, sizeof(sw_state));
-		sw_state.base = pipe_config->base;
-		sw_state.scaler_state = pipe_config->scaler_state;
-		sw_state.shared_dpll = pipe_config->shared_dpll;
-		sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
-		sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
-
-		intel_modeset_pipe_config(&crtc->base, &sw_state);
-
-		/* Check if we need to force a modeset */
-		if (!intel_pipe_config_compare(dev, &sw_state, hw_state, !i915.fastboot)) {
-			DRM_DEBUG_KMS("sw and hw state differ, forcing modeset\n");
-			pipe_config->base.mode_changed = true;
-		} else {
-			*pipe_config = sw_state;
-		}
-	}
+	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE)
+		pipe_config->base.mode_changed = true;
 
+	else if (hw_state->base.active && pipe_config->base.active)
+		intel_fastboot_calc_modeset(crtc, hw_state, pipe_config);
 
 	if (dev_priv->quirks & QUIRK_PIPEA_FORCE && !hw_state->base.active &&
 	    crtc->pipe == PIPE_A && !pipe_config->base.active) {
@@ -15584,6 +15643,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		crtc_state->planes_changed = false;
 
 		if (crtc->state->enable) {
+			memset(&crtc->mode, 0, sizeof(crtc->mode));
 			intel_mode_from_pipe_config(&crtc->mode,
 				to_intel_crtc_state(crtc->state));
 			intel_mode_from_pipe_config(&crtc->state->adjusted_mode,
@@ -15678,9 +15738,12 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		int j;
 		struct drm_plane *primary = c->primary;
 
+		if (!c->state->active)
+			continue;
+
 		obj = intel_fb_obj(primary->state->fb);
 		if (obj == NULL)
-			goto disable;
+			continue;
 
 		mutex_lock(&dev->struct_mutex);
 		ret = intel_pin_and_fence_fb_obj(primary, primary->state->fb,
@@ -15715,6 +15778,8 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		 */
 
 disable:
+		DRM_DEBUG_KMS("[CRTC:%i] No fb or forced inactive, disabling.\n",
+			      c->base.id);
 		crtc_state->active = crtc_state->enable = false;
 
 		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
drivers/gpu/drm/i915/intel_fbdev.c +1 -6
index 6ac4990a0c11..2c494d78652a 100644
@@ -486,15 +486,10 @@ retry:
 			 * config, not the input mode, which is what crtc->mode
 			 * usually contains. But since our current fastboot
 			 * code puts a mode derived from the post-pfit timings
-			 * into crtc->mode this works out correctly. We don't
-			 * use hwmode anywhere right now, so use it for this
-			 * since the fb helper layer wants a pointer to
-			 * something we own.
+			 * into crtc->mode this works out correctly.
 			 */
 			DRM_DEBUG_KMS("looking for current mode on connector %s\n",
 				      connector->name);
-			intel_mode_from_pipe_config(&encoder->crtc->hwmode,
-						    to_intel_crtc(encoder->crtc)->config);
 			modes[i] = &encoder->crtc->hwmode;
 		}
 		crtcs[i] = new_crtc;
@@ -584,9 +579,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 	struct intel_crtc *intel_crtc;
 	unsigned int max_size = 0;
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_fbdev.c static bool intel_fbdev_init_bios(struct drm_device *dev, · line 588

Quoted 2 lines
drivers/gpu/drm/i915/intel_fbdev.c +0 -2
-	if (!i915.fastboot)
-		return false;

I think it'd be useful to split the fbdev part of the fastboot removal out into a separate patch. Or do I miss a depency here? Assuming ofc that we enable the pfit trick for modesets in general.

I think you did miss a dependency. Not competely sure though..

~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

Re: [RFC PATCH 4/7] drm/i915: enable fastboot for everyone

Quoted 12 lines · Maarten Lankhorst

Op 22-06-15 om 17:21 schreef Daniel Vetter:

Quoted 11 lines

drivers/gpu/drm/i915/intel_display.c intel_pipe_config_compare(struct drm_device *dev, · line 12494

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +0 -8
-	/*
-	 * FIXME: BIOS likes to set up a cloned config with lvds+external
-	 * screen. Since we don't yet re-compute the pipe config when moving
-	 * just the lvds port away to another pipe the sw tracking won't match.
-	 *
-	 * Proper atomic modesets with recomputed global state will fix this.
-	 * Until then just don't check gmch state for inherited modes.
-	 */
 	if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_INHERITED_MODE)) {

This seems like a separate change - with recomputing state on all pipes unconditionally we should be able to drop this?

Quoted 2 lines

We repurpose inherited mode here to skip some checks on first boot that will be patched up on first atomic commit.

Yeah, but since you delete the FIXME comment (I agree that's adressed) there shouldn't be any reason any more for this. If there still is then we need a new comment imo. And we do read out pfit state correctly, so this shouldn't cause any pipe config mismatches on the initial state.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +0 -0
@@ -13147,7 +13122,10 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 		if (needs_modeset(crtc->state) && crtc->state->active) {
 			update_scanline_offset(to_intel_crtc(crtc));
 			dev_priv->display.crtc_enable(crtc);
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int __intel_set_mode(struct drm_atomic_state *state) · line 13128

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +4 -1
-		}
+		} else if (to_intel_crtc_state(crtc_state)->quirks &
+			   PIPE_CONFIG_QUIRK_INHERITED_MODE)
+			/* force hw readout check */
+			any_ms = true;

Imo this should be a separate patch since forcing a modeset check after the initial takeover is a good thing. Also maybe do a s/any_ms/do_modeset_checks/ for clarity of what this does.

Quoted 2 lines

It's used for other reasons too, like updating power domains when crtc states change. So do_modeset_checks would be misleading.

Yeah I got confused reading code since it looks so different. any_ms totally does not what I thought it does, and the name is good as-is.

Quoted 44 lines
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/i915/intel_display.c +2 -6
 		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 	}
@@ -13430,8 +13408,6 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 	if (ret)
 		goto out;
 
-	intel_update_pipe_size(to_intel_crtc(set->crtc));
-
 	ret = intel_set_mode_checked(state);
 	if (ret) {
 		DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
@@ -13718,10 +13694,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	if (!crtc->state->active)
 		return;
 
-	if (state->visible)
-		/* FIXME: kill this fastboot hack */
-		intel_update_pipe_size(intel_crtc);
-
 	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
 }
 
@@ -13741,6 +13713,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_crtc_state *old_intel_state =
+		to_intel_crtc_state(old_crtc_state);
 
 	if (!needs_modeset(crtc->state))
 		intel_pre_plane_update(intel_crtc);
@@ -13756,7 +13730,10 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13735

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +3 -1
-	if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
+	if (!needs_modeset(crtc->state) && crtc->state->active &&
+	    old_intel_state->quirks & PIPE_CONFIG_QUIRK_INHERITED_MODE)
+		intel_update_fastboot(intel_crtc, old_intel_state);

Nack, fastboot only for the initial mode is not what I want. We should be able to speed up _any_ modeset where we just disable the pfit. Allowing fast pfit removal unconditionally will also allow us to easily test this part of fastboot with an igt, which I'd also like to see.

Quoted 6 lines

You're right, but I think because this needs more infrastructure. I only want to convert fastboot at first. For MST we might also need a variant which only performs a pipe modeset, rather than a full modeset. Still there are cases where we will need to force a modeset regardless, for example when device frequency changes.

In either case this probably requires a lot of code may differ on each platform. :(

This isn't about anything else but fastboot: I just want the pfit-disable trick to work on _any_ modeset, since if we don't do that then we can't test it with igt. And that's bad. pfit-disabling really should be orthogonal to any inherited state cleanup, if it's not the good isn't yet ready for prime time imo.

Quoted 9 lines
Quoted 5 lines

drivers/gpu/drm/i915/intel_display.c static void intel_begin_crtc_commit(struct drm_crtc *crtc, · line 13737

Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
+	else if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
 		skl_detach_scalers(intel_crtc);

Also I think it'd be clearer if we have state flags (like for the pageflip stuff) in crtc_state to enable these fixup functions on an as-needed basis.

I think this call should be moved to the plane commit function instead, with a single detach_scaler to disable the relevant scaler, if the scaler's not used afterwards.

fastboot updates would disable it for the crtc, eliminating the need to call it separately.

Yeah that makes sense.

Quoted 96 lines
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/i915/intel_display.c +81 -0
 }
 
@@ -15096,6 +15073,114 @@ intel_check_plane_mapping(struct intel_crtc *crtc)
 	return true;
 }
 
+static bool
+intel_compare_m_n(unsigned int m, unsigned int n,
+		  unsigned int m2, unsigned int n2)
+{
+	if (m == m2 && n == n2)
+		return true;
+
+	if (!m || !n || !m2 || !n2)
+		return false;
+
+	if (m > m2) {
+		while (m > m2) {
+			m >>= 1;
+			n >>= 1;
+		}
+	} else if (m < m2) {
+		while (m < m2) {
+			m2 >>= 1;
+			n2 >>= 1;
+		}
+	}
+
+	return m == m2 && n == n2;
+}
+
+static bool
+intel_compare_link_m_n(const struct intel_link_m_n *m_n,
+		       const struct intel_link_m_n *m2_n2)
+{
+	if (m_n->tu == m2_n2->tu &&
+	    intel_compare_m_n(m_n->gmch_m, m_n->gmch_n,
+			      m2_n2->gmch_m, m2_n2->gmch_n) &&
+	    intel_compare_m_n(m_n->link_m, m_n->link_n,
+			      m2_n2->link_m, m2_n2->link_n))
+		return true;
+
+	return false;
+}
+
+static void intel_fastboot_calc_modeset(struct intel_crtc *crtc,
+					struct intel_crtc_state *hw_state,
+					struct intel_crtc_state *pipe_config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct intel_crtc_state sw_state;
+
+	if (needs_modeset(&pipe_config->base)) {
+		DRM_DEBUG_KMS("Skipping fastboot checks, modeset forced\n");
+		return;
+	}
+
+	memset(&sw_state, 0, sizeof(sw_state));
+	sw_state.base = pipe_config->base;
+	sw_state.scaler_state = pipe_config->scaler_state;
+	sw_state.shared_dpll = pipe_config->shared_dpll;
+	sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
+	sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
+	intel_modeset_pipe_config(&crtc->base, &sw_state);
+	sw_state.quirks = hw_state->quirks & PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS;
+
+	if (intel_compare_link_m_n(&sw_state.fdi_m_n, &hw_state->fdi_m_n))
+		sw_state.fdi_m_n = hw_state->fdi_m_n;
+
+	if (INTEL_INFO(dev)->gen < 8) {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n))
+			sw_state.dp_m_n = hw_state->dp_m_n;
+
+		if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+					   &hw_state->dp_m2_n2))
+			sw_state.dp_m2_n2 = hw_state->dp_m2_n2;
+	} else {
+		if (intel_compare_link_m_n(&sw_state.dp_m_n,
+					   &hw_state->dp_m_n)) {
+			sw_state.dp_m_n = hw_state->dp_m_n;
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		} else if (intel_compare_link_m_n(&sw_state.dp_m2_n2,
+						  &hw_state->dp_m_n)) {
+			sw_state.dp_m2_n2 = hw_state->dp_m_n;
+
+			hw_state->dp_m_n = sw_state.dp_m_n;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15159

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+			hw_state->dp_m2_n2 = sw_state.dp_m2_n2;
+		}
+	}

Not too happy with splitting up the modeset state compare code like this. If we add enum mode { EXACT, COMPATIBLE } to intel_pipe_config_compare we could tie things together well and have all the pipe config code grouped in one place. But then the _compare() is a bit misleading since it'd also update the sw_state, so maybe better to call it compare_and_ajust.

Quoted 2 lines

Or pass a bool adjust, since checking state after a modeset needs to match exactly, and no adjustment can be done.

Yeah adjust is a better name. The point behind the enum is that if you have a pile of bool arguments it's hard to know without looking at the function what's going on. With enums you can go with self-descriptive names. We're not doing this yet everywhere, but as a rule I'd like to see it if there's more than one bool in the arg list.

Quoted 31 lines
Quoted 23 lines

The macros would then either copy the hw_state to sw_state (if it's some intermediate state we don't care about) or compare it (with maybe some adjustments made). But I'd really like to have all that compare/adjust logic in one place if possible.

Quoted 18 lines
drivers/gpu/drm/i915/intel_display.c +18 -0
+
+	/* Check if we need to force a modeset */
+	if (!intel_pipe_config_compare(dev, &sw_state, hw_state, true)) {
+		DRM_INFO("[CRTC:%i] sw state incompatible, forcing modeset\n",
+			 crtc->base.base.id);
+		pipe_config->base.mode_changed = true;
+	} else {
+		DRM_INFO("[CRTC:%i] sw state and hw state fastboot compatible\n",
+			 crtc->base.base.id);
+
+		*pipe_config = sw_state;
+		intel_dump_pipe_config(crtc, pipe_config,
+				       "[new fastboot state]");
+
+		/* prevent a modeset by patching up mode struct */
+
+		hw_state->base.mode.type = pipe_config->base.mode.type =
+		hw_state->base.adjusted_mode.type = pipe_config->base.adjusted_mode.type;
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c intel_check_plane_mapping(struct intel_crtc *crtc) · line 15180

Quoted 3 lines
drivers/gpu/drm/i915/intel_display.c +3 -0
+
+		/* clock readout can be approximate, just copy it. */
+		hw_state->base.mode.clock = pipe_config->base.mode.clock = pipe_config->base.adjusted_mode.clock;

Why do we still need this? If we use intel_pipe_config_compare to compute mode_changed then we hopefully don't need to hack around things any more. I guess this is where we need your plan to split out connector_changed from mode_changed and then replace the mode_changed computed by the helpers by what intel_pipe_config_compare things is justified.

Quoted 2 lines

My display has a slightly different clock and mode->type in edid. Patching this up prevented the modeset. There can also be other reasons for modeset, like CDCLK changes.

Yeah I know we need to patch this up, but we should patch up the requested mode. Instead allowing some slight mismatches in the adjusted mode (and copying over the dpll state if that's the case) should be all that's needed.

Maybe helpers should also look at adjusted modes instead of requested modes? Would be a big change, but I think it makes sense in general - adjusted_mode is the one the crtc is supposed to output. That would also help with handling pfit changes correctly in i915.

Quoted 105 lines
Quoted 105 lines
Quoted 105 lines
drivers/gpu/drm/i915/intel_display.c +14 -31
+	}
+}
+
 static void intel_sanitize_crtc(struct intel_crtc *crtc,
 				struct intel_crtc_state *pipe_config,
 				bool force_restore)
@@ -15135,37 +15220,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc,
 		pipe_config->base.active = !!enable;
 	}
 
-	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE) {
-		if (force_restore || i915.fastboot)
-			pipe_config->base.mode_changed = true;
-		else
-			pipe_config->base.active = false;
-	}
-
-	/* XXX: This is needs to be modified for making fastboot possible
-	 * by default without requiring a modeset.
-	 */
-	if (hw_state->base.active && pipe_config->base.active) {
-		struct intel_crtc_state sw_state;
-
-		memset(&sw_state, 0, sizeof(sw_state));
-		sw_state.base = pipe_config->base;
-		sw_state.scaler_state = pipe_config->scaler_state;
-		sw_state.shared_dpll = pipe_config->shared_dpll;
-		sw_state.dpll_hw_state = pipe_config->dpll_hw_state;
-		sw_state.ddi_pll_sel = pipe_config->ddi_pll_sel;
-
-		intel_modeset_pipe_config(&crtc->base, &sw_state);
-
-		/* Check if we need to force a modeset */
-		if (!intel_pipe_config_compare(dev, &sw_state, hw_state, !i915.fastboot)) {
-			DRM_DEBUG_KMS("sw and hw state differ, forcing modeset\n");
-			pipe_config->base.mode_changed = true;
-		} else {
-			*pipe_config = sw_state;
-		}
-	}
+	if (hw_state->quirks & PIPE_CONFIG_QUIRK_WRONG_PLANE)
+		pipe_config->base.mode_changed = true;
 
+	else if (hw_state->base.active && pipe_config->base.active)
+		intel_fastboot_calc_modeset(crtc, hw_state, pipe_config);
 
 	if (dev_priv->quirks & QUIRK_PIPEA_FORCE && !hw_state->base.active &&
 	    crtc->pipe == PIPE_A && !pipe_config->base.active) {
@@ -15584,6 +15643,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		crtc_state->planes_changed = false;
 
 		if (crtc->state->enable) {
+			memset(&crtc->mode, 0, sizeof(crtc->mode));
 			intel_mode_from_pipe_config(&crtc->mode,
 				to_intel_crtc_state(crtc->state));
 			intel_mode_from_pipe_config(&crtc->state->adjusted_mode,
@@ -15678,9 +15738,12 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		int j;
 		struct drm_plane *primary = c->primary;
 
+		if (!c->state->active)
+			continue;
+
 		obj = intel_fb_obj(primary->state->fb);
 		if (obj == NULL)
-			goto disable;
+			continue;
 
 		mutex_lock(&dev->struct_mutex);
 		ret = intel_pin_and_fence_fb_obj(primary, primary->state->fb,
@@ -15715,6 +15778,8 @@ void intel_modeset_gem_init(struct drm_device *dev, struct drm_atomic_state *sta
 		 */
 
 disable:
+		DRM_DEBUG_KMS("[CRTC:%i] No fb or forced inactive, disabling.\n",
+			      c->base.id);
 		crtc_state->active = crtc_state->enable = false;
 
 		ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
drivers/gpu/drm/i915/intel_fbdev.c +1 -6
index 6ac4990a0c11..2c494d78652a 100644
@@ -486,15 +486,10 @@ retry:
 			 * config, not the input mode, which is what crtc->mode
 			 * usually contains. But since our current fastboot
 			 * code puts a mode derived from the post-pfit timings
-			 * into crtc->mode this works out correctly. We don't
-			 * use hwmode anywhere right now, so use it for this
-			 * since the fb helper layer wants a pointer to
-			 * something we own.
+			 * into crtc->mode this works out correctly.
 			 */
 			DRM_DEBUG_KMS("looking for current mode on connector %s\n",
 				      connector->name);
-			intel_mode_from_pipe_config(&encoder->crtc->hwmode,
-						    to_intel_crtc(encoder->crtc)->config);
 			modes[i] = &encoder->crtc->hwmode;
 		}
 		crtcs[i] = new_crtc;
@@ -584,9 +579,6 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
 	struct intel_crtc *intel_crtc;
 	unsigned int max_size = 0;
 
Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/i915/intel_fbdev.c static bool intel_fbdev_init_bios(struct drm_device *dev, · line 588

Quoted 2 lines
drivers/gpu/drm/i915/intel_fbdev.c +0 -2
-	if (!i915.fastboot)
-		return false;

I think it'd be useful to split the fbdev part of the fastboot removal out into a separate patch. Or do I miss a depency here? Assuming ofc that we enable the pfit trick for modesets in general.

I think you did miss a dependency. Not competely sure though..

Well yeah that's likely, but since I didn't see it you need to help me out ;-)
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

RFC PATCH 5/7 drm/i915: Update power domains only on affected crtc's.

In reply to Maarten Lankhorst

Use for_each_crtc_state to only touch affected crtc's. In order to make sure that the initial power is still set correctly we make sure modeset_update_crtc_power_domains is called during the initial modeset.

---
 drivers/gpu/drm/i915/intel_display.c | 44 ++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/intel_display.c +29 -15
index de975ef09e23..942d25e7490a 100644
@@ -5197,30 +5197,35 @@ static unsigned long get_crtc_power_domains(struct drm_crtc *crtc)
 	return mask;
 }
 
-static void modeset_update_crtc_power_domains(struct drm_atomic_state *state)
+static void modeset_update_crtc_power_domains(struct drm_atomic_state *state,
+					      bool power_only)
 {
 	struct drm_device *dev = state->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, };
-	struct intel_crtc *crtc;
+	unsigned long pipe_domains[I915_MAX_PIPES] = { 0, }, domains;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int i;
 
 	/*
 	 * First get all needed power domains, then put all unneeded, to avoid
 	 * any unnecessary toggling of the power wells.
 	 */
-	for_each_intel_crtc(dev, crtc) {
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
 		enum intel_display_power_domain domain;
+		enum pipe pipe = to_intel_crtc(crtc)->pipe;
 
-		if (!crtc->base.state->enable)
+		if (!crtc->state->active)
 			continue;
 
-		pipe_domains[crtc->pipe] = get_crtc_power_domains(&crtc->base);
+		domains = pipe_domains[pipe] = get_crtc_power_domains(crtc);
+		domains &= ~to_intel_crtc(crtc)->enabled_power_domains;
 
-		for_each_power_domain(domain, pipe_domains[crtc->pipe])
+		for_each_power_domain(domain, domains)
 			intel_display_power_get(dev_priv, domain);
 	}
 
-	if (dev_priv->display.modeset_commit_cdclk) {
+	if (!power_only && dev_priv->display.modeset_commit_cdclk) {
 		unsigned int cdclk = to_intel_atomic_state(state)->cdclk;
 
 		if (cdclk != dev_priv->cdclk_freq &&
@@ -5228,16 +5233,19 @@ static void modeset_update_crtc_power_domains(struct drm_atomic_state *state)
 			dev_priv->display.modeset_commit_cdclk(state);
 	}
 
-	for_each_intel_crtc(dev, crtc) {
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+		enum pipe pipe = intel_crtc->pipe;
 		enum intel_display_power_domain domain;
 
-		for_each_power_domain(domain, crtc->enabled_power_domains)
-			intel_display_power_put(dev_priv, domain);
+		domains = intel_crtc->enabled_power_domains;
+		domains &= ~pipe_domains[pipe];
 
-		crtc->enabled_power_domains = pipe_domains[crtc->pipe];
-	}
+		intel_crtc->enabled_power_domains = pipe_domains[pipe];
 
-	intel_display_set_init_power(dev_priv, false);
+		for_each_power_domain(domain, domains)
+			intel_display_power_put(dev_priv, domain);
+	}
 }
 
 static void intel_update_max_cdclk(struct drm_device *dev)
@@ -13115,7 +13123,7 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 	/* The state has been swaped above, so state actually contains the
 	 * old state now. */
 	if (any_ms)
-		modeset_update_crtc_power_domains(state);
+		modeset_update_crtc_power_domains(state, false);
 
 	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
@@ -15606,6 +15614,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		return NULL;
 	}
 
+	/* swap sw/hw state */
 	drm_atomic_helper_swap_state(dev, state);
 
 	if (force_restore) {
@@ -15619,6 +15628,9 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		to_intel_atomic_state(state)->dpll_set = false;
 	}
 
+	/* update power state to match hw state */
+	modeset_update_crtc_power_domains(state, true);
+
 	/* HW state is read out, now we need to sanitize this mess. */
 	for_each_intel_encoder(dev, encoder) {
 		intel_sanitize_encoder(encoder);
@@ -15697,6 +15709,8 @@ intel_modeset_setup_hw_state(struct drm_device *dev, bool force_restore)
 		drm_atomic_state_free(state);
 	}
 
+	intel_display_set_init_power(dev_priv, false);
+
 	intel_modeset_check_state(dev);
 	return NULL;
 }
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

RFC PATCH 6/7 drm/i915: Always reset in intel_crtc_restore_mode

In reply to Maarten Lankhorst

And get rid of things that are no longer true. This function is only used for forcing a modeset when encoder properties are changed.

All the existing state is fine in this case, only setting mode_changed will force a full recalculation here, and take all the state needed.

---
 drivers/gpu/drm/i915/intel_display.c | 62 +++++++++++-------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/gpu/drm/i915/intel_display.c +18 -44
index 942d25e7490a..796d08c4606e 100644
@@ -13174,66 +13174,40 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_atomic_state *state;
-	struct intel_crtc *intel_crtc;
-	struct intel_encoder *encoder;
-	struct intel_connector *connector;
-	struct drm_connector_state *connector_state;
-	struct intel_crtc_state *crtc_state;
+	struct drm_crtc_state *crtc_state;
 	int ret;
 
 	state = drm_atomic_state_alloc(dev);
 	if (!state) {
-		DRM_DEBUG_KMS("[CRTC:%d] mode restore failed, out of memory",
+		DRM_DEBUG_KMS("[CRTC:%d] crtc restore failed, out of memory",
 			      crtc->base.id);
 		return;
 	}
 
-	state->acquire_ctx = dev->mode_config.acquire_ctx;
-
-	/* The force restore path in the HW readout code relies on the staged
-	 * config still keeping the user requested config while the actual
-	 * state has been overwritten by the configuration read from HW. We
-	 * need to copy the staged config to the atomic state, otherwise the
-	 * mode set will just reapply the state the HW is already in. */
-	for_each_intel_encoder(dev, encoder) {
-		if (encoder->base.crtc != crtc)
-			continue;
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
 
-		for_each_intel_connector(dev, connector) {
-			if (connector->base.state->best_encoder != &encoder->base)
-				continue;
-
-			connector_state = drm_atomic_get_connector_state(state, &connector->base);
-			if (IS_ERR(connector_state)) {
-				DRM_DEBUG_KMS("Failed to add [CONNECTOR:%d:%s] to state: %ld\n",
-					      connector->base.base.id,
-					      connector->base.name,
-					      PTR_ERR(connector_state));
-				continue;
-			}
+retry:
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	ret = PTR_ERR_OR_ZERO(crtc_state);
+	if (!ret) {
+		if (!crtc_state->active)
+			goto out;
 
-			connector_state->crtc = crtc;
-		}
+		crtc_state->mode_changed = true;
+		ret = intel_modeset_compute_config(state);
 	}
 
-	for_each_intel_crtc(dev, intel_crtc) {
-		crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
-		if (IS_ERR(crtc_state)) {
-			DRM_DEBUG_KMS("Failed to add [CRTC:%d] to state: %ld\n",
-				      intel_crtc->base.base.id,
-				      PTR_ERR(crtc_state));
-			continue;
-		}
+	if (!ret)
+		ret = intel_set_mode_checked(state);
 
-		if (&intel_crtc->base == crtc)
-			drm_mode_copy(&crtc_state->base.mode, &crtc->mode);
+	if (ret == -EDEADLK) {
+		drm_atomic_state_clear(state);
+		drm_modeset_backoff(state->acquire_ctx);
+		goto retry;
 	}
 
-	intel_modeset_setup_plane_state(state, crtc, &crtc->mode,
-					crtc->primary->fb, crtc->x, crtc->y);
-
-	ret = intel_set_mode(state);
 	if (ret)
+out:
 		drm_atomic_state_free(state);
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [RFC PATCH 6/7] drm/i915: Always reset in intel_crtc_restore_mode

Quoted 7 lines · Maarten Lankhorst

And get rid of things that are no longer true. This function is only used for forcing a modeset when encoder properties are changed.

All the existing state is fine in this case, only setting mode_changed will force a full recalculation here, and take all the state needed.

Just to make sure we're aligned here on future work: When we start converting over connector props we simply need to push the ->mode_changed (or well perhaps better crtc_state->connector_changed) update if there's anything to do into the connector's atomic_set_prop callback.

But I guess for a lot of state it's actually better to not do that, and rely upon intel_pipe_config_compare to figure things out for us. That means we must run pretty much all the modeset compute_config code unconditionally, but I think that has a clear advantage of reducing duplicated state comparisons.

I don't expect we'll ever get rid of this one since of Old Crap encoders/connectores (dvo, sdvo, tv, ...) we'll likely never convert the props to atomic properly.
-Daniel

Quoted 100 lines
---
 drivers/gpu/drm/i915/intel_display.c | 62 +++++++++++-------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/gpu/drm/i915/intel_display.c +18 -44
index 942d25e7490a..796d08c4606e 100644
@@ -13174,66 +13174,40 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_atomic_state *state;
-	struct intel_crtc *intel_crtc;
-	struct intel_encoder *encoder;
-	struct intel_connector *connector;
-	struct drm_connector_state *connector_state;
-	struct intel_crtc_state *crtc_state;
+	struct drm_crtc_state *crtc_state;
 	int ret;
 
 	state = drm_atomic_state_alloc(dev);
 	if (!state) {
-		DRM_DEBUG_KMS("[CRTC:%d] mode restore failed, out of memory",
+		DRM_DEBUG_KMS("[CRTC:%d] crtc restore failed, out of memory",
 			      crtc->base.id);
 		return;
 	}
 
-	state->acquire_ctx = dev->mode_config.acquire_ctx;
-
-	/* The force restore path in the HW readout code relies on the staged
-	 * config still keeping the user requested config while the actual
-	 * state has been overwritten by the configuration read from HW. We
-	 * need to copy the staged config to the atomic state, otherwise the
-	 * mode set will just reapply the state the HW is already in. */
-	for_each_intel_encoder(dev, encoder) {
-		if (encoder->base.crtc != crtc)
-			continue;
+	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
 
-		for_each_intel_connector(dev, connector) {
-			if (connector->base.state->best_encoder != &encoder->base)
-				continue;
-
-			connector_state = drm_atomic_get_connector_state(state, &connector->base);
-			if (IS_ERR(connector_state)) {
-				DRM_DEBUG_KMS("Failed to add [CONNECTOR:%d:%s] to state: %ld\n",
-					      connector->base.base.id,
-					      connector->base.name,
-					      PTR_ERR(connector_state));
-				continue;
-			}
+retry:
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	ret = PTR_ERR_OR_ZERO(crtc_state);
+	if (!ret) {
+		if (!crtc_state->active)
+			goto out;
 
-			connector_state->crtc = crtc;
-		}
+		crtc_state->mode_changed = true;
+		ret = intel_modeset_compute_config(state);
 	}
 
-	for_each_intel_crtc(dev, intel_crtc) {
-		crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
-		if (IS_ERR(crtc_state)) {
-			DRM_DEBUG_KMS("Failed to add [CRTC:%d] to state: %ld\n",
-				      intel_crtc->base.base.id,
-				      PTR_ERR(crtc_state));
-			continue;
-		}
+	if (!ret)
+		ret = intel_set_mode_checked(state);
 
-		if (&intel_crtc->base == crtc)
-			drm_mode_copy(&crtc_state->base.mode, &crtc->mode);
+	if (ret == -EDEADLK) {
+		drm_atomic_state_clear(state);
+		drm_modeset_backoff(state->acquire_ctx);
+		goto retry;
 	}
 
-	intel_modeset_setup_plane_state(state, crtc, &crtc->mode,
-					crtc->primary->fb, crtc->x, crtc->y);
-
-	ret = intel_set_mode(state);
 	if (ret)
+out:
 		drm_atomic_state_free(state);
 }
 
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

RFC PATCH 7/7 drm/i915: Make intel_display_suspend atomic, try 2.

In reply to Maarten Lankhorst

Calculate all state using a normal transition, but afterwards fudge crtc->state->active back to its old value. This should still allow state restore in setup_hw_state to work properly.

---
 drivers/gpu/drm/i915/intel_display.c | 74 +++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_drv.h     |  2 +-
 2 files changed, 49 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/intel_display.c +48 -26
index 796d08c4606e..9c25b080260c 100644
@@ -6175,40 +6175,62 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 		intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
 }
 
-static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
+/*
+ * turn all crtc's off, but do not adjust state
+ * This has to be paired with a call to intel_modeset_setup_hw_state.
+ */
+int intel_display_suspend(struct drm_device *dev)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct drm_i915_private *dev_priv = to_i915(crtc->dev);
-	enum intel_display_power_domain domain;
-	unsigned long domains;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc *crtc;
+	unsigned crtc_mask = 0;
+	int ret = 0;
 
-	if (!intel_crtc->active)
-		return;
+	if (WARN_ON(!ctx))
+		return 0;
 
-	if (to_intel_plane_state(crtc->primary->state)->visible) {
-		intel_crtc_wait_for_pending_flips(crtc);
-		intel_pre_disable_primary(crtc);
+	lockdep_assert_held(&ctx->ww_ctx);
+	state = drm_atomic_state_alloc(dev);
+	if (WARN_ON(!state))
+		return -ENOMEM;
+
+	state->acquire_ctx = ctx;
+	state->allow_modeset = true;
+
+	for_each_crtc(dev, crtc) {
+		struct drm_crtc_state *crtc_state =
+			drm_atomic_get_crtc_state(state, crtc);
+
+		ret = PTR_ERR_OR_ZERO(crtc_state);
+		if (ret)
+			goto free;
+
+		if (!crtc_state->active)
+			continue;
+
+		crtc_state->active = false;
+		crtc_mask |= 1 << drm_crtc_index(crtc);
 	}
 
-	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
-	dev_priv->display.crtc_disable(crtc);
+	if (crtc_mask) {
+		ret = intel_set_mode(state);
 
-	domains = intel_crtc->enabled_power_domains;
-	for_each_power_domain(domain, domains)
-		intel_display_power_put(dev_priv, domain);
-	intel_crtc->enabled_power_domains = 0;
-}
+		if (!ret) {
+			for_each_crtc(dev, crtc)
+				if (crtc_mask & (1 << drm_crtc_index(crtc)))
+					crtc->state->active = true;
 
-/*
- * turn all crtc's off, but do not adjust state
- * This has to be paired with a call to intel_modeset_setup_hw_state.
- */
-void intel_display_suspend(struct drm_device *dev)
-{
-	struct drm_crtc *crtc;
+			return ret;
+		}
+	}
 
-	for_each_crtc(dev, crtc)
-		intel_crtc_disable_noatomic(crtc);
+free:
+	if (ret)
+		DRM_ERROR("Suspending crtc's failed with %i\n", ret);
+	drm_atomic_state_free(state);
+	return ret;
 }
 
 void intel_display_resume(struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -1
index ea380b83eb5d..fb6c88ade842 100644
@@ -992,7 +992,7 @@ int intel_pch_rawclk(struct drm_device *dev);
 void intel_mark_busy(struct drm_device *dev);
 void intel_mark_idle(struct drm_device *dev);
 void intel_crtc_restore_mode(struct drm_crtc *crtc);
-void intel_display_suspend(struct drm_device *dev);
+int intel_display_suspend(struct drm_device *dev);
 int intel_crtc_control(struct drm_crtc *crtc, bool enable);
 void intel_crtc_update_dpms(struct drm_crtc *crtc);
 void intel_encoder_destroy(struct drm_encoder *encoder);
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw
In reply to Maarten Lankhorst
Quoted 5 lines · Maarten Lankhorst

The only thing missing after part 3 is restoring atomic readout and making suspend/restore. With fixes for all identified causes of regressions from atomic suspend being done in convert to atomic, part 3 it's time to worry about getting atomic suspend/restore working again.

Quoted 8 lines

I do this in a few steps, first I re-introduce the old commit for hw state readout, with fixes. After that I convert the atomic readout to a full initial modeset, and finally I try to re-enable fastboot optimizations again by default, in a less hacky way.

This is a RFC because of the following possible issues:
- mode->clock may not be read out correctly. It can differ slightly from the actually set value, which forces a modeset anyway when it could be avoided.

We shouldn't look at mode->clock but instead at the adjusted mode. And I guess for that one we should reshuffle the code to put the computed clock with the actual dp hw settings in there. Plus add it to the hw state readout logic and require an exact match.

Or we need to allow a slight mismatch (really just slight) when deciding whether to modeset or not.

Quoted 1 line

- Not tested with DRRS support on DP, might be broken with fastboot?

There's hw state readout and cross-checking for this, you should get yelled at if this happens. I guess we'll eventually grow a pretty big list of fixup code that we need to run after the crtc is enabled. -Daniel

Quoted 29 lines

Maarten Lankhorst (7):
drm/i915: Do not update pfit state when toggling crtc enabled. drm/i915: Read hw state into an atomic state struct, try 2. All changes from try2.
drm/i915: enable fastboot for everyone
drm/i915: Update power domains only on affected crtc's. drm/i915: Always reset in intel_crtc_restore_mode drm/i915: Make intel_display_suspend atomic, try 2.

 drivers/gpu/drm/i915/i915_dma.c      |   12 +-
 drivers/gpu/drm/i915/i915_drv.c      |    2 +-
 drivers/gpu/drm/i915/i915_drv.h      |    7 +-
 drivers/gpu/drm/i915/i915_params.c   |    5 -
 drivers/gpu/drm/i915/intel_atomic.c  |   23 +-
 drivers/gpu/drm/i915/intel_display.c | 1302 ++++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dp.c      |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |   21 +-
 drivers/gpu/drm/i915/intel_fbdev.c   |   22 +-
 drivers/gpu/drm/i915/intel_lvds.c    |    2 +-
 10 files changed, 786 insertions(+), 612 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx