Skip to contentSkip to conversation

drm/i915: Run psr_setup unconditionally

PATCH In review Rodrigo Vivi 3 participants 23 messages Jul 12, 2014 – Jul 13, 2014

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/11 drm/i915: Run psr_setup unconditionally

From: Daniel Vetter <[email protected]>

Due to runtime pm and system s/r we need to restore hw state every time we enable a pipe again. Hence trying to avoid that is just pointless book-keeping which Rodrigo then tried to work around by manually adding psr_setup calls to our resume code.

Much simpler to just remove code instead.

v2: Properly bail out of psr exit if psr isn't enabled. Spotted by Rodrigo.

---
 drivers/gpu/drm/i915/i915_drv.h | 1 -
 drivers/gpu/drm/i915/intel_dp.c | 7 +------
 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index a89c912..91f137f 100644
@@ -657,7 +657,6 @@ struct i915_drrs {
 struct i915_psr {
 	bool sink_support;
 	bool source_ok;
-	bool setup_done;
 	bool enabled;
 	bool active;
 	struct delayed_work work;
drivers/gpu/drm/i915/intel_dp.c +1 -6
index ae3737c..302cdaa 100644
@@ -1714,9 +1714,6 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct edp_vsc_psr psr_vsc;
 
-	if (dev_priv->psr.setup_done)
-		return;
-
 	/* Prepare VSC packet as per EDP 1.3 spec, Table 3.10 */
 	memset(&psr_vsc, 0, sizeof(psr_vsc));
 	psr_vsc.sdp_header.HB0 = 0;
@@ -1728,8 +1725,6 @@ static void intel_edp_psr_setup(struct intel_dp *intel_dp)
 	/* Avoid continuous PSR exit by masking memup and hpd */
 	I915_WRITE(EDP_PSR_DEBUG_CTL(dev), EDP_PSR_DEBUG_MASK_MEMUP |
 		   EDP_PSR_DEBUG_MASK_HPD | EDP_PSR_DEBUG_MASK_LPSP);
-
-	dev_priv->psr.setup_done = true;
 }
 
 static void intel_edp_psr_enable_sink(struct intel_dp *intel_dp)
@@ -1961,7 +1956,7 @@ void intel_edp_psr_exit(struct drm_device *dev)
 	if (!HAS_PSR(dev))
 		return;
 
-	if (!dev_priv->psr.setup_done)
+	if (!dev_priv->psr.enabled)
 		return;
 
 	cancel_delayed_work_sync(&dev_priv->psr.work);
Signature · 1 line
1.9.3
author maintainer
#1 lore raw

PATCH 2/11 drm/i915: Add a FIXME about drrs/psr interactions

From: Daniel Vetter <[email protected]>

Can't review this right now due to lack of DRRS code.

---
 drivers/gpu/drm/i915/intel_dp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_dp.c +5 -0
index 302cdaa..cb57494 100644
@@ -4141,6 +4141,11 @@ void intel_dp_set_drrs_state(struct drm_device *dev, int refresh_rate)
 		return;
 	}
 
+	/*
+	 * FIXME: This needs proper synchronization with psr state. But really
+	 * hard to tell without seeing the user of this function of this code.
+	 * Check locking and ordering once that lands.
+	 */
 	if (INTEL_INFO(dev)->gen < 8 && intel_edp_is_psr_enabled(dev)) {
 		DRM_DEBUG_KMS("DRRS is disabled as PSR is enabled\n");
 		return;
Signature · 1 line
1.9.3
author maintainer
#2 lore raw

PATCH 3/11 drm/i915: Track the psr dp connector in dev_priv->psr.enabled

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

Trying to fish that one out through looping is a bit a locking nightmare. So just set it and use it in the work struct.

v2:
- Don't Oops in psr_work, spotted by Rodrigo.
- Fix compile warning.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  2 +-
 drivers/gpu/drm/i915/i915_drv.h     |  3 ++-
 drivers/gpu/drm/i915/intel_dp.c     | 22 +++++++++-------------
 3 files changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 981ca42..62ea619 100644
@@ -1894,7 +1894,7 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 
 	seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
 	seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
-	seq_printf(m, "Enabled: %s\n", yesno(dev_priv->psr.enabled));
+	seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
 	seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
 
 	enabled = HAS_PSR(dev) &&
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 91f137f..1ec4d4a 100644
@@ -654,10 +654,11 @@ struct i915_drrs {
 	struct intel_connector *connector;
 };
 
+struct intel_dp;
 struct i915_psr {
 	bool sink_support;
 	bool source_ok;
-	bool enabled;
+	struct intel_dp *enabled;
 	bool active;
 	struct delayed_work work;
 };
drivers/gpu/drm/i915/intel_dp.c +9 -13
index cb57494..a07d192 100644
@@ -1876,7 +1876,7 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp)
 	/* Enable PSR on the host */
 	intel_edp_psr_enable_source(intel_dp);
 
