Skip to contentSkip to conversation

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

PATCH Superseded José Roberto de Souza 4 participants 6 messages Jan 31, 2019 – Feb 1, 2019

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 will be executed by real users.

So lets force a fastset in the PSR CRTC to trigger a pipe update and stress the default code path.

Recently a bug was found when switching from PSR2 to PSR1 while enable_psr kernel parameter was set to the default parameter, this changes fix it and also fixes the bug linked bellow were DRRS was left enabled together with PSR when enabling PSR from debugfs.

v2: Handling missing case: disabled to PSR1

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]>

---

Should I add IGT tests to test every state switch combination?

 drivers/gpu/drm/i915/i915_debugfs.c |  14 +--
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_ddi.c    |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   6 +-
 drivers/gpu/drm/i915/intel_psr.c    | 187 +++++++++++++++++-----------
 5 files changed, 118 insertions(+), 93 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index fa2c226fc779..766a5b4ad3d6 100644
@@ -2607,7 +2607,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;
 	intel_wakeref_t wakeref;
 	int ret;
 
@@ -2618,18 +2617,7 @@ i915_edp_psr_debug_set(void *data, u64 val)
 
 	wakeref = 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, wakeref);
 
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 22da9df1f0a7..f75b4ce4df5f 100644
@@ -496,7 +496,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	enum pipe pipe;
 	bool active;
drivers/gpu/drm/i915/intel_ddi.c +1 -1
index ca705546a0ab..9211e4579489 100644
@@ -3556,7 +3556,7 @@ static void intel_ddi_update_pipe_dp(struct intel_encoder *encoder,
 {
 	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
 
-	intel_psr_enable(intel_dp, crtc_state);
+	intel_psr_update(intel_dp, crtc_state);
 	intel_edp_drrs_enable(intel_dp, crtc_state);
 
 	intel_panel_update_backlight(encoder, crtc_state, conn_state);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index 90ba5436370e..4c01decc30d3 100644
@@ -2067,9 +2067,9 @@ 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);
+void intel_psr_update(struct intel_dp *intel_dp,
+		      const struct intel_crtc_state *crtc_state);
+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 +112 -75

249 lines not on this page · raw message

Signature · 6 lines
2.20.1

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

✓ Fi.CI.BAT: success for drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug (rev2)
URL : https://patchwork.freedesktop.org/series/56013/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5515 -> Patchwork_12099
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56013/revisions/2/mbox/

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

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

### IGT changes ###

#### Issues hit ####

* igt@kms_flip@basic-flip-vs-dpms:
- fi-skl-6700hq: PASS -> DMESG-WARN [fdo#105998]

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362] +2

#### Possible fixes ####

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

* igt@kms_busy@basic-flip-a:
- fi-gdg-551: FAIL [fdo#103182] -> PASS +1

* igt@pm_rpm@module-reload:
- fi-skl-6770hq: FAIL [fdo#108511] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105998]: https://bugs.freedesktop.org/show_bug.cgi?id=105998
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271

Participating hosts (43 -> 41)
------------------------------

Additional (1): fi-glk-j4005
Missing (3): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan

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

* Linux: CI_DRM_5515 -> Patchwork_12099

CI_DRM_5515: d90f6e750bfce2161e5460364651c65cbfe1a1da @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4801: 6f6bacf12759fb319ade3ba37861ae711f8a5cd9 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12099: 3751c63cdcb9e048d053a5c122ae66ce2dee1170 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

3751c63cdcb9 drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug

== Logs ==

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

Reviewed-by on v2 1/1
#2 lore raw
In reply to José Roberto de Souza

Op 31-01-2019 om 01:58 schreef José Roberto de Souza:

Quoted 15 lines

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 will be executed by real users.

So lets force a fastset in the PSR CRTC to trigger a pipe update and stress the default code path.

Recently a bug was found when switching from PSR2 to PSR1 while enable_psr kernel parameter was set to the default parameter, this changes fix it and also fixes the bug linked bellow were DRRS was left enabled together with PSR when enabling PSR from debugfs.

v2: Handling missing case: disabled to PSR1

Quoted 8 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]>

---

Should I add IGT tests to test every state switch combination?

Should probably be done for DRRS as well. We should be able to stop having to set has_drrs and has_psr unconditionally then. :) Could be a separate followup patch.

The complete duplication of the whole atomic state is overkill and should be avoided, just use if (!intel_crtc_has_type(to_intel_crtc_state(crtc->state), INTEL_OUTPUT_EDP)

	continue;

crtc_state = drm_atomic_get_old_crtc_state(...)
....

And then do a normal commit. We will add all planes and connectors as needed.

With that fixed:

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

#3 lore raw
Quoted 26 lines · Maarten Lankhorst

Op 31-01-2019 om 01:58 schreef José Roberto de Souza:

Quoted 25 lines

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 will
be executed by real users.

So lets force a fastset in the PSR CRTC to trigger a pipe update and
stress the default code path.

Recently a bug was found when switching from PSR2 to PSR1 while enable_psr kernel parameter was set to the default parameter, this changes fix it and also fixes the bug linked bellow were DRRS was left enabled together with PSR when enabling PSR from debugfs.

v2: Handling missing case: disabled to PSR1

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]>

---

Quoted 5 lines
Quoted 1 line

Should I add IGT tests to test every state switch combination?

Should probably be done for DRRS as well. We should be able to stop having to set has_drrs and has_psr unconditionally then. :) Could be a separate followup patch.

