Skip to contentSkip to conversation

drm/i915: Check if PSR is globally enabled before change PSR variables

PATCH In review José Roberto de Souza 5 participants 15 messages Nov 30, 2018 – Dec 21, 2018

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

PATCH 1/2 drm/i915: Check if PSR is globally enabled before change PSR variables

There is no issues changing the PSR variables even if PSR will be not enabled but it avoid having misleading values like have psr2_enabled set but enabled unset.

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/intel_psr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_psr.c +6 -5
index 2084784f320d..827b8c31783d 100644
@@ -716,14 +716,15 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 		goto unlock;
 	}
 
+	if (!psr_global_enabled(dev_priv->psr.debug)) {
+		DRM_DEBUG_KMS("PSR disabled by flag\n");
+		goto unlock;
+	}
+
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv, crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
 	dev_priv->psr.prepared = true;
-
-	if (psr_global_enabled(dev_priv->psr.debug))
-		intel_psr_enable_locked(dev_priv, crtc_state);
-	else
-		DRM_DEBUG_KMS("PSR disabled by flag\n");
+	intel_psr_enable_locked(dev_priv, crtc_state);
 
 unlock:
 	mutex_unlock(&dev_priv->psr.lock);
Signature · 6 lines
2.19.2

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

PATCH 2/2 drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Changing the i915_edp_psr_debug was enabling, disabling or switching PSR version by directly calling intel_psr_disable_locked() and intel_psr_enable_locked(), what is not the default PSR path that is executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested PSR state change and really stress the code path that matters for the regular user.

Also by doing this way it fixes the issue below, were DRRS was left enabled together with PSR when enabling PSR from debugfs.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++----------------
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
 	intel_runtime_pm_put(dev_priv);
 
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +1 -3
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, u64 value);
 void intel_psr_invalidate(struct drm_i915_private *dev_priv,
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +52 -67

174 lines not on this page · raw message

Signature · 6 lines
2.19.2

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

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 11 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching PSR version by directly calling intel_psr_disable_locked() and intel_psr_enable_locked(), what is not the default PSR path that is executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested PSR state change and really stress the code path that matters for the regular user.

Also by doing this way it fixes the issue below, were DRRS was left enabled together with PSR when enabling PSR from debugfs.

While this patch does fix the issue, psr_compute_config() not checking crtc_state->has_drrs seems odd. We should change it to not set crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or do it the other way around.

Quoted 267 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++------------
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,
 DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +1 -3
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
 u64 value);
 void intel_psr_invalidate(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -5
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
 	intel_psr_enable_locked(dev_priv, crtc_state);
 

unlock:

drivers/gpu/drm/i915/intel_psr.c +0 -5
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +47 -27
@@ -883,36 +874,61 @@ static bool __psr_wait_for_idle_locked(struct
 drm_i915_private *dev_priv)
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private *dev_priv,
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private
 *dev_priv)
 {
-	/* Can't switch psr state anyway if PSR2 is not supported. */
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==
 I915_PSR_DEBUG_FORCE_PSR1)
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=
 I915_PSR_DEBUG_FORCE_PSR1)
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
 
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
 u64 val)
 {
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ | I915_PSR_DEBUG_MODE_MASK) ||
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never touched

again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret = wait_for_completion_interruptible(&commit-
Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +1 -11
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state, mode))
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug & I915_PSR_DEBUG_MODE_MASK;
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +0 -1
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 10 lines
drivers/gpu/drm/i915/intel_psr.c +3 -3
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
 
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#3 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 15 lines · Dhinakaran Pandiyan
Quoted 6 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and intel_psr_enable_locked(), what is not the default PSR path that is executed in a regular modesets.

Quoted 7 lines

So lets force a modeset in the PSR CRTC to trigger the requested PSR
state change and really stress the code path that matters for the regular user.

Also by doing this way it fixes the issue below, were DRRS was left enabled together with PSR when enabling PSR from debugfs.

Quoted 6 lines

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or do it
the other way around.

psr_compute_config() is not called when enabling PSR from debugfs, this issue was reported when PSR1 was not enabled by default so DRRS was being enabled by default but not PSR and when PSR was enabled from debugfs both were kept enabled.

In the first version of this patch I was just disabling DRRS when enabling PSR but Maarten suggested to not do so and instead stress the default code path.

Quoted 275 lines
Quoted 275 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++------------
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,
 DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +1 -3
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
 u64 value);
 void intel_psr_invalidate(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -4
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
drivers/gpu/drm/i915/intel_psr.c +0 -1
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
 	intel_psr_enable_locked(dev_priv, crtc_state);

unlock:

drivers/gpu/drm/i915/intel_psr.c +0 -5
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +47 -27
@@ -883,36 +874,61 @@ static bool __psr_wait_for_idle_locked(struct
 drm_i915_private *dev_priv)
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private *dev_priv,
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private
 *dev_priv)
 {
-	/* Can't switch psr state anyway if PSR2 is not supported. */
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==
 I915_PSR_DEBUG_FORCE_PSR1)
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=
 I915_PSR_DEBUG_FORCE_PSR1)
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
 
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv,
 u64 val)
 {
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ | I915_PSR_DEBUG_MODE_MASK) ||
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never touched