-	dev_priv->psr.enabled = true;
+	dev_priv->psr.enabled = intel_dp;
 	dev_priv->psr.active = true;
 }
 
@@ -1917,26 +1917,22 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)
 		       EDP_PSR_STATUS_STATE_MASK) == 0, 2000, 10))
 		DRM_ERROR("Timed out waiting for PSR Idle State\n");
 
-	dev_priv->psr.enabled = false;
+	dev_priv->psr.enabled = NULL;
 }
 
 static void intel_edp_psr_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
 		container_of(work, typeof(*dev_priv), psr.work.work);
-	struct drm_device *dev = dev_priv->dev;
-	struct intel_encoder *encoder;
-	struct intel_dp *intel_dp = NULL;
+	struct intel_dp *intel_dp = dev_priv->psr.enabled;
 
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head)
-		if (encoder->type == INTEL_OUTPUT_EDP) {
-			intel_dp = enc_to_intel_dp(&encoder->base);
+	if (!intel_dp)
+		return;
 
-			if (!intel_edp_psr_match_conditions(intel_dp))
-				intel_edp_psr_disable(intel_dp);
-			else
-				intel_edp_psr_do_enable(intel_dp);
-		}
+	if (!intel_edp_psr_match_conditions(intel_dp))
+		intel_edp_psr_disable(intel_dp);
+	else
+		intel_edp_psr_do_enable(intel_dp);
 }
 
 static void intel_edp_psr_inactivate(struct drm_device *dev)
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH 4/11 drm/i915: Don't try to disable psr harder from the work item

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

It's disabled already except when we've raced.

---
 drivers/gpu/drm/i915/intel_dp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +1 -3
index a07d192..bc3a2a4 100644
@@ -1929,9 +1929,7 @@ static void intel_edp_psr_work(struct work_struct *work)
 	if (!intel_dp)
 		return;
 
-	if (!intel_edp_psr_match_conditions(intel_dp))
-		intel_edp_psr_disable(intel_dp);
-	else
+	if (intel_edp_psr_match_conditions(intel_dp))
 		intel_edp_psr_do_enable(intel_dp);
 }
 
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH 5/11 drm/i915: Lock down psr sw/hw state tracking

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

Make sure we track the sw side (psr.active) correctly and WARN everywhere it might get out of sync with the hw.

v2: Fixup WARN_ON logic inversion, reported by Rodrigo.

---
 drivers/gpu/drm/i915/intel_dp.c | 43 ++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +23 -20
index bc3a2a4..b4e4bdc 100644
@@ -1867,8 +1867,8 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp)
 	struct drm_device *dev = intel_dig_port->base.base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	if (intel_edp_is_psr_enabled(dev))
-		return;
+	WARN_ON(I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE);
+	WARN_ON(dev_priv->psr.active);
 
 	/* Enable PSR on the panel */
 	intel_edp_psr_enable_sink(intel_dp);
@@ -1909,13 +1909,19 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)
 	if (!dev_priv->psr.enabled)
 		return;
 
-	I915_WRITE(EDP_PSR_CTL(dev),
-		   I915_READ(EDP_PSR_CTL(dev)) & ~EDP_PSR_ENABLE);
+	if (dev_priv->psr.active) {
+		I915_WRITE(EDP_PSR_CTL(dev),
+			   I915_READ(EDP_PSR_CTL(dev)) & ~EDP_PSR_ENABLE);
+
+		/* Wait till PSR is idle */
+		if (_wait_for((I915_READ(EDP_PSR_STATUS_CTL(dev)) &
+			       EDP_PSR_STATUS_STATE_MASK) == 0, 2000, 10))
+			DRM_ERROR("Timed out waiting for PSR Idle State\n");
 
-	/* Wait till PSR is idle */
-	if (_wait_for((I915_READ(EDP_PSR_STATUS_CTL(dev)) &
-		       EDP_PSR_STATUS_STATE_MASK) == 0, 2000, 10))
-		DRM_ERROR("Timed out waiting for PSR Idle State\n");
+		dev_priv->psr.active = false;
+	} else {
+		WARN_ON(I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE);
+	}
 
 	dev_priv->psr.enabled = NULL;
 }
