All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/: dell wyse 3040 shutdown fix
@ 2022-12-25 18:44 Alexey Lukyanchuk
  2022-12-25 18:55   ` [Intel-gfx] " Alexey Lukyanchuk
  2022-12-25 19:05 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
  0 siblings, 2 replies; 38+ messages in thread
From: Alexey Lukyanchuk @ 2022-12-25 18:44 UTC (permalink / raw)
  To: nikita.shubin; +Cc: Alexey Lukyanchuk, stable

dell wyse 3040 doesn't peform poweroff properly, but instead remains in 
turned power on state. Additional mutex_lock and 
intel_crtc_wait_for_next_vblank 
in drivers/gpu/drm/i915/display/intel_crtc.c from 
feature 6.2 kernel resolve this trouble

cc: stable@vger.kernel.org
original commit Link: https://patchwork.freedesktop.org/patch/508926/
fixes: 
Signed-off-by: Alexey Lukyanchuk <skif@skif-web.ru>
---
I got some troubles with this device (dell wyse 3040) since kernel 5.11
started to use i915_driver_shutdown function. I found solution here:

https://lore.kernel.org/dri-devel/Y1wd6ZJ8LdJpCfZL@intel.com/#r

---
 drivers/gpu/drm/i915/display/intel_audio.c | 37 +++++++++++++++-------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c
index aacbc6da8..44344ecdf 100644
--- a/drivers/gpu/drm/i915/display/intel_audio.c
+++ b/drivers/gpu/drm/i915/display/intel_audio.c
@@ -336,6 +336,7 @@ static void g4x_audio_codec_disable(struct intel_encoder *encoder,
 				    const struct drm_connector_state *old_conn_state)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
 	u32 eldv, tmp;
 
 	tmp = intel_de_read(dev_priv, G4X_AUD_VID_DID);
@@ -348,6 +349,9 @@ static void g4x_audio_codec_disable(struct intel_encoder *encoder,
 	tmp = intel_de_read(dev_priv, G4X_AUD_CNTL_ST);
 	tmp &= ~eldv;
 	intel_de_write(dev_priv, G4X_AUD_CNTL_ST, tmp);
+
+	intel_crtc_wait_for_next_vblank(crtc);
+	intel_crtc_wait_for_next_vblank(crtc);
 }
 
 static void g4x_audio_codec_enable(struct intel_encoder *encoder,
@@ -355,12 +359,15 @@ static void g4x_audio_codec_enable(struct intel_encoder *encoder,
 				   const struct drm_connector_state *conn_state)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_connector *connector = conn_state->connector;
 	const u8 *eld = connector->eld;
 	u32 eldv;
 	u32 tmp;
 	int len, i;
 
+	intel_crtc_wait_for_next_vblank(crtc);
+
 	tmp = intel_de_read(dev_priv, G4X_AUD_VID_DID);
 	if (tmp == INTEL_AUDIO_DEVBLC || tmp == INTEL_AUDIO_DEVCL)
 		eldv = G4X_ELDV_DEVCL_DEVBLC;
@@ -493,6 +500,7 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder,
 				    const struct drm_connector_state *old_conn_state)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
 	enum transcoder cpu_transcoder = old_crtc_state->cpu_transcoder;
 	u32 tmp;
 
@@ -508,6 +516,10 @@ static void hsw_audio_codec_disable(struct intel_encoder *encoder,
 		tmp |= AUD_CONFIG_N_VALUE_INDEX;
 	intel_de_write(dev_priv, HSW_AUD_CFG(cpu_transcoder), tmp);
 
+
+	intel_crtc_wait_for_next_vblank(crtc);
+	intel_crtc_wait_for_next_vblank(crtc);
+
 	/* Invalidate ELD */
 	tmp = intel_de_read(dev_priv, HSW_AUD_PIN_ELD_CP_VLD);
 	tmp &= ~AUDIO_ELD_VALID(cpu_transcoder);
@@ -633,6 +645,7 @@ static void hsw_audio_codec_enable(struct intel_encoder *encoder,
 				   const struct drm_connector_state *conn_state)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_connector *connector = conn_state->connector;
 	enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
 	const u8 *eld = connector->eld;
@@ -651,12 +664,7 @@ static void hsw_audio_codec_enable(struct intel_encoder *encoder,
 	tmp &= ~AUDIO_ELD_VALID(cpu_transcoder);
 	intel_de_write(dev_priv, HSW_AUD_PIN_ELD_CP_VLD, tmp);
 
-	/*
-	 * FIXME: We're supposed to wait for vblank here, but we have vblanks
-	 * disabled during the mode set. The proper fix would be to push the
-	 * rest of the setup into a vblank work item, queued here, but the
-	 * infrastructure is not there yet.
-	 */
+	intel_crtc_wait_for_next_vblank(crtc);
 
 	/* Reset ELD write address */
 	tmp = intel_de_read(dev_priv, HSW_AUD_DIP_ELD_CTRL(cpu_transcoder));
@@ -705,6 +713,8 @@ static void ilk_audio_codec_disable(struct intel_encoder *encoder,
 		aud_cntrl_st2 = CPT_AUD_CNTRL_ST2;
 	}
 
+	mutex_lock(&dev_priv->display.audio.mutex);
+
 	/* Disable timestamps */
 	tmp = intel_de_read(dev_priv, aud_config);
 	tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
@@ -721,6 +731,10 @@ static void ilk_audio_codec_disable(struct intel_encoder *encoder,
 	tmp = intel_de_read(dev_priv, aud_cntrl_st2);
 	tmp &= ~eldv;
 	intel_de_write(dev_priv, aud_cntrl_st2, tmp);
+	mutex_unlock(&dev_priv->display.audio.mutex);
+
+	intel_crtc_wait_for_next_vblank(crtc);
+	intel_crtc_wait_for_next_vblank(crtc);
 }
 
 static void ilk_audio_codec_enable(struct intel_encoder *encoder,
@@ -740,12 +754,7 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
 	if (drm_WARN_ON(&dev_priv->drm, port == PORT_A))
 		return;
 
-	/*
-	 * FIXME: We're supposed to wait for vblank here, but we have vblanks
-	 * disabled during the mode set. The proper fix would be to push the
-	 * rest of the setup into a vblank work item, queued here, but the
-	 * infrastructure is not there yet.
-	 */
+	intel_crtc_wait_for_next_vblank(crtc);
 
 	if (HAS_PCH_IBX(dev_priv)) {
 		hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
@@ -767,6 +776,8 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
 
 	eldv = IBX_ELD_VALID(port);
 
+	mutex_lock(&dev_priv->display.audio.mutex);
+
 	/* Invalidate ELD */
 	tmp = intel_de_read(dev_priv, aud_cntrl_st2);
 	tmp &= ~eldv;
@@ -798,6 +809,8 @@ static void ilk_audio_codec_enable(struct intel_encoder *encoder,
 	else
 		tmp |= audio_config_hdmi_pixel_clock(crtc_state);
 	intel_de_write(dev_priv, aud_config, tmp);
+
+	mutex_unlock(&dev_priv->display.audio.mutex);
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2023-01-04 14:09 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 18:44 [PATCH] drm/i915/: dell wyse 3040 shutdown fix Alexey Lukyanchuk
2022-12-25 18:55 ` [PATCH v2] drm/i915: " Alexey Lukyanchuk
2022-12-25 18:55   ` Alexey Lukyanchuk
2022-12-25 18:55   ` [Intel-gfx] " Alexey Lukyanchuk
2022-12-27 16:39   ` Rodrigo Vivi
2022-12-27 16:39     ` Rodrigo Vivi
2022-12-27 16:39     ` Rodrigo Vivi
2022-12-27 17:40     ` Alexey Lukyachuk
2022-12-27 17:40       ` Alexey Lukyachuk
2022-12-27 17:40       ` Alexey Lukyachuk
2022-12-28  8:50       ` Jani Nikula
2022-12-28  8:50         ` Jani Nikula
2022-12-28  8:50         ` Jani Nikula
2023-01-02 13:56       ` Alexey Lukyachuk
2023-01-02 13:56         ` Alexey Lukyachuk
2023-01-02 13:56         ` Alexey Lukyachuk
2023-01-03 10:14         ` Jani Nikula
2023-01-03 10:14           ` Jani Nikula
2023-01-03 10:14           ` Jani Nikula
2023-01-03 10:24           ` Alexey Lukyachuk
2023-01-03 10:24             ` Alexey Lukyachuk
2023-01-03 10:24             ` Alexey Lukyachuk
2023-01-04 14:08             ` Jani Nikula
2023-01-04 14:08               ` Jani Nikula
2023-01-04 14:08               ` Jani Nikula
2023-01-03 12:46         ` Rodrigo Vivi
2023-01-03 12:46           ` Rodrigo Vivi
2023-01-03 12:46           ` Rodrigo Vivi
2023-01-03 13:43           ` Jani Nikula
2023-01-03 13:43             ` Jani Nikula
2023-01-03 13:43             ` Jani Nikula
2023-01-03 16:09           ` Alexey Lukyachuk
2023-01-03 16:09             ` Alexey Lukyachuk
2023-01-03 16:09             ` Alexey Lukyachuk
2023-01-03 16:18             ` Rodrigo Vivi
2023-01-03 16:18               ` Rodrigo Vivi
2023-01-03 16:18               ` Rodrigo Vivi
2022-12-25 19:05 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.