again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret = wait_for_completion_interruptible(&commit-
Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +1 -11
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state, mode))
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug & I915_PSR_DEBUG_MODE_MASK;
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +3 -3
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
Quoted 4 lines

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +0 -1
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#4 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 26 lines · Jose
Quoted 17 lines · Dhinakaran Pandiyan
Quoted 7 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and intel_psr_enable_locked(), what is not the default PSR path that is
executed in a regular modesets.

Quoted 8 lines

So lets force a modeset in the PSR CRTC to trigger the requested PSR
state change and really stress the code path that matters for the regular user.

Also by doing this way it fixes the issue below, were DRRS was left
enabled together with PSR when enabling PSR from debugfs.

Quoted 7 lines

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or do
it
the other way around.

Quoted 2 lines

psr_compute_config() is not called when enabling PSR from debugfs, this

Right. My suggestion is to allow either ->has_drrs or ->has_psr being set (not both) in the kernel and disable DRRS in the IGT before starting the test.

Quoted 8 lines

issue was reported when PSR1 was not enabled by default so DRRS was being enabled by default but not PSR and when PSR was enabled from debugfs both were kept enabled.

In the first version of this patch I was just disabling DRRS when enabling PSR but Maarten suggested to not do so and instead stress the
default code path.

This patch changes crtc_state->mode_changed to force a modeset, which means it is not exactly the same as the 'default' code path.

Quoted 284 lines
Quoted 284 lines
Quoted 284 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++--------
----
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64
 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,
 DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +1 -3
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private
 *dev_priv,
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private
 *dev_priv,

u64 value);
void intel_psr_invalidate(struct drm_i915_private *dev_priv,

drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -4
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
drivers/gpu/drm/i915/intel_psr.c +0 -1
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
 	intel_psr_enable_locked(dev_priv, crtc_state);

unlock:

drivers/gpu/drm/i915/intel_psr.c +0 -5
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +0 -0
@@ -883,36 +874,61 @@ static bool

__psr_wait_for_idle_locked(struct
drm_i915_private *dev_priv)

drivers/gpu/drm/i915/intel_psr.c +1 -3
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private *dev_priv,
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private

*dev_priv)
{

drivers/gpu/drm/i915/intel_psr.c +18 -4
-	/* Can't switch psr state anyway if PSR2 is not supported. */
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +2 -2
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +23 -3
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
 
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_psr.c +1 -2
-			       struct drm_modeset_acquire_ctx *ctx,
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 val)
{

drivers/gpu/drm/i915/intel_psr.c +2 -13
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ | I915_PSR_DEBUG_MODE_MASK) ||
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never touched

again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret = wait_for_completion_interruptible(&commit-
Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +1 -11
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state, mode))
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug & I915_PSR_DEBUG_MODE_MASK;
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +3 -3
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +0 -1
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#5 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 30 lines · Dhinakaran Pandiyan
Quoted 29 lines · Jose
Quoted 27 lines · Dhinakaran Pandiyan
Quoted 15 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and intel_psr_enable_locked(), what is not the default PSR path that
is
executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested
PSR
state change and really stress the code path that matters for the
regular user.

Quoted 3 lines

Also by doing this way it fixes the issue below, were DRRS was left
enabled together with PSR when enabling PSR from debugfs.

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or do
it
the other way around.

Quoted 5 lines
Quoted 2 lines

psr_compute_config() is not called when enabling PSR from debugfs, this

Right. My suggestion is to allow either ->has_drrs or ->has_psr being set (not both) in the kernel and disable DRRS in the IGT before starting the test.

So in case were PSR is disabled by parameter and DRRS is supported we would not enable DRRS? Because has_psr is set even if PSR is disabled.

Disabling DRRS from IGT is duplicating the code that already do that and also not validating the default code path.

Quoted 6 lines
Quoted 6 lines

issue was reported when PSR1 was not enabled by default so DRRS was being enabled by default but not PSR and when PSR was enabled from debugfs both were kept enabled.

Quoted 7 lines
Quoted 4 lines

In the first version of this patch I was just disabling DRRS when enabling PSR but Maarten suggested to not do so and instead stress the
default code path.

This patch changes crtc_state->mode_changed to force a modeset, which means it is not exactly the same as the 'default' code path.

Some drm and i915 code paths also set mode_changed and the result of this is exactly the same as do a full modeset.