@@ -1933,16 +1939,6 @@ static void intel_edp_psr_work(struct work_struct *work)
 		intel_edp_psr_do_enable(intel_dp);
 }
 
-static void intel_edp_psr_inactivate(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	dev_priv->psr.active = false;
-
-	I915_WRITE(EDP_PSR_CTL(dev), I915_READ(EDP_PSR_CTL(dev))
-		   & ~EDP_PSR_ENABLE);
-}
-
 void intel_edp_psr_exit(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1955,8 +1951,15 @@ void intel_edp_psr_exit(struct drm_device *dev)
 
 	cancel_delayed_work_sync(&dev_priv->psr.work);
 
-	if (dev_priv->psr.active)
-		intel_edp_psr_inactivate(dev);
+	if (dev_priv->psr.active) {
+		u32 val = I915_READ(EDP_PSR_CTL(dev));
+
+		WARN_ON(!(val & EDP_PSR_ENABLE));
+
+		I915_WRITE(EDP_PSR_CTL(dev), val & ~EDP_PSR_ENABLE);
+
+		dev_priv->psr.active = false;
+	}
 
 	schedule_delayed_work(&dev_priv->psr.work,
 			      msecs_to_jiffies(100));
Signature · 1 line
1.9.3
author maintainer
#5 lore raw

PATCH 6/11 drm/i915: More checks for psr.enabled

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

We need to make sure that no one else is using this in the enable function and also that the work item hasn't raced with the disabled function.

v2: Improve bisectability by moving one hunk to an earlier patch.

v3: added missing dev_priv declaration (Rodrigo)

---
 drivers/gpu/drm/i915/intel_dp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_dp.c +6 -0
index b4e4bdc..5854ae6 100644
@@ -1883,6 +1883,7 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp)
 void intel_edp_psr_enable(struct intel_dp *intel_dp)
 {
 	struct drm_device *dev = intel_dp_to_dev(intel_dp);
+	struct drm_i915_private *dev_priv = dev->dev_private;
 
 	if (!HAS_PSR(dev)) {
 		DRM_DEBUG_KMS("PSR not supported on this platform\n");
@@ -1894,6 +1895,11 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)
 		return;
 	}
 
+	if (dev_priv->psr.enabled) {
+		DRM_DEBUG_KMS("PSR already in use\n");
+		return;
+	}
+
 	/* Setup PSR once */
 	intel_edp_psr_setup(intel_dp);
 
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH 7/11 drm/i915: Add locking to psr code

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

It's not really optional to have locking ...

The ugly part is how much locking the psr work needs since it has to recheck everything. Which is way too much. But we need to ditch the psr work in it's current form anyway and implement proper frontbuffer tracking.

The other nasty bit that had to go was the delayed work cancle in psr_exit. Which means a bunch of races just became a bit more likely, but mea culpa.

v2: Fixup HAS_PSR checks, resulting in uninitialized mutex issues.

---
 drivers/gpu/drm/i915/i915_drv.h |  1 +
 drivers/gpu/drm/i915/intel_dp.c | 38 +++++++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 1ec4d4a..ae069b6 100644
@@ -656,6 +656,7 @@ struct i915_drrs {
 
 struct intel_dp;
 struct i915_psr {
+	struct mutex lock;
 	bool sink_support;
 	bool source_ok;
 	struct intel_dp *enabled;
drivers/gpu/drm/i915/intel_dp.c +31 -7
index 5854ae6..a59d5a6 100644
@@ -1800,6 +1800,11 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)
 	struct drm_i915_gem_object *obj = intel_fb_obj(crtc->primary->fb);
 	struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
 
+	lockdep_assert_held(&dev_priv->psr.lock);
+	lockdep_assert_held(&dev->struct_mutex);
+	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+
 	dev_priv->psr.source_ok = false;
 
 	if (!HAS_PSR(dev)) {
@@ -1869,6 +1874,7 @@ static void intel_edp_psr_do_enable(struct intel_dp *intel_dp)
 
 	WARN_ON(I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE);
 	WARN_ON(dev_priv->psr.active);
+	lockdep_assert_held(&dev_priv->psr.lock);
 
 	/* Enable PSR on the panel */
 	intel_edp_psr_enable_sink(intel_dp);
@@ -1895,8 +1901,10 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)
 		return;
 	}
 