I have DRRS/PSR bugs assigned to me, I will definitely fix that in the future.

Quoted 5 lines

The complete duplication of the whole atomic state is overkill and should be avoided, just use
if (!intel_crtc_has_type(to_intel_crtc_state(crtc->state), INTEL_OUTPUT_EDP)

Quoted 7 lines
	continue;

crtc_state = drm_atomic_get_old_crtc_state(...)
....

And then do a normal commit. We will add all planes and connectors as needed.

Thanks for the suggestion, just sent the new version with this.

Quoted 4 lines

With that fixed:

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

#4 lore raw

✓ Fi.CI.IGT: success for drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug (rev2)

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

== Series Details ==

Series: drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug (rev2)
URL : https://patchwork.freedesktop.org/series/56013/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5515_full -> Patchwork_12099_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_pwrite_pread@snooped-copy-performance:
- shard-apl: PASS -> INCOMPLETE [fdo#103927]

* igt@kms_busy@extended-modeset-hang-newfb-render-b:
- shard-snb: NOTRUN -> DMESG-WARN [fdo#107956]

* igt@kms_color@pipe-b-ctm-max:
- shard-apl: PASS -> FAIL [fdo#108147]

* igt@kms_cursor_crc@cursor-128x42-sliding:
- shard-apl: PASS -> FAIL [fdo#103232]

* igt@kms_cursor_crc@cursor-256x256-suspend:
- shard-hsw: PASS -> INCOMPLETE [fdo#103540]

* igt@kms_plane@pixel-format-pipe-b-planes-source-clamping:
- shard-apl: PASS -> FAIL [fdo#108948]

* igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb:
- shard-glk: PASS -> FAIL [fdo#108145]

* igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
- shard-apl: NOTRUN -> FAIL [fdo#108145] +1

* igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
- shard-apl: PASS -> FAIL [fdo#103166] +1

* igt@kms_plane_multiple@atomic-pipe-a-tiling-yf:
- shard-glk: PASS -> FAIL [fdo#103166]

* igt@kms_setmode@basic:
- shard-hsw: PASS -> FAIL [fdo#99912]
- shard-kbl: PASS -> FAIL [fdo#99912]

#### Possible fixes ####

* igt@gem_workarounds@suspend-resume:
- shard-kbl: INCOMPLETE [fdo#103665] -> PASS

* igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
- shard-apl: FAIL [fdo#106510] / [fdo#108145] -> PASS

* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-kbl: DMESG-WARN [fdo#103313] -> PASS

* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-apl: FAIL [fdo#103166] -> PASS +2

* igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
- shard-glk: FAIL [fdo#103166] -> PASS

* igt@kms_rotation_crc@sprite-rotation-270:
- shard-apl: INCOMPLETE [fdo#103927] -> PASS

* igt@kms_setmode@basic:
- shard-apl: FAIL [fdo#99912] -> PASS

* igt@perf@blocking:
- shard-hsw: FAIL [fdo#102252] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102252]: https://bugs.freedesktop.org/show_bug.cgi?id=102252
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103313]: https://bugs.freedesktop.org/show_bug.cgi?id=103313
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#106510]: https://bugs.freedesktop.org/show_bug.cgi?id=106510
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
[fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (7 -> 5)
------------------------------

Missing (2): shard-skl shard-iclb

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

* Linux: CI_DRM_5515 -> Patchwork_12099

CI_DRM_5515: d90f6e750bfce2161e5460364651c65cbfe1a1da @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4801: 6f6bacf12759fb319ade3ba37861ae711f8a5cd9 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12099: 3751c63cdcb9e048d053a5c122ae66ce2dee1170 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

#5 lore raw
In reply to José Roberto de Souza
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 will be executed by real users.

So lets force a fastset in the PSR CRTC to trigger a pipe update and stress the default code path.

Recently a bug was found when switching from PSR2 to PSR1 while enable_psr kernel parameter was set to the default parameter, this changes fix it and also fixes the bug linked bellow were DRRS was left enabled together with PSR when enabling PSR from debugfs.

v2: Handling missing case: disabled to PSR1

Quoted 8 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]>

---

Should I add IGT tests to test every state switch combination?

Yes, please. At the minimum we need, PSR1->PSR2->PSR1 to make sure the driver warnings aren't triggered.

Quoted 236 lines
 drivers/gpu/drm/i915/i915_debugfs.c |  14 +--
 drivers/gpu/drm/i915/i915_drv.h     |   2 +-
 drivers/gpu/drm/i915/intel_ddi.c    |   2 +-
 drivers/gpu/drm/i915/intel_drv.h    |   6 +-
 drivers/gpu/drm/i915/intel_psr.c    | 187 +++++++++++++++++---------
--
 5 files changed, 118 insertions(+), 93 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -13
index fa2c226fc779..766a5b4ad3d6 100644
@@ -2607,7 +2607,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;
 	intel_wakeref_t wakeref;
 	int ret;
 
@@ -2618,18 +2617,7 @@ i915_edp_psr_debug_set(void *data, u64 val)
 
 	wakeref = 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, wakeref);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 22da9df1f0a7..f75b4ce4df5f 100644
@@ -496,7 +496,7 @@ struct i915_psr {
 
 	u32 debug;
 	bool sink_support;
-	bool prepared, enabled;
+	bool enabled;
 	struct intel_dp *dp;
 	enum pipe pipe;
 	bool active;
drivers/gpu/drm/i915/intel_ddi.c +1 -1
index ca705546a0ab..9211e4579489 100644
@@ -3556,7 +3556,7 @@ static void intel_ddi_update_pipe_dp(struct
 intel_encoder *encoder,
 {
 	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
 
-	intel_psr_enable(intel_dp, crtc_state);
+	intel_psr_update(intel_dp, crtc_state);
 	intel_edp_drrs_enable(intel_dp, crtc_state);
 
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 	intel_panel_update_backlight(encoder, crtc_state, conn_state);
drivers/gpu/drm/i915/intel_drv.h +3 -3
index 90ba5436370e..4c01decc30d3 100644
@@ -2067,9 +2067,9 @@ 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);
+void intel_psr_update(struct intel_dp *intel_dp,
+		      const struct intel_crtc_state *crtc_state);
+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 +0 -0
index 84a0fb981561..90fe05a33b71 100644
@@ -51,6 +51,8 @@
  * must be correctly synchronized/cancelled when shutting down the

pipe."
*/

drivers/gpu/drm/i915/intel_psr.c +7 -2
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "intel_drv.h"
 #include "i915_drv.h"
@@ -718,8 +720,11 @@ static void intel_psr_enable_locked(struct
 drm_i915_private *dev_priv,
 {
 	struct intel_dp *intel_dp = dev_priv->psr.dp;
 
-	if (dev_priv->psr.enabled)
-		return;
+	WARN_ON(dev_priv->psr.enabled);
+
+	dev_priv->psr.psr2_enabled = intel_psr2_enabled(dev_priv,
 crtc_state);
+	dev_priv->psr.busy_frontbuffer_bits = 0;
+	dev_priv->psr.pipe = to_intel_crtc(crtc_state->base.crtc)-
 >pipe;
drivers/gpu/drm/i915/intel_psr.c +4 -11
 	DRM_DEBUG_KMS("Enabling PSR%s\n",
 		      dev_priv->psr.psr2_enabled ? "2" : "1");
@@ -752,20 +757,13 @@ 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");
+
+	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;
-	dev_priv->psr.pipe = to_intel_crtc(crtc_state->base.crtc)-
 >pipe;
-
-	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:

drivers/gpu/drm/i915/intel_psr.c +9 -5
 	mutex_unlock(&dev_priv->psr.lock);
@@ -848,18 +846,62 @@ 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);
 }
 
+#define PSR_MODE_STRING_GET(enabled, psr2_enabled) \
+		enabled ? (psr2_enabled ? "PSR2" : "PSR1") : "disabled"
+
+/**
+ * intel_psr_update - Update PSR state
+ * @intel_dp: Intel DP
+ * @crtc_state: new CRTC state
+ *
+ * This functions will update PSR states, disabling, enabling or

switching PSR
+ * version when executing fastsets. For full modeset, intel_psr_disable() and
+ * intel_psr_enable() should be called instead.
+ */

drivers/gpu/drm/i915/intel_psr.c +20 -0
+void intel_psr_update(struct intel_dp *intel_dp,
+		      const struct intel_crtc_state *crtc_state)
+{
+	struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
+	struct i915_psr *psr = &dev_priv->psr;
+	bool enable, psr2_enable;
+	const char *old_mode, *new_mode;
+
+	if (!CAN_PSR(dev_priv) || READ_ONCE(psr->dp) != intel_dp)
+		return;
+
+	mutex_lock(&dev_priv->psr.lock);
+
+	enable = crtc_state->has_psr && psr_global_enabled(psr->debug);
+	psr2_enable = intel_psr2_enabled(dev_priv, crtc_state);
+
+	if (psr->enabled == enable && psr2_enable == psr->psr2_enabled)
+		goto unlock;
+
+	old_mode = PSR_MODE_STRING_GET(psr->enabled, psr-
Quoted 1 line

psr2_enabled);

drivers/gpu/drm/i915/intel_psr.c +18 -4
+	new_mode = PSR_MODE_STRING_GET(enable, psr2_enable);
+	DRM_DEBUG_KMS("Updating from %s to %s", old_mode, new_mode);
+
+	if (psr->enabled) {
+		if (!enable || psr2_enable != psr->psr2_enabled)
+			intel_psr_disable_locked(intel_dp);
+	}
+
+	if (enable) {
+		if (!psr->enabled || psr2_enable != psr->psr2_enabled)
+			intel_psr_enable_locked(dev_priv, crtc_state);
+	}
+
+unlock:
+	mutex_unlock(&dev_priv->psr.lock);
+}
+
 /**
  * intel_psr_wait_for_idle - wait for PSR1 to idle
  * @new_crtc_state: new CRTC state
@@ -924,36 +966,62 @@ 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_fastset_force(struct drm_i915_private
 *dev_priv)
 {
-	/* Can't switch psr state anyway if PSR2 is not supported. */

drivers/gpu/drm/i915/intel_psr.c static bool __psr_wait_for_idle_locked(struct · line 980

Quoted 10 lines
drivers/gpu/drm/i915/intel_psr.c +8 -2
-	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);

Why do we need mode_config.mutex, isn't modeset_lock_all() sufficient?

drivers/gpu/drm/i915/intel_psr.c static bool __psr_wait_for_idle_locked(struct drm_i915_private *dev_priv) · line 982

Quoted 4 lines
drivers/gpu/drm/i915/intel_psr.c +4 -0
+	drm_modeset_acquire_init(&ctx, 0);
+
+modeset_lock_retry:
+	err = drm_modeset_lock_all_ctx(dev, &ctx);

Also why not takes locks for the specific crtc and connector instead?

Quoted 113 lines
drivers/gpu/drm/i915/intel_psr.c +35 -21
+	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);
 
-	return false;
+		/* Mark mode as changed to trigger a pipe->update() */
+		if (pipe_state->cpu_transcoder == TRANSCODER_EDP)
+			crtc_state->mode_changed = true;
+	}
+
+	err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
+
+	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) {
@@ -961,49 +1029,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 1045

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_fastset_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