Quoted 299 lines
Quoted 299 lines
Quoted 299 lines
Quoted 299 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++--------
----
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64
 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,
 DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +0 -2
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state
 *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state
 *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private
 *dev_priv,
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_drv.h +1 -1
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 value);
void intel_psr_invalidate(struct drm_i915_private *dev_priv,

drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -4
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
drivers/gpu/drm/i915/intel_psr.c +0 -1
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 
 	dev_priv->psr.psr2_enabled =
 intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
drivers/gpu/drm/i915/intel_psr.c +0 -5
 	intel_psr_enable_locked(dev_priv, crtc_state);
 
 unlock:
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +0 -0
@@ -883,36 +874,61 @@ static bool

__psr_wait_for_idle_locked(struct
drm_i915_private *dev_priv)

drivers/gpu/drm/i915/intel_psr.c +1 -3
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private *dev_priv,
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private

*dev_priv)
{

drivers/gpu/drm/i915/intel_psr.c +0 -1
-	/* Can't switch psr state anyway if PSR2 is not

supported. */

drivers/gpu/drm/i915/intel_psr.c +18 -3
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +2 -2
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +7 -1
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)

{

drivers/gpu/drm/i915/intel_psr.c +9 -0
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state,

&ctx);

drivers/gpu/drm/i915/intel_psr.c +7 -2
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_psr.c +0 -1
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_psr.c +1 -1
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 val)
{

drivers/gpu/drm/i915/intel_psr.c +2 -8
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ |

I915_PSR_DEBUG_MODE_MASK) ||

drivers/gpu/drm/i915/intel_psr.c +0 -5
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev-
 >mode_config.connection_mutex,
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never

touched
again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret =

wait_for_completion_interruptible(&commit-

Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +0 -7
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state,

mode))

drivers/gpu/drm/i915/intel_psr.c +1 -2
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug &

I915_PSR_DEBUG_MODE_MASK;

drivers/gpu/drm/i915/intel_psr.c +0 -2
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +3 -3
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +0 -1
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#6 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 38 lines · Jose
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 35 lines · Jose
Quoted 22 lines · Dhinakaran Pandiyan
Quoted 16 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and
intel_psr_enable_locked(), what is not the default PSR path that
is
executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested
PSR
state change and really stress the code path that matters for the
regular user.

Quoted 4 lines

Also by doing this way it fixes the issue below, were DRRS was
left
enabled together with PSR when enabling PSR from debugfs.

Quoted 8 lines

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or
do
it
the other way around.

psr_compute_config() is not called when enabling PSR from debugfs,
this

Quoted 8 lines
Quoted 4 lines

Right. My suggestion is to allow either ->has_drrs or ->has_psr being
set (not both) in the kernel and disable DRRS in the IGT before starting the test.

So in case were PSR is disabled by parameter and DRRS is supported we would not enable DRRS? Because has_psr is set even if PSR is disabled.

Set ->has_psr = true in psr_compute_config() only if the module parameter and debugfs mode allow it. That is how the code worked earlier. Given that this patch duplicates the atomic state and runs through all state checks, we can move back to the earlier way of completing all checks in psr_compute_config().

Quoted 3 lines

Disabling DRRS from IGT is duplicating the code that already do that and also not validating the default code path.

Call drrs_compute_config() after psr_compute_config(), don't set has_drrs if has_psr is set.

Quoted 323 lines
Quoted 15 lines
Quoted 9 lines

issue was reported when PSR1 was not enabled by default so DRRS was
being enabled by default but not PSR and when PSR was enabled from
debugfs both were kept enabled.

Quoted 5 lines

In the first version of this patch I was just disabling DRRS when enabling PSR but Maarten suggested to not do so and instead stress
the
default code path.

Quoted 3 lines

This patch changes crtc_state->mode_changed to force a modeset, which
means it is not exactly the same as the 'default' code path.

Some drm and i915 code paths also set mode_changed and the result of this is exactly the same as do a full modeset.

Quoted 301 lines
Quoted 301 lines
Quoted 301 lines
Quoted 301 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++----
----
----
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64
 val)
 
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,
 DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +0 -2
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state
 *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state
 *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private
 *dev_priv,
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_drv.h +1 -1
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 value);
void intel_psr_invalidate(struct drm_i915_private *dev_priv,

drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -4
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
drivers/gpu/drm/i915/intel_psr.c +0 -1
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 
 	dev_priv->psr.psr2_enabled =
 intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
drivers/gpu/drm/i915/intel_psr.c +0 -5
 	intel_psr_enable_locked(dev_priv, crtc_state);
 
 unlock:
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +0 -0
@@ -883,36 +874,61 @@ static bool

__psr_wait_for_idle_locked(struct
drm_i915_private *dev_priv)

drivers/gpu/drm/i915/intel_psr.c +1 -3
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private *dev_priv,
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private

*dev_priv)
{

drivers/gpu/drm/i915/intel_psr.c +0 -1
-	/* Can't switch psr state anyway if PSR2 is not

supported. */

drivers/gpu/drm/i915/intel_psr.c +18 -3
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +2 -2
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +7 -1
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)