+	mutex_lock(&dev_priv->psr.lock);
 	if (dev_priv->psr.enabled) {
 		DRM_DEBUG_KMS("PSR already in use\n");
+		mutex_unlock(&dev_priv->psr.lock);
 		return;
 	}
 
@@ -1905,6 +1913,7 @@ void intel_edp_psr_enable(struct intel_dp *intel_dp)
 
 	if (intel_edp_psr_match_conditions(intel_dp))
 		intel_edp_psr_do_enable(intel_dp);
+	mutex_unlock(&dev_priv->psr.lock);
 }
 
 void intel_edp_psr_disable(struct intel_dp *intel_dp)
@@ -1912,9 +1921,15 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)
 	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	if (!dev_priv->psr.enabled)
+	if (!HAS_PSR(dev))
 		return;
 
+	mutex_lock(&dev_priv->psr.lock);
+	if (!dev_priv->psr.enabled) {
+		mutex_unlock(&dev_priv->psr.lock);
+		return;
+	}
+
 	if (dev_priv->psr.active) {
 		I915_WRITE(EDP_PSR_CTL(dev),
 			   I915_READ(EDP_PSR_CTL(dev)) & ~EDP_PSR_ENABLE);
@@ -1930,19 +1945,30 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)
 	}
 
 	dev_priv->psr.enabled = NULL;
+	mutex_unlock(&dev_priv->psr.lock);
 }
 
 static void intel_edp_psr_work(struct work_struct *work)
 {
 	struct drm_i915_private *dev_priv =
 		container_of(work, typeof(*dev_priv), psr.work.work);
+	struct drm_device *dev = dev_priv->dev;
 	struct intel_dp *intel_dp = dev_priv->psr.enabled;
 
+	drm_modeset_lock_all(dev);
+	mutex_lock(&dev->struct_mutex);
+	mutex_lock(&dev_priv->psr.lock);
+	intel_dp = dev_priv->psr.enabled;
+
 	if (!intel_dp)
-		return;
+		goto unlock;
 
 	if (intel_edp_psr_match_conditions(intel_dp))
 		intel_edp_psr_do_enable(intel_dp);
+unlock:
+	mutex_unlock(&dev_priv->psr.lock);
+	mutex_unlock(&dev->struct_mutex);
+	drm_modeset_unlock_all(dev);
 }
 
 void intel_edp_psr_exit(struct drm_device *dev)
@@ -1955,8 +1981,7 @@ void intel_edp_psr_exit(struct drm_device *dev)
 	if (!dev_priv->psr.enabled)
 		return;
 
-	cancel_delayed_work_sync(&dev_priv->psr.work);
-
+	mutex_lock(&dev_priv->psr.lock);
 	if (dev_priv->psr.active) {
 		u32 val = I915_READ(EDP_PSR_CTL(dev));
 
@@ -1969,16 +1994,15 @@ void intel_edp_psr_exit(struct drm_device *dev)
 
 	schedule_delayed_work(&dev_priv->psr.work,
 			      msecs_to_jiffies(100));
+	mutex_unlock(&dev_priv->psr.lock);
 }
 
 void intel_edp_psr_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	if (!HAS_PSR(dev))
-		return;
-
 	INIT_DELAYED_WORK(&dev_priv->psr.work, intel_edp_psr_work);
+	mutex_init(&dev_priv->psr.lock);
 }
 
 static void intel_disable_dp(struct intel_encoder *encoder)
Signature · 1 line
1.9.3
author maintainer
#7 lore raw

PATCH 8/11 drm/i915: Fix up PSR frontbuffer tracking

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

I've tried to split this up, but all the changes are so tightly related that I didn't find a good way to do this without breaking bisecting. Essentially this completely changes how psr is glued into the overall driver, and there's not much you can do to soften such a paradigm change.

- Use frontbuffer tracking bits stuff to separate disable and re-enable.

- Don't re-check everything in the psr work. We have now accurate tracking for everything, so no need to check for sprites or tiling really. Allows us to ditch tons of locks.

- That in turn allows us to properly cancel the work in the disable function - no more deadlocks.

- Add a check for HSW sprites and force a flush. Apparently the hardware doesn't forward the flushing when updating the sprite base address. We can do the same trick everywhere else we have such issues, e.g. on baytrail with ... everything.

- Don't re-enable psr with a delay in psr_exit. It really must be turned off forever if we detect a gtt write. At least with the current frontbuffer render tracking. Userspace can do a busy ioctl call or no-op pageflip to re-enable psr.

- Drop redundant checks for crtc and crtc->active - now that they're only called from enable this is guaranteed.

- Fix up the hsw port check. eDP can also happen on port D, but the issue is exactly that it doesn't work there. So an || check is wrong.

- We still schedule the psr work with a delay. The frontbuffer flushing interface mandates that we upload the next full frame, so need to wait a bit. Once we have single-shot frame uploads we can do better here.

v2: Don't enable psr initially, rely upon the fb flush of the initial plane setup for that. Gives us more unified code flow and makes the crtc enable sequence less a special case.

v3: s/psr_exit/psr_invalidate/ for consistency

v4: Fixup whitespace.

v5: Correctly bail out of psr_invalidate/flush when dev_priv->psr.enabled is NULL. Spotted by Rodrigo.

v6:
- Only schedule work when there's work to do. Fixes WARNINGs reported by Rodrigo.
- Comments Chris requested to clarify the code.

v7: Fix conflict on rebase (Rodrigo)

---
 drivers/gpu/drm/i915/i915_drv.h      |   1 +
 drivers/gpu/drm/i915/intel_display.c |   4 +-
 drivers/gpu/drm/i915/intel_dp.c      | 124 ++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_drv.h     |   5 +-
 4 files changed, 85 insertions(+), 49 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index ae069b6..f48e452 100644
@@ -662,6 +662,7 @@ struct i915_psr {
 	struct intel_dp *enabled;
 	bool active;
 	struct delayed_work work;
+	unsigned busy_frontbuffer_bits;
 };
 
 enum intel_pch {
drivers/gpu/drm/i915/intel_display.c +2 -2
index fe6f1db..538fe31 100644
@@ -8938,7 +8938,7 @@ void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
 
 	intel_mark_fb_busy(dev, obj->frontbuffer_bits, ring);
 
-	intel_edp_psr_exit(dev);
+	intel_edp_psr_invalidate(dev, obj->frontbuffer_bits);
 }
 
 /**
@@ -8964,7 +8964,7 @@ void intel_frontbuffer_flush(struct drm_device *dev,
 
 	intel_mark_fb_busy(dev, frontbuffer_bits, NULL);
 
-	intel_edp_psr_exit(dev);
+	intel_edp_psr_flush(dev, frontbuffer_bits);
 }
 
 /**
drivers/gpu/drm/i915/intel_dp.c +78 -46

195 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +4 -1
index 016d894..e6ef0ef 100644
@@ -869,7 +869,10 @@ void intel_edp_panel_off(struct intel_dp *intel_dp);
 void intel_edp_psr_enable(struct intel_dp *intel_dp);
 void intel_edp_psr_disable(struct intel_dp *intel_dp);
 void intel_dp_set_drrs_state(struct drm_device *dev, int refresh_rate);
-void intel_edp_psr_exit(struct drm_device *dev);
+void intel_edp_psr_invalidate(struct drm_device *dev,
+			      unsigned frontbuffer_bits);
+void intel_edp_psr_flush(struct drm_device *dev,
+			 unsigned frontbuffer_bits);
 void intel_edp_psr_init(struct drm_device *dev);
 
 /* intel_dsi.c */
Signature · 1 line
1.9.3
author maintainer
#8 lore raw

PATCH 9/11 drm/i915: Improve PSR debugfs output

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

Add busy_frontbuffer_bits and locking.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
index 62ea619..fc39610 100644
@@ -1892,10 +1892,15 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 
 	intel_runtime_pm_get(dev_priv);
 
+	mutex_lock(&dev_priv->psr.lock);
 	seq_printf(m, "Sink_Support: %s\n", yesno(dev_priv->psr.sink_support));
 	seq_printf(m, "Source_OK: %s\n", yesno(dev_priv->psr.source_ok));
 	seq_printf(m, "Enabled: %s\n", yesno((bool)dev_priv->psr.enabled));
 	seq_printf(m, "Active: %s\n", yesno(dev_priv->psr.active));