{

drivers/gpu/drm/i915/intel_psr.c +9 -0
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state,

&ctx);

drivers/gpu/drm/i915/intel_psr.c +7 -2
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_psr.c +0 -1
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_psr.c +1 -1
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 val)
{

drivers/gpu/drm/i915/intel_psr.c +2 -8
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ |

I915_PSR_DEBUG_MODE_MASK) ||

drivers/gpu/drm/i915/intel_psr.c +0 -5
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev-
 > mode_config.connection_mutex,
 
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never

touched
again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret =

wait_for_completion_interruptible(&commit-

Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +0 -7
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state,

mode))

drivers/gpu/drm/i915/intel_psr.c +1 -2
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug &

I915_PSR_DEBUG_MODE_MASK;

drivers/gpu/drm/i915/intel_psr.c +0 -2
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +3 -3
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +0 -1
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#7 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Quoted 58 lines · Dhinakaran Pandiyan
Quoted 47 lines · Jose
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 36 lines · Jose
Quoted 34 lines · Dhinakaran Pandiyan
Quoted 17 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and
intel_psr_enable_locked(), what is not the default PSR path that
is
executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested
PSR
state change and really stress the code path that matters for
the
regular user.

Quoted 4 lines

Also by doing this way it fixes the issue below, were DRRS was
left
enabled together with PSR when enabling PSR from debugfs.

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set
crtc_state->has_psr if crtc_state->has_drrs happens to be set.
Or
do
it
the other way around.

Quoted 8 lines
Quoted 3 lines

psr_compute_config() is not called when enabling PSR from debugfs,
this

Right. My suggestion is to allow either ->has_drrs or ->has_psr being
set (not both) in the kernel and disable DRRS in the IGT before starting the test.

Quoted 4 lines

So in case were PSR is disabled by parameter and DRRS is supported we
would not enable DRRS? Because has_psr is set even if PSR is disabled.

Set ->has_psr = true in psr_compute_config() only if the module parameter and debugfs mode allow it. That is how the code worked earlier. Given that this patch duplicates the atomic state and runs through all state checks, we can move back to the earlier way of completing all checks in psr_compute_config().

Quoted 5 lines
Quoted 3 lines

Disabling DRRS from IGT is duplicating the code that already do that
and also not validating the default code path.

Call drrs_compute_config() after psr_compute_config(), don't set has_drrs if has_psr is set.

What about add a flag to skip modeset so when running IGT tests we set that flag and PSR mode will be changed in the next modeset, what is already done after every write to i915_edp_psr_debug in IGT tests? This way we remove the code duplication and only stress the default code path.

Also plus the changes in has_drrs that you mentioned but in other patch.

Quoted 327 lines
Quoted 327 lines
Quoted 15 lines
Quoted 8 lines

issue was reported when PSR1 was not enabled by default so DRRS was
being enabled by default but not PSR and when PSR was enabled from
debugfs both were kept enabled.

Quoted 6 lines

In the first version of this patch I was just disabling DRRS when
enabling PSR but Maarten suggested to not do so and instead stress
the
default code path.

Quoted 3 lines

This patch changes crtc_state->mode_changed to force a modeset, which
means it is not exactly the same as the 'default' code path.

Some drm and i915 code paths also set mode_changed and the result of
this is exactly the same as do a full modeset.

Quoted 304 lines
Quoted 304 lines
Quoted 304 lines
Quoted 304 lines

Bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=108341

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +---
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   4 +-
 drivers/gpu/drm/i915/intel_psr.c    | 119 ++++++++++++----
----
----
----
 4 files changed, 55 insertions(+), 84 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -1
index 129b9a6f8309..bc32f683dc46 100644
@@ -2775,7 +2775,6 @@ static int
 i915_edp_psr_debug_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
-	struct drm_modeset_acquire_ctx ctx;
 	int ret;
 
 	if (!CAN_PSR(dev_priv))
@@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data,

u64
val)

drivers/gpu/drm/i915/i915_debugfs.c +0 -1
 	intel_runtime_pm_get(dev_priv);
 
-	drm_modeset_acquire_init(&ctx,

DRM_MODESET_ACQUIRE_INTERRUPTIBLE);

drivers/gpu/drm/i915/i915_debugfs.c +1 -11
-
-retry:
-	ret = intel_psr_set_debugfs_mode(dev_priv, &ctx, val);
-	if (ret == -EDEADLK) {
-		ret = drm_modeset_backoff(&ctx);
-		if (!ret)
-			goto retry;
-	}
-
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = intel_psr_set_debugfs_mode(dev_priv, val);
 
 	intel_runtime_pm_put(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 43ac6873a2bb..93d8ca9c0375 100644
@@ -493,7 +493,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	bool active;
 	struct work_struct work;
drivers/gpu/drm/i915/intel_drv.h +0 -2
index 86ff57738cd9..89d4eed0dd89 100644
@@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		      const struct intel_crtc_state
 *crtc_state);
 void intel_psr_disable(struct intel_dp *intel_dp,
 		      const struct intel_crtc_state
 *old_crtc_state);
-int intel_psr_set_debugfs_mode(struct drm_i915_private
 *dev_priv,
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_drv.h +1 -1
-			       u64 value);
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 value);
void intel_psr_invalidate(struct drm_i915_private
*dev_priv,

drivers/gpu/drm/i915/intel_drv.h +0 -0
 			  unsigned frontbuffer_bits,
 			  enum fb_op_origin origin);
drivers/gpu/drm/i915/intel_psr.c +1 -4
index 827b8c31783d..305848cceda7 100644
@@ -52,6 +52,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 	WARN_ON(dev_priv->drrs.dp);
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (dev_priv->psr.prepared) {
-		DRM_DEBUG_KMS("PSR already in use\n");
-		goto unlock;
-	}
 
 	if (!psr_global_enabled(dev_priv->psr.debug)) {
drivers/gpu/drm/i915/intel_psr.c +0 -1
 		DRM_DEBUG_KMS("PSR disabled by flag\n");
@@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 
 	dev_priv->psr.psr2_enabled =
 intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
-	dev_priv->psr.prepared = true;
drivers/gpu/drm/i915/intel_psr.c +0 -5
 	intel_psr_enable_locked(dev_priv, crtc_state);
 
 unlock:
@@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp
 *intel_dp,
 		return;
 
 	mutex_lock(&dev_priv->psr.lock);
-	if (!dev_priv->psr.prepared) {
-		mutex_unlock(&dev_priv->psr.lock);
-		return;
-	}
 
 	intel_psr_disable_locked(intel_dp);
 
-	dev_priv->psr.prepared = false;
 	mutex_unlock(&dev_priv->psr.lock);
 	cancel_work_sync(&dev_priv->psr.work);

}

drivers/gpu/drm/i915/intel_psr.c +0 -0
@@ -883,36 +874,61 @@ static bool

__psr_wait_for_idle_locked(struct
drm_i915_private *dev_priv)

drivers/gpu/drm/i915/intel_psr.c +0 -1
 	return err == 0 && dev_priv->psr.enabled;
 }
 
-static bool switching_psr(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_psr.c +1 -2
-			  struct intel_crtc_state *crtc_state,
-			  u32 mode)
+static int intel_psr_modeset_force(struct drm_i915_private

*dev_priv)
{

drivers/gpu/drm/i915/intel_psr.c +0 -1
-	/* Can't switch psr state anyway if PSR2 is not

supported. */

drivers/gpu/drm/i915/intel_psr.c +18 -3
-	if (!crtc_state || !crtc_state->has_psr2)
-		return false;
+	struct drm_device *dev = &dev_priv->drm;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_crtc_state *crtc_state;
+	struct drm_crtc *crtc;
+	int err, i;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (err) {
+		if (err == -EDEADLK) {
+			err = drm_modeset_backoff(&ctx);
+			if (!err)
+				goto modeset_lock_retry;
+		}
 
-	if (dev_priv->psr.psr2_enabled && mode ==

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +2 -2
-		return true;
+		goto unlock;
+	}
 
-	if (!dev_priv->psr.psr2_enabled && mode !=

I915_PSR_DEBUG_FORCE_PSR1)

drivers/gpu/drm/i915/intel_psr.c +7 -1
-		return true;
+	state = drm_atomic_helper_duplicate_state(dev, &ctx);
+	if (IS_ERR(state)) {
+		err = PTR_ERR(state);
+		goto unlock;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, crtc_state, i)

{

drivers/gpu/drm/i915/intel_psr.c +9 -0
+		struct intel_crtc_state *pipe_state;
+
+		pipe_state = to_intel_crtc_state(crtc_state);
+		/* Mark mode as changed to force a modeset */
+		if (pipe_state->has_psr)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state,

&ctx);

drivers/gpu/drm/i915/intel_psr.c +7 -2
-	return false;
+	drm_atomic_state_put(state);
+unlock:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return err;
 }
 
-int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_psr.c +0 -1
-			       struct drm_modeset_acquire_ctx

*ctx,

drivers/gpu/drm/i915/intel_psr.c +1 -1
-			       u64 val)
+int intel_psr_set_debugfs_mode(struct drm_i915_private

*dev_priv,
u64 val)
{

drivers/gpu/drm/i915/intel_psr.c +2 -8
-	struct drm_device *dev = &dev_priv->drm;
-	struct drm_connector_state *conn_state;
-	struct intel_crtc_state *crtc_state = NULL;
-	struct drm_crtc_commit *commit;
-	struct drm_crtc *crtc;
-	struct intel_dp *dp;
+	const u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
+	u32 old_mode;
 	int ret;
-	bool enable;
-	u32 mode = val & I915_PSR_DEBUG_MODE_MASK;
 
 	if (val & ~(I915_PSR_DEBUG_IRQ |

I915_PSR_DEBUG_MODE_MASK) ||

drivers/gpu/drm/i915/intel_psr.c +0 -5
 	    mode > I915_PSR_DEBUG_FORCE_PSR1) {
@@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct
 drm_i915_private *dev_priv,
 		return -EINVAL;
 	}
 
-	ret = drm_modeset_lock(&dev-
 > mode_config.connection_mutex,
 
 ctx);
-	if (ret)
-		return ret;
-
-	/* dev_priv->psr.dp should be set once and then never

touched
again. */

drivers/gpu/drm/i915/intel_psr.c +0 -15
-	dp = READ_ONCE(dev_priv->psr.dp);
-	conn_state = dp->attached_connector->base.state;
-	crtc = conn_state->crtc;
-	if (crtc) {
-		ret = drm_modeset_lock(&crtc->mutex, ctx);
-		if (ret)
-			return ret;
-
-		crtc_state = to_intel_crtc_state(crtc->state);
-		commit = crtc_state->base.commit;
-	} else {
-		commit = conn_state->commit;
-	}
-	if (commit) {
-		ret =

wait_for_completion_interruptible(&commit-

Quoted 1 line

hw_done);

drivers/gpu/drm/i915/intel_psr.c +0 -7
-		if (ret)
-			return ret;
-	}
-
 	ret = mutex_lock_interruptible(&dev_priv->psr.lock);
 	if (ret)
 		return ret;
 
-	enable = psr_global_enabled(val);
-
-	if (!enable || switching_psr(dev_priv, crtc_state,

mode))

drivers/gpu/drm/i915/intel_psr.c +1 -2
-		intel_psr_disable_locked(dev_priv->psr.dp);
-
+	old_mode = dev_priv->psr.debug &

I915_PSR_DEBUG_MODE_MASK;

drivers/gpu/drm/i915/intel_psr.c +0 -2
 	dev_priv->psr.debug = val;
-	if (crtc)
-		dev_priv->psr.psr2_enabled =

intel_psr2_enabled(dev_priv, crtc_state);

drivers/gpu/drm/i915/intel_psr.c +3 -3
-	intel_psr_irq_control(dev_priv, dev_priv->psr.debug);
+	mutex_unlock(&dev_priv->psr.lock);
 
-	if (dev_priv->psr.prepared && enable)
-		intel_psr_enable_locked(dev_priv, crtc_state);
+	if (old_mode != mode)
+		ret = intel_psr_modeset_force(dev_priv);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_psr.c int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, · line 952

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +0 -1
-	mutex_unlock(&dev_priv->psr.lock);
 	return ret;
 }

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

#8 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Op 11-12-2018 om 19:16 schreef Souza, Jose:

Quoted 60 lines · Dhinakaran Pandiyan
Quoted 54 lines · Jose
Quoted 39 lines · Dhinakaran Pandiyan
Quoted 38 lines · Jose
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 23 lines
Quoted 17 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and
intel_psr_enable_locked(), what is not the default PSR path that
is
executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested
PSR
state change and really stress the code path that matters for
the
regular user.

Quoted 4 lines

Also by doing this way it fixes the issue below, were DRRS was
left
enabled together with PSR when enabling PSR from debugfs.

Quoted 10 lines

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set
crtc_state->has_psr if crtc_state->has_drrs happens to be set.
Or
do
it
the other way around.

psr_compute_config() is not called when enabling PSR from debugfs,
this

Quoted 8 lines
Quoted 4 lines

Right. My suggestion is to allow either ->has_drrs or ->has_psr being
set (not both) in the kernel and disable DRRS in the IGT before starting the test.

So in case were PSR is disabled by parameter and DRRS is supported we
would not enable DRRS? Because has_psr is set even if PSR is disabled.

Set ->has_psr = true in psr_compute_config() only if the module parameter and debugfs mode allow it. That is how the code worked earlier. Given that this patch duplicates the atomic state and runs through all state checks, we can move back to the earlier way of completing all checks in psr_compute_config().

Quoted 5 lines
Quoted 3 lines

Disabling DRRS from IGT is duplicating the code that already do that
and also not validating the default code path.

Call drrs_compute_config() after psr_compute_config(), don't set has_drrs if has_psr is set.

Quoted 8 lines

What about add a flag to skip modeset so when running IGT tests we set that flag and PSR mode will be changed in the next modeset, what is already done after every write to i915_edp_psr_debug in IGT tests? This way we remove the code duplication and only stress the default code path.

Also plus the changes in has_drrs that you mentioned but in other patch.

Well the reason we set both is because kernel should decide which one to enable. The only way we can have both active is if we mess with debugfs.

I see the fact you're trying to enable both as a failure from the user. Anything in debugfs can be used for advanced debugging, and can possibly brick your system. If we really care, then we should disable DRRS when enabling PSR, and the same when enabling DRRS, that we disable PSR.

There's no need to restore it afterwards, because it's debugfs api.

~Maarten

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

#9 lore raw

Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

Op 17-12-2018 om 12:16 schreef Maarten Lankhorst:

Quoted 72 lines

Op 11-12-2018 om 19:16 schreef Souza, Jose:

Quoted 60 lines · Dhinakaran Pandiyan
Quoted 54 lines · Jose
Quoted 39 lines · Dhinakaran Pandiyan
Quoted 38 lines · Jose
Quoted 37 lines · Dhinakaran Pandiyan
Quoted 23 lines
Quoted 17 lines · José Roberto de Souza

Changing the i915_edp_psr_debug was enabling, disabling or switching
PSR version by directly calling intel_psr_disable_locked() and
intel_psr_enable_locked(), what is not the default PSR path that
is
executed in a regular modesets.

So lets force a modeset in the PSR CRTC to trigger the requested
PSR
state change and really stress the code path that matters for
the
regular user.

Quoted 4 lines

Also by doing this way it fixes the issue below, were DRRS was
left
enabled together with PSR when enabling PSR from debugfs.

Quoted 10 lines

While this patch does fix the issue, psr_compute_config() not checking
crtc_state->has_drrs seems odd. We should change it to not set
crtc_state->has_psr if crtc_state->has_drrs happens to be set.
Or
do
it
the other way around.

psr_compute_config() is not called when enabling PSR from debugfs,
this

Quoted 8 lines
Quoted 4 lines

Right. My suggestion is to allow either ->has_drrs or ->has_psr being
set (not both) in the kernel and disable DRRS in the IGT before starting the test.

So in case were PSR is disabled by parameter and DRRS is supported we
would not enable DRRS? Because has_psr is set even if PSR is disabled.

Set ->has_psr = true in psr_compute_config() only if the module parameter and debugfs mode allow it. That is how the code worked earlier. Given that this patch duplicates the atomic state and runs through all state checks, we can move back to the earlier way of completing all checks in psr_compute_config().

Quoted 5 lines
Quoted 3 lines

Disabling DRRS from IGT is duplicating the code that already do that
and also not validating the default code path.

Call drrs_compute_config() after psr_compute_config(), don't set has_drrs if has_psr is set.

Quoted 8 lines

What about add a flag to skip modeset so when running IGT tests we set that flag and PSR mode will be changed in the next modeset, what is already done after every write to i915_edp_psr_debug in IGT tests? This way we remove the code duplication and only stress the default code path.

Also plus the changes in has_drrs that you mentioned but in other patch.

Well the reason we set both is because kernel should decide which one to enable. The only way we can have both active is if we mess with debugfs.

Quoted 9 lines

I see the fact you're trying to enable both as a failure from the user. Anything in debugfs can be used for advanced debugging, and can possibly brick your system. If we really care, then we should disable DRRS when enabling PSR, and the same when enabling DRRS, that we disable PSR.

There's no need to restore it afterwards, because it's debugfs api.

~Maarten

.. or we could stop messing around, make a commit which sets crtc_state->mode_changed, it will degrade the modeset to a fastset, and then we can use update_pipe() to make the new settings active:

https://patchwork.freedesktop.org/series/54339/

And then only set enable_psr enable_drrs in crtc_state when we plan to use

it. This removes the need for separate settings..

~Maarten

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

#10 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915: Check if PSR is globally enabled before change PSR variables

In reply to José Roberto de Souza
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Check if PSR is globally enabled before change PSR variables
URL : https://patchwork.freedesktop.org/series/53293/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
3558d3c4ede6 drm/i915: Check if PSR is globally enabled before change PSR variables
e80f11002bee drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug
-:69: CHECK:BOOL_MEMBER: Avoid using bool structure members because of possible alignment issues - see: https://lkml.org/lkml/2017/11/21/384
#69: FILE: drivers/gpu/drm/i915/i915_drv.h:496:
+	bool enabled;

total: 0 errors, 0 warnings, 1 checks, 218 lines checked

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

#11 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Check if PSR is globally enabled before change PSR variables

In reply to José Roberto de Souza
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Check if PSR is globally enabled before change PSR variables
URL : https://patchwork.freedesktop.org/series/53293/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5227 -> Patchwork_10971
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/53293/revisions/1/mbox/

Known issues
------------

Here are the changes found in Patchwork_10971 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_execlists:
- fi-apl-guc: PASS -> INCOMPLETE [fdo#103927]

#### Possible fixes ####

* igt@gem_ctx_create@basic-files:
- fi-bsw-kefka: FAIL [fdo#108656] -> PASS

* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: FAIL [fdo#103167] -> PASS

[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#108656]: https://bugs.freedesktop.org/show_bug.cgi?id=108656

Participating hosts (50 -> 44)
------------------------------

Additional (1): fi-glk-j4005
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus

Build changes
-------------

* Linux: CI_DRM_5227 -> Patchwork_10971

CI_DRM_5227: 95052693524067ba66e1a6733355739fbcc8d5b6 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4736: 285ebfb3b7adc56586031afa5150c4e5ad40c229 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10971: e80f11002beea20c381b747016f887c59672bbd0 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

e80f11002bee drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug 3558d3c4ede6 drm/i915: Check if PSR is globally enabled before change PSR variables

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10971/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Reviewed-by on v1 1/2
#12 lore raw
In reply to José Roberto de Souza
Quoted 8 lines · José Roberto de Souza

There is no issues changing the PSR variables even if PSR will be not enabled but it avoid having misleading values like have psr2_enabled set but enabled unset.

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Quoted 36 lines
---
 drivers/gpu/drm/i915/intel_psr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_psr.c +6 -5
index 2084784f320d..827b8c31783d 100644
@@ -716,14 +716,15 @@ void intel_psr_enable(struct intel_dp *intel_dp,
 		goto unlock;
 	}
 
+	if (!psr_global_enabled(dev_priv->psr.debug)) {
+		DRM_DEBUG_KMS("PSR disabled by flag\n");
+		goto unlock;
+	}
+
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv, crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
 	dev_priv->psr.prepared = true;
-
-	if (psr_global_enabled(dev_priv->psr.debug))
-		intel_psr_enable_locked(dev_priv, crtc_state);
-	else
-		DRM_DEBUG_KMS("PSR disabled by flag\n");
+	intel_psr_enable_locked(dev_priv, crtc_state);
 
 unlock:
 	mutex_unlock(&dev_priv->psr.lock);
Signature · 6 lines
2.19.2

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

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

#13 lore raw
In reply to José Roberto de Souza
Quoted 21 lines · José Roberto de Souza

There is no issues changing the PSR variables even if PSR will be not enabled but it avoid having misleading values like have psr2_enabled set but enabled unset.

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/intel_psr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_psr.c +0 -0
index 2084784f320d..827b8c31783d 100644
@@ -716,14 +716,15 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		goto unlock;
 	}

drivers/gpu/drm/i915/intel_psr.c void intel_psr_enable(struct intel_dp · line 728

Quoted 10 lines
drivers/gpu/drm/i915/intel_psr.c +5 -0
 
+	if (!psr_global_enabled(dev_priv->psr.debug)) {
+		DRM_DEBUG_KMS("PSR disabled by flag\n");
+		goto unlock;
+	}
+
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
 	dev_priv->psr.prepared = true;

.prepared needs to be set even when psr_global_enabled() returns false. This is so that we can enable PSR via debugfs later.

Quoted 9 lines
drivers/gpu/drm/i915/intel_psr.c +1 -5
-
-	if (psr_global_enabled(dev_priv->psr.debug))
-		intel_psr_enable_locked(dev_priv, crtc_state);
-	else
-		DRM_DEBUG_KMS("PSR disabled by flag\n");
+	intel_psr_enable_locked(dev_priv, crtc_state);
 

unlock:
mutex_unlock(&dev_priv->psr.lock);

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

#14 lore raw
Quoted 25 lines · Dhinakaran Pandiyan
Quoted 24 lines · José Roberto de Souza

There is no issues changing the PSR variables even if PSR will be not
enabled but it avoid having misleading values like have psr2_enabled
set but enabled unset.

Cc Maarten Lankhorst <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/intel_psr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_psr.c +0 -0
index 2084784f320d..827b8c31783d 100644
@@ -716,14 +716,15 @@ void intel_psr_enable(struct intel_dp
 *intel_dp,
 		goto unlock;
 	}
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_psr.c void intel_psr_enable(struct intel_dp *intel_dp, · line 726

Quoted 9 lines
drivers/gpu/drm/i915/intel_psr.c +5 -0
+	if (!psr_global_enabled(dev_priv->psr.debug)) {
+		DRM_DEBUG_KMS("PSR disabled by flag\n");
+		goto unlock;
+	}
+
 	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
 	dev_priv->psr.busy_frontbuffer_bits = 0;
 	dev_priv->psr.prepared = true;

.prepared needs to be set even when psr_global_enabled() returns false.
This is so that we can enable PSR via debugfs later.

Oh that is right =/
Well so we can squash this patch with the next one.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/intel_psr.c +1 -5
-
-	if (psr_global_enabled(dev_priv->psr.debug))
-		intel_psr_enable_locked(dev_priv, crtc_state);
-	else
-		DRM_DEBUG_KMS("PSR disabled by flag\n");
+	intel_psr_enable_locked(dev_priv, crtc_state);
 

unlock:
mutex_unlock(&dev_priv->psr.lock);

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