+	seq_printf(m, "Busy frontbuffer bits: 0x%03x\n",
+		   dev_priv->psr.busy_frontbuffer_bits);
+	seq_printf(m, "Re-enable work scheduled: %s\n",
+		   yesno(work_busy(&dev_priv->psr.work.work)));
 
 	enabled = HAS_PSR(dev) &&
 		I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE;
@@ -1905,6 +1910,7 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 		psrperf = I915_READ(EDP_PSR_PERF_CNT(dev)) &
 			EDP_PSR_PERF_CNT_MASK;
 	seq_printf(m, "Performance_Counter: %u\n", psrperf);
+	mutex_unlock(&dev_priv->psr.lock);
 
 	intel_runtime_pm_put(dev_priv);
 	return 0;
Signature · 1 line
1.9.3
author maintainer
#9 lore raw

PATCH 10/11 drm/i915: Remove redundant HAS_PSR checks

In reply to Rodrigo Vivi

From: Daniel Vetter <[email protected]>

We only need to check for this in psr_enable, everything else is already protect by the dev_priv->psr.enabled checks. Those need the psr locking, but these functions are called infrequent enough that the locking overhead is negligible.

Suggested by Chris Wilson.

---
 drivers/gpu/drm/i915/intel_dp.c | 14 --------------
 1 file changed, 14 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +0 -14
index a8f8d00..5498e12 100644
@@ -1805,11 +1805,6 @@ static bool intel_edp_psr_match_conditions(struct intel_dp *intel_dp)
 
 	dev_priv->psr.source_ok = false;
 
-	if (!HAS_PSR(dev)) {
-		DRM_DEBUG_KMS("PSR not supported on this platform\n");
-		return false;
-	}
-
 	if (IS_HASWELL(dev) && dig_port->port != PORT_A) {
 		DRM_DEBUG_KMS("HSW ties PSR to DDI A (eDP)\n");
 		return false;
@@ -1896,9 +1891,6 @@ void intel_edp_psr_disable(struct intel_dp *intel_dp)
 	struct drm_device *dev = intel_dp_to_dev(intel_dp);
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	if (!HAS_PSR(dev))
-		return;
-
 	mutex_lock(&dev_priv->psr.lock);
 	if (!dev_priv->psr.enabled) {
 		mutex_unlock(&dev_priv->psr.lock);
@@ -1973,9 +1965,6 @@ void intel_edp_psr_invalidate(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	enum pipe pipe;
 
-	if (!HAS_PSR(dev))
-		return;
-
 	mutex_lock(&dev_priv->psr.lock);
 	if (!dev_priv->psr.enabled) {
 		mutex_unlock(&dev_priv->psr.lock);
@@ -2000,9 +1989,6 @@ void intel_edp_psr_flush(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	enum pipe pipe;
 
-	if (!HAS_PSR(dev))
-		return;
-
 	mutex_lock(&dev_priv->psr.lock);
 	if (!dev_priv->psr.enabled) {
 		mutex_unlock(&dev_priv->psr.lock);
Signature · 1 line
1.9.3
author maintainer
#10 lore raw

PATCH 11/11 drm/i915: Enable PSR by default.

In reply to Rodrigo Vivi

Panel Self Refresh is an eDP power saving feature specified by VESA's eDP v1.3, that allows some panel componets to shutdown while you still see static images on the screen. Besides being supported on the platform it must be supported by the eDP panel itself.

Now that we have the propper frontbuffer tracking support and correct locks on place we can enabled this feature by default.

---
 drivers/gpu/drm/i915/i915_params.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_params.c +2 -2
index 8145729..bbdee21 100644
@@ -37,7 +37,7 @@ struct i915_params i915 __read_mostly = {
 	.enable_fbc = -1,
 	.enable_hangcheck = true,
 	.enable_ppgtt = -1,
-	.enable_psr = 0,
+	.enable_psr = 1,
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
 	.enable_ips = 1,
@@ -118,7 +118,7 @@ MODULE_PARM_DESC(enable_ppgtt,
 	"(-1=auto [default], 0=disabled, 1=aliasing, 2=full)");
 
 module_param_named(enable_psr, i915.enable_psr, int, 0600);
-MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
+MODULE_PARM_DESC(enable_psr, "Enable PSR (default: true)");
 
 module_param_named(preliminary_hw_support, i915.preliminary_hw_support, int, 0600);
 MODULE_PARM_DESC(preliminary_hw_support,
Signature · 1 line
1.9.3
#11 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 9 lines · Rodrigo Vivi

Panel Self Refresh is an eDP power saving feature specified by VESA's eDP v1.3, that allows some panel componets to shutdown while you still see static images on the screen. Besides being supported on the platform it must be supported by the eDP panel itself.

Now that we have the propper frontbuffer tracking support and correct locks on place we can enabled this feature by default.

Yay!

Entire series pulled in, thanks a lot for the testing and review.

Besides byt psr the big chunk is now polishing the testcase. Iirc I've written down a detailed description of the task in internal jira and assigned it to you, right?

I want to have the tests before we enable byt psr to make sure we really catch all the regressions that might crop up.

Thanks, Daniel

Quoted 33 lines
---
 drivers/gpu/drm/i915/i915_params.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_params.c +2 -2
index 8145729..bbdee21 100644
@@ -37,7 +37,7 @@ struct i915_params i915 __read_mostly = {
 	.enable_fbc = -1,
 	.enable_hangcheck = true,
 	.enable_ppgtt = -1,
-	.enable_psr = 0,
+	.enable_psr = 1,
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
 	.enable_ips = 1,
@@ -118,7 +118,7 @@ MODULE_PARM_DESC(enable_ppgtt,
 	"(-1=auto [default], 0=disabled, 1=aliasing, 2=full)");
 
 module_param_named(enable_psr, i915.enable_psr, int, 0600);
-MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
+MODULE_PARM_DESC(enable_psr, "Enable PSR (default: true)");
 
 module_param_named(preliminary_hw_support, i915.preliminary_hw_support, int, 0600);
 MODULE_PARM_DESC(preliminary_hw_support,
Signature · 6 lines
1.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#12 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Rodrigo Vivi

Panel Self Refresh is an eDP power saving feature specified by VESA's eDP v1.3, that allows some panel componets to shutdown while you still see static images on the screen. Besides being supported on the platform it must be supported by the eDP panel itself.

Quoted 8 lines
Quoted 4 lines

Now that we have the propper frontbuffer tracking support and correct locks on place we can enabled this feature by default.

Yay!

Entire series pulled in, thanks a lot for the testing and review.

Is there any chance we can have the output property to know when PSR is available and active on the eDP?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#13 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 10 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Rodrigo Vivi

Panel Self Refresh is an eDP power saving feature specified by VESA's eDP v1.3, that allows some panel componets to shutdown while you still see static images on the screen. Besides being supported on the platform it must be supported by the eDP panel itself.

Now that we have the propper frontbuffer tracking support and correct locks on place we can enabled this feature by default.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yay!

Entire series pulled in, thanks a lot for the testing and review.

Is there any chance we can have the output property to know when PSR is available and active on the eDP?

Oh right, forgotten about this. I guess now that the hw stuff is there we can resurrect this. And with the universal planes support we could move the "prefer backbuffer rendering" hint to planes even where it imo belongs (since e.g. fbc is on the plane). Or maybe we don't care about that level of granularity and just have one per pipe. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#14 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 17 lines · Daniel Vetter
Quoted 16 lines · Chris Wilson
Quoted 14 lines · Daniel Vetter
Quoted 9 lines · Rodrigo Vivi

Panel Self Refresh is an eDP power saving feature specified by VESA's eDP v1.3, that allows some panel componets to shutdown while you still see static images on the screen. Besides being supported on the platform it must be supported by the eDP panel itself.

Now that we have the propper frontbuffer tracking support and correct locks on place we can enabled this feature by default.

Yay!

Entire series pulled in, thanks a lot for the testing and review.

Quoted 8 lines
Quoted 2 lines

Is there any chance we can have the output property to know when PSR is available and active on the eDP?

Oh right, forgotten about this. I guess now that the hw stuff is there we can resurrect this. And with the universal planes support we could move the "prefer backbuffer rendering" hint to planes even where it imo belongs (since e.g. fbc is on the plane). Or maybe we don't care about that level of granularity and just have one per pipe.

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#15 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#16 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#17 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 5 lines · Chris Wilson
Quoted 4 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Quoted 8 lines
Quoted 5 lines

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#18 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Quoted 5 lines
Quoted 2 lines

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?

An interesting factoid to present to the user. Also makes it easy for me to check everything works in X.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#19 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 13 lines · Chris Wilson
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?

An interesting factoid to present to the user. Also makes it easy for me to check everything works in X.

Hm not sure we want users to know this stuff. Next they ask to adjust it and then we have the same mess as with kernel options ;-) But I don't care strongly enough really either way. In-kernel I still think we want to keep this on the crtc so that fbc and psr work the same way. The connector property would then just chase the connected crtc to read out the property.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#20 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 23 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?

An interesting factoid to present to the user. Also makes it easy for me to check everything works in X.

Quoted 6 lines

Hm not sure we want users to know this stuff. Next they ask to adjust it and then we have the same mess as with kernel options ;-) But I don't care strongly enough really either way. In-kernel I still think we want to keep this on the crtc so that fbc and psr work the same way. The connector property would then just chase the connected crtc to read out the property.

It can't be crtc as it is an connector properrty... And it is immutable. I think it will be one of those useful things that people would like to check infrequently to make sure everything is functioning as intended (like powertop). I think there may be a few properties like this we can expose. And if people ask why PSR isn't active, then we should do a better job at making sure it stays enabled.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#21 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 31 lines · Chris Wilson
Quoted 23 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?

An interesting factoid to present to the user. Also makes it easy for me to check everything works in X.

Quoted 6 lines

Hm not sure we want users to know this stuff. Next they ask to adjust it and then we have the same mess as with kernel options ;-) But I don't care strongly enough really either way. In-kernel I still think we want to keep this on the crtc so that fbc and psr work the same way. The connector property would then just chase the connected crtc to read out the property.

Quoted 6 lines

It can't be crtc as it is an connector properrty... And it is immutable. I think it will be one of those useful things that people would like to check infrequently to make sure everything is functioning as intended (like powertop). I think there may be a few properties like this we can expose. And if people ask why PSR isn't active, then we should do a better job at making sure it stays enabled.

Oh, you mean just a psr property? I've thought in general terms of discouraging frontbuffer rendering and included fbc. A simple has_self_refresh_display (don't want to exclude dsi) is obviously a connector thing. But I thought you want to use that as a "should I flip or can I frontbuffer render" hint, and I guessed that fbc should be part of that. At least once we switched it to the sw tracking. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#22 lore raw

Re: [PATCH 11/11] drm/i915: Enable PSR by default.

Quoted 39 lines · Daniel Vetter
Quoted 31 lines · Chris Wilson
Quoted 23 lines · Daniel Vetter
Quoted 13 lines · Chris Wilson
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 2 lines · Chris Wilson

But PSR is definitely an output property... Please-dont-touch-me is indeed a plane property.

Well I guess we also want this for fbc, and fbc isn't an output property. I guess in the end it doesn't really matter that much as long as it's there, but traditional userspace exposes all output properties to userspace (on X), hence why I think we should hide it a bit ;-)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Hence why I want PSR as an output property. I want to see the status exposed in xrandr.

Hm, why that? I've thought we only want this to give hints to the compositor/ddx?

An interesting factoid to present to the user. Also makes it easy for me to check everything works in X.

Quoted 6 lines

Hm not sure we want users to know this stuff. Next they ask to adjust it and then we have the same mess as with kernel options ;-) But I don't care strongly enough really either way. In-kernel I still think we want to keep this on the crtc so that fbc and psr work the same way. The connector property would then just chase the connected crtc to read out the property.

Quoted 6 lines

It can't be crtc as it is an connector properrty... And it is immutable. I think it will be one of those useful things that people would like to check infrequently to make sure everything is functioning as intended (like powertop). I think there may be a few properties like this we can expose. And if people ask why PSR isn't active, then we should do a better job at making sure it stays enabled.

Quoted 6 lines

Oh, you mean just a psr property? I've thought in general terms of discouraging frontbuffer rendering and included fbc. A simple has_self_refresh_display (don't want to exclude dsi) is obviously a connector thing. But I thought you want to use that as a "should I flip or can I frontbuffer render" hint, and I guessed that fbc should be part of that. At least once we switched it to the sw tracking.

Yes, I was after both. But at the moment, I am interested in having a user-visible flag for showing that your fancy low power display is working.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre