Skip to contentSkip to conversation

drm/i915/ddi: Get AUX power domain for DP main link too

PATCH Superseded Imre Deak 4 participants 13 messages Jun 21, 2018 – Jun 22, 2018

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Imre Deak

author
#0 lore raw

PATCH 1/2 drm/i915/ddi: Get AUX power domain for DP main link too

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power wells.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +29 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +11 -1
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +2 -1
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 6 lines
2.13.2

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

PATCH 2/2 drm/i915/cnl: Don't get separate AUX power domain ref for DP PSR

After the previous patch we don't need to get an explicit AUX power reference for PSR functionality, since we hold now an AUX reference whenever the main link is active on any DP ports.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.h    |  1 -
 drivers/gpu/drm/i915/intel_psr.c        | 41 ---------------------------------
 drivers/gpu/drm/i915/intel_runtime_pm.c |  3 ---
 3 files changed, 45 deletions(-)
drivers/gpu/drm/i915/intel_display.h +0 -1
index dfb02da73ac8..29501bf368b2 100644
@@ -198,7 +198,6 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_AUX_E,
 	POWER_DOMAIN_AUX_F,
-	POWER_DOMAIN_AUX_IO_A,
 	POWER_DOMAIN_GMBUS,
 	POWER_DOMAIN_MODESET,
 	POWER_DOMAIN_GT_IRQ,
drivers/gpu/drm/i915/intel_psr.c +0 -41

59 lines not on this page · raw message

drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
index de3a81034f77..58a8f07eafa4 100644
@@ -132,8 +132,6 @@ intel_display_power_domain_str(enum intel_display_power_domain domain)
 		return "AUX_E";
 	case POWER_DOMAIN_AUX_F:
 		return "AUX_F";
-	case POWER_DOMAIN_AUX_IO_A:
-		return "AUX_IO_A";
 	case POWER_DOMAIN_GMBUS:
 		return "GMBUS";
 	case POWER_DOMAIN_INIT:
@@ -1872,7 +1870,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT_ULL(POWER_DOMAIN_INIT))
 #define CNL_DISPLAY_AUX_A_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_A) |			\
-	BIT_ULL(POWER_DOMAIN_AUX_IO_A) |		\
 	BIT_ULL(POWER_DOMAIN_INIT))
 #define CNL_DISPLAY_AUX_B_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_B) |			\
Signature · 6 lines
2.13.2

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

Re: [PATCH 2/2] drm/i915/cnl: Don't get separate AUX power domain ref for DP PSR

Quoted 37 lines · Imre Deak

After the previous patch we don't need to get an explicit AUX power reference for PSR functionality, since we hold now an AUX reference whenever the main link is active on any DP ports.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.h    |  1 -
 drivers/gpu/drm/i915/intel_psr.c        | 41 ---------------------------------
 drivers/gpu/drm/i915/intel_runtime_pm.c |  3 ---
 3 files changed, 45 deletions(-)
drivers/gpu/drm/i915/intel_display.h +0 -1
index dfb02da73ac8..29501bf368b2 100644
@@ -198,7 +198,6 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_AUX_E,
 	POWER_DOMAIN_AUX_F,
-	POWER_DOMAIN_AUX_IO_A,
 	POWER_DOMAIN_GMBUS,
 	POWER_DOMAIN_MODESET,
 	POWER_DOMAIN_GT_IRQ,
drivers/gpu/drm/i915/intel_psr.c +0 -3
index d4cd19fea148..eecdd8b5b5e0 100644
@@ -56,43 +56,6 @@
 #include "intel_drv.h"
 #include "i915_drv.h"
 
-static inline enum intel_display_power_domain
-psr_aux_domain(struct intel_dp *intel_dp)
-{

drivers/gpu/drm/i915/intel_psr.c line 71

Quoted 10 lines
drivers/gpu/drm/i915/intel_psr.c +0 -10
-	/* CNL HW requires corresponding AUX IOs to be powered up for PSR.
-	 * However, for non-A AUX ports the corresponding non-EDP transcoders
-	 * would have already enabled power well 2 and DC_OFF. This means we can
-	 * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference instead of a
-	 * specific AUX_IO reference without powering up any extra wells.
-	 * Note that PSR is enabled only on Port A even though this function
-	 * returns the correct domain for other ports too.
-	 */
-	return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A :
-					      intel_dp->aux_power_domain;

Hmm. Isn't this going to prevent DC5 during PSR?

Quoted 68 lines
drivers/gpu/drm/i915/intel_psr.c +0 -28
-}
-
-static void psr_aux_io_power_get(struct intel_dp *intel_dp)
-{
-	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-	struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
-
-	if (INTEL_GEN(dev_priv) < 10)
-		return;
-
-	intel_display_power_get(dev_priv, psr_aux_domain(intel_dp));
-}
-
-static void psr_aux_io_power_put(struct intel_dp *intel_dp)
-{
-	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-	struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
-
-	if (INTEL_GEN(dev_priv) < 10)
-		return;
-
-	intel_display_power_put(dev_priv, psr_aux_domain(intel_dp));
-}
-
 void intel_psr_irq_control(struct drm_i915_private *dev_priv, bool debug)
 {
 	u32 debug_mask, mask;
@@ -595,8 +558,6 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
 
-	psr_aux_io_power_get(intel_dp);
-
 	/* Only HSW and BDW have PSR AUX registers that need to be setup. SKL+
 	 * use hardcoded values PSR AUX transactions
 	 */
@@ -717,8 +678,6 @@ static void hsw_psr_disable(struct intel_dp *intel_dp,
 		else
 			WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
 	}
-
-	psr_aux_io_power_put(intel_dp);
 }
 
 /**
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -3
index de3a81034f77..58a8f07eafa4 100644
@@ -132,8 +132,6 @@ intel_display_power_domain_str(enum intel_display_power_domain domain)
 		return "AUX_E";
 	case POWER_DOMAIN_AUX_F:
 		return "AUX_F";
-	case POWER_DOMAIN_AUX_IO_A:
-		return "AUX_IO_A";
 	case POWER_DOMAIN_GMBUS:
 		return "GMBUS";
 	case POWER_DOMAIN_INIT:
@@ -1872,7 +1870,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT_ULL(POWER_DOMAIN_INIT))
 #define CNL_DISPLAY_AUX_A_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_A) |			\
-	BIT_ULL(POWER_DOMAIN_AUX_IO_A) |		\
 	BIT_ULL(POWER_DOMAIN_INIT))
 #define CNL_DISPLAY_AUX_B_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_B) |			\
Signature · 1 line
2.13.2
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#3 lore raw

Re: [PATCH 2/2] drm/i915/cnl: Don't get separate AUX power domain ref for DP PSR

Quoted 35 lines · Ville Syrjälä
Quoted 34 lines · Imre Deak

After the previous patch we don't need to get an explicit AUX power reference for PSR functionality, since we hold now an AUX reference whenever the main link is active on any DP ports.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.h    |  1 -
 drivers/gpu/drm/i915/intel_psr.c        | 41 ---------------------------------
 drivers/gpu/drm/i915/intel_runtime_pm.c |  3 ---
 3 files changed, 45 deletions(-)
drivers/gpu/drm/i915/intel_display.h +0 -1
index dfb02da73ac8..29501bf368b2 100644
@@ -198,7 +198,6 @@ enum intel_display_power_domain {
 	POWER_DOMAIN_AUX_D,
 	POWER_DOMAIN_AUX_E,
 	POWER_DOMAIN_AUX_F,
-	POWER_DOMAIN_AUX_IO_A,
 	POWER_DOMAIN_GMBUS,
 	POWER_DOMAIN_MODESET,
 	POWER_DOMAIN_GT_IRQ,
drivers/gpu/drm/i915/intel_psr.c +0 -0
index d4cd19fea148..eecdd8b5b5e0 100644
@@ -56,43 +56,6 @@
 #include "intel_drv.h"
 #include "i915_drv.h"
 
Quoted 15 lines

drivers/gpu/drm/i915/intel_psr.c line 71

Quoted 13 lines
drivers/gpu/drm/i915/intel_psr.c +0 -13
-static inline enum intel_display_power_domain
-psr_aux_domain(struct intel_dp *intel_dp)
-{
-	/* CNL HW requires corresponding AUX IOs to be powered up for PSR.
-	 * However, for non-A AUX ports the corresponding non-EDP transcoders
-	 * would have already enabled power well 2 and DC_OFF. This means we can
-	 * acquire a wider POWER_DOMAIN_AUX_{B,C,D,F} reference instead of a
-	 * specific AUX_IO reference without powering up any extra wells.
-	 * Note that PSR is enabled only on Port A even though this function
-	 * returns the correct domain for other ports too.
-	 */
-	return intel_dp->aux_ch == AUX_CH_A ? POWER_DOMAIN_AUX_IO_A :
-					      intel_dp->aux_power_domain;

Hmm. Isn't this going to prevent DC5 during PSR?

Yep, it would. So we still need a separate AUX_IO domain which we would take during encoder enabling, whereas the AUX domain - which prevents DC states - would be used only for AUX transfers.

Quoted 61 lines
Quoted 61 lines
drivers/gpu/drm/i915/intel_psr.c +0 -28
-}
-
-static void psr_aux_io_power_get(struct intel_dp *intel_dp)
-{
-	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-	struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
-
-	if (INTEL_GEN(dev_priv) < 10)
-		return;
-
-	intel_display_power_get(dev_priv, psr_aux_domain(intel_dp));
-}
-
-static void psr_aux_io_power_put(struct intel_dp *intel_dp)
-{
-	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-	struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
-
-	if (INTEL_GEN(dev_priv) < 10)
-		return;
-
-	intel_display_power_put(dev_priv, psr_aux_domain(intel_dp));
-}
-
 void intel_psr_irq_control(struct drm_i915_private *dev_priv, bool debug)
 {
 	u32 debug_mask, mask;
@@ -595,8 +558,6 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
 
-	psr_aux_io_power_get(intel_dp);
-
 	/* Only HSW and BDW have PSR AUX registers that need to be setup. SKL+
 	 * use hardcoded values PSR AUX transactions
 	 */
@@ -717,8 +678,6 @@ static void hsw_psr_disable(struct intel_dp *intel_dp,
 		else
 			WARN_ON(I915_READ(EDP_PSR_CTL) & EDP_PSR_ENABLE);
 	}
-
-	psr_aux_io_power_put(intel_dp);
 }
 
 /**
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -2
index de3a81034f77..58a8f07eafa4 100644
@@ -132,8 +132,6 @@ intel_display_power_domain_str(enum intel_display_power_domain domain)
 		return "AUX_E";
 	case POWER_DOMAIN_AUX_F:
 		return "AUX_F";
-	case POWER_DOMAIN_AUX_IO_A:
-		return "AUX_IO_A";
 	case POWER_DOMAIN_GMBUS:
 		return "GMBUS";
 	case POWER_DOMAIN_INIT:
@@ -1872,7 +1870,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 	BIT_ULL(POWER_DOMAIN_INIT))
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +0 -1
 #define CNL_DISPLAY_AUX_A_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_A) |			\
-	BIT_ULL(POWER_DOMAIN_AUX_IO_A) |		\
 	BIT_ULL(POWER_DOMAIN_INIT))
 #define CNL_DISPLAY_AUX_B_POWER_DOMAINS (		\
 	BIT_ULL(POWER_DOMAIN_AUX_B) |			\
Signature · 1 line
2.13.2
Signature · 2 lines
Ville Syrjälä
Intel

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

#4 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too

In reply to Imre Deak
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too
URL : https://patchwork.freedesktop.org/series/45181/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
2fcf2866905b drm/i915/ddi: Get AUX power domain for DP main link too
-:10: WARNING:TYPO_SPELLING: 'followings' may be misspelled - perhaps 'following'?
#10: 
AUX transfers. However, the followings suggest that we also need these

total: 0 errors, 1 warnings, 0 checks, 87 lines checked f1178ae6d5f0 drm/i915/cnl: Don't get separate AUX power domain ref for DP PSR

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

#5 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too

In reply to Imre Deak
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too
URL : https://patchwork.freedesktop.org/series/45181/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4362 -> Patchwork_9385 =

== Summary - SUCCESS ==

No regressions found.

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

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_gttfill@basic:
      fi-byt-n2820:       PASS -> FAIL (fdo#106744)

    
    ==== Possible fixes ====

    igt@gem_ctx_create@basic-files:
      fi-skl-6700k2:      INCOMPLETE (fdo#106988) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#106744 https://bugs.freedesktop.org/show_bug.cgi?id=106744
fdo#106988 https://bugs.freedesktop.org/show_bug.cgi?id=106988

== Participating hosts (42 -> 37) ==

Additional (1): fi-bxt-dsi
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-glk-dsi fi-bsw-cyan fi-ctg-p8600 fi-kbl-x1275

== Build changes ==

* Linux: CI_DRM_4362 -> Patchwork_9385

CI_DRM_4362: 7159c27349b070831dfb3512ca055c8dbcf9e1fc @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4528: 6be300d405de5974b262e8b93a445be4ac618e6a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9385: f1178ae6d5f0ad56370f2557d746cf5fc09c0923 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

f1178ae6d5f0 drm/i915/cnl: Don't get separate AUX power domain ref for DP PSR 2fcf2866905b drm/i915/ddi: Get AUX power domain for DP main link too

== Logs ==

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

#6 lore raw
In reply to Imre Deak
Quoted 105 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power wells.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +29 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +1 -0
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;

drivers/gpu/drm/i915/intel_display.c get_encoder_power_domains(struct drm_i915_private *dev_priv) · line 15691

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +8 -1
 
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;

Actually I think we can just drop this NULL crtc state case. If the encoder is active it will have a crtc assigned, and only then do we actually shut it down if the connector/crtc is not active. So if we we ever did get into a situation where we didn't have the crtc we'd leak the power references. Also we need the crtc state to shut down the encoder.

The entire sanitize_encoder() thing is a bit wonky. In case we have an active encoder without a connector it won't actually do anything. I suppose that could at least happen with sdvo. With ddi it would required the port to be enabled with the wrong mode which I suppose is a slightly less realistic option.

Another case when we wouldn't do anything is if the port is enabled without any transcoder having selected it. That could happen with CPT/PPT DP or DDI. Other port types have the pipe select bits on the port so it's not possible to get into that situation.

Since we don't seem to have any mysterious bug reports about ports being wonky maybe these things just don't happen in practice. Or everything just happens to work out by accient even if don't shut things down cleanly.

Quoted 21 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +2 -1
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#7 lore raw
Quoted 107 lines · Ville Syrjälä
Quoted 106 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power wells.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +29 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +1 -0
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
Quoted 16 lines

drivers/gpu/drm/i915/intel_display.c get_encoder_power_domains(struct drm_i915_private *dev_priv) · line 15691

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +8 -1
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;

Actually I think we can just drop this NULL crtc state case. If the encoder is active it will have a crtc assigned, and only then do we actually shut it down if the connector/crtc is not active. So if we we ever did get into a situation where we didn't have the crtc we'd leak the power references. Also we need the crtc state to shut down the encoder.

Err, thanks for catching that. Confused myself reading intel_sanitize_encoder(), thinking that we'll disable there encoders without a crtc, but that's not the case as you pointed out. Since encoder->base.crtc can be NULL for MST I will still keep the above and rely on intel_ddi_get_hw_state() to skip taking power refs for that case. Will update the comment accrodingly.

Quoted 29 lines

The entire sanitize_encoder() thing is a bit wonky. In case we have an active encoder without a connector it won't actually do anything. I suppose that could at least happen with sdvo. With ddi it would required the port to be enabled with the wrong mode which I suppose is a slightly less realistic option.

Another case when we wouldn't do anything is if the port is enabled without any transcoder having selected it. That could happen with CPT/PPT DP or DDI. Other port types have the pipe select bits on the port so it's not possible to get into that situation.

Since we don't seem to have any mysterious bug reports about ports being wonky maybe these things just don't happen in practice. Or everything just happens to work out by accient even if don't shut things down cleanly.

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +2 -1
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 2 lines
Ville Syrjälä
Intel

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

#8 lore raw
Quoted 18 lines · Imre Deak
Quoted 17 lines · Ville Syrjälä
Quoted 16 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power well

Currently I get AUX timeouts and unable to start link training
on DP without disable_power_well=0 option set.
I think the reason was that we were not getting the power domain for the AUX. So hopefully this patch should fix it.

Manasi

Quoted 152 lines
Quoted 87 lines
Quoted 87 lines
Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +29 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +1 -0
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
Quoted 16 lines

drivers/gpu/drm/i915/intel_display.c get_encoder_power_domains(struct drm_i915_private *dev_priv) · line 15691

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +8 -1
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;

Actually I think we can just drop this NULL crtc state case. If the encoder is active it will have a crtc assigned, and only then do we actually shut it down if the connector/crtc is not active. So if we we ever did get into a situation where we didn't have the crtc we'd leak the power references. Also we need the crtc state to shut down the encoder.

Err, thanks for catching that. Confused myself reading intel_sanitize_encoder(), thinking that we'll disable there encoders without a crtc, but that's not the case as you pointed out. Since encoder->base.crtc can be NULL for MST I will still keep the above and rely on intel_ddi_get_hw_state() to skip taking power refs for that case. Will update the comment accrodingly.

Quoted 29 lines

The entire sanitize_encoder() thing is a bit wonky. In case we have an active encoder without a connector it won't actually do anything. I suppose that could at least happen with sdvo. With ddi it would required the port to be enabled with the wrong mode which I suppose is a slightly less realistic option.

Another case when we wouldn't do anything is if the port is enabled without any transcoder having selected it. That could happen with CPT/PPT DP or DDI. Other port types have the pipe select bits on the port so it's not possible to get into that situation.

Since we don't seem to have any mysterious bug reports about ports being wonky maybe these things just don't happen in practice. Or everything just happens to work out by accient even if don't shut things down cleanly.

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +2 -1
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 2 lines
Ville Syrjälä
Intel
Quoted 4 lines

_______________________________________________
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

author
#9 lore raw
Quoted 19 lines · Manasi Navare
Quoted 18 lines · Imre Deak
Quoted 17 lines · Ville Syrjälä
Quoted 16 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power well

Currently I get AUX timeouts and unable to start link training on DP without disable_power_well=0 option set. I think the reason was that we were not getting the power domain for the AUX. So hopefully this patch should fix it.

Yes, that's because during link training - where the port is enabled with a training pattern set - we can't enable the AUX power well, it'll time out. B/c of that AUX transfers will time out too. After disabling the training pattern and enabling the port for real video signals, AUX enabling starts to work again..

--Imre

Quoted 159 lines

Manasi

Quoted 156 lines
Quoted 87 lines
Quoted 87 lines
Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +29 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +1 -0
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
Quoted 16 lines

drivers/gpu/drm/i915/intel_display.c get_encoder_power_domains(struct drm_i915_private *dev_priv) · line 15691

Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +8 -1
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;

Actually I think we can just drop this NULL crtc state case. If the encoder is active it will have a crtc assigned, and only then do we actually shut it down if the connector/crtc is not active. So if we we ever did get into a situation where we didn't have the crtc we'd leak the power references. Also we need the crtc state to shut down the encoder.

Err, thanks for catching that. Confused myself reading intel_sanitize_encoder(), thinking that we'll disable there encoders without a crtc, but that's not the case as you pointed out. Since encoder->base.crtc can be NULL for MST I will still keep the above and rely on intel_ddi_get_hw_state() to skip taking power refs for that case. Will update the comment accrodingly.

Quoted 29 lines

The entire sanitize_encoder() thing is a bit wonky. In case we have an active encoder without a connector it won't actually do anything. I suppose that could at least happen with sdvo. With ddi it would required the port to be enabled with the wrong mode which I suppose is a slightly less realistic option.

Another case when we wouldn't do anything is if the port is enabled without any transcoder having selected it. That could happen with CPT/PPT DP or DDI. Other port types have the pipe select bits on the port so it's not possible to get into that situation.

Since we don't seem to have any mysterious bug reports about ports being wonky maybe these things just don't happen in practice. Or everything just happens to work out by accient even if don't shut things down cleanly.

Quoted 13 lines
drivers/gpu/drm/i915/intel_display.c +2 -0
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +2 -1
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 2 lines
Ville Syrjälä
Intel

_______________________________________________
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

#10 lore raw
In reply to Imre Deak
Quoted 56 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power wells.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +9 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct intel_encoder *encoder, · line 2009

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {

I would use intel_crtc_has_dp_encoder() here so that one doesn't have to think "what is not HDMI?".

Quoted 70 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +11 -1
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +2 -1
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#11 lore raw
Quoted 62 lines · Ville Syrjälä
Quoted 61 lines · Imre Deak

So far we got an AUX power domain reference only for the duration of DP AUX transfers. However, the followings suggest that we also need these for main link functionality:
- The specification doesn't state whether it's needed or not for main link functionality, but suggests that these power wells need to be enabled already during display core initialization (Sequences to Initialize Display).
- For PSR we need to keep the AUX power well enabled.
- On ICL combo PHY ports (non-TC) the AUX power well is needed for link training too: while the port is enabled with a DP link training test pattern trying to toggle the AUX power well will time out.
- On ICL MG PHY ports (TC) the AUX power well is needed also for main link functionality (both in DP and HDMI modes).
- Windows enables these power wells both for main and AUX lane functionality.

Based on the above take an AUX power reference for main link functionality too. This makes a difference only on GEN10+ (GLK+) platforms, where we have separate port specific AUX power wells.

Cc Ville Syrjälä <[email protected]>
Cc Dhinakaran Pandiyan <[email protected]>
Cc Paulo Zanoni <[email protected]>
---
 drivers/gpu/drm/i915/intel_ddi.c     | 33 +++++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  3 ++-
 3 files changed, 42 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +14 -4
index 044fe1fb9872..b09cb6969bbb 100644
@@ -1983,15 +1983,36 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
 	return ret;
 }
 
-static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder)
+static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder,
+				       struct intel_crtc_state *crtc_state)
 {
 	struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base);
 	enum pipe pipe;
+	u64 domains;
 
-	if (intel_ddi_get_hw_state(encoder, &pipe))
-		return BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!intel_ddi_get_hw_state(encoder, &pipe))
+		return 0;
 
-	return 0;
+	domains = BIT_ULL(dig_port->ddi_io_power_domain);
+	if (!crtc_state)
+		return domains;
+
+	/*
+	 * TODO: Add support for MST encoders. Atm, the following should never
+	 * happen since this function will be called only for the primary
+	 * encoder which doesn't have its own pipe/crtc_state.
+	 */
Quoted 8 lines

drivers/gpu/drm/i915/intel_ddi.c bool intel_ddi_get_hw_state(struct intel_encoder *encoder, · line 2009

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -0
+	if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)))
+		return domains;
+
+	/* AUX power is only needed for (e)DP mode, not for HDMI. */
+	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {

I would use intel_crtc_has_dp_encoder() here so that one doesn't have to think "what is not HDMI?".

Ok, makes sense.

Quoted 63 lines
Quoted 63 lines
drivers/gpu/drm/i915/intel_ddi.c +10 -0
+		struct intel_dp *intel_dp = &dig_port->dp;
+
+		domains |= BIT_ULL(intel_dp->aux_power_domain);
+	}
+
+	return domains;
 }
 
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state)
@@ -2631,6 +2652,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
 
 	WARN_ON(is_mst && (port == PORT_A || port == PORT_E));
 
+	intel_display_power_get(dev_priv, intel_dp->aux_power_domain);
+
 	intel_dp_set_link_params(intel_dp, crtc_state->port_clock,
 				 crtc_state->lane_count, is_mst);
 
@@ -2775,6 +2798,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
 	intel_display_power_put(dev_priv, dig_port->ddi_io_power_domain);
 
 	intel_ddi_clk_disable(encoder);
+
+	intel_display_power_put(dev_priv, intel_dp->aux_power_domain);
 }
 
 static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_display.c +11 -1
index 2c8fef3ede54..d9fefcec4b1a 100644
@@ -15676,11 +15676,21 @@ get_encoder_power_domains(struct drm_i915_private *dev_priv)
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
 		u64 get_domains;
 		enum intel_display_power_domain domain;
+		struct intel_crtc_state *crtc_state;
 
 		if (!encoder->get_power_domains)
 			continue;
 
-		get_domains = encoder->get_power_domains(encoder);
+		/*
+		 * In case of a dangling encoder without a crtc we still need
+		 * to get power domain refs. Such encoders will be disabled
+		 * dropping these references.
+		 */
+		crtc_state = encoder->base.crtc ?
+			     to_intel_crtc_state(encoder->base.crtc->state) :
+			     NULL;
+
+		get_domains = encoder->get_power_domains(encoder, crtc_state);
 		for_each_power_domain(domain, get_domains)
 			intel_display_power_get(dev_priv, domain);
 	}
drivers/gpu/drm/i915/intel_drv.h +0 -0
index 0c3ac0eafde0..7174429d930a 100644
@@ -254,7 +254,8 @@ struct intel_encoder {
 			   struct intel_crtc_state *pipe_config);
 	/* Returns a mask of power domains that need to be referenced as part
 	 * of the hardware state readout code. */
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +2 -1
-	u64 (*get_power_domains)(struct intel_encoder *encoder);
+	u64 (*get_power_domains)(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state);
 	/*
 	 * Called during system suspend after all pending requests for the
 	 * encoder are flushed (for example for DP AUX transactions) and
Signature · 1 line
2.13.2
Signature · 2 lines
Ville Syrjälä
Intel

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

#12 lore raw

✓ Fi.CI.IGT: success for series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too

In reply to Imre Deak
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915/ddi: Get AUX power domain for DP main link too
URL : https://patchwork.freedesktop.org/series/45181/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4362_full -> Patchwork_9385_full =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_9385_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9385_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9385_full:

=== IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS +1

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_gtt:
      shard-kbl:          PASS -> FAIL (fdo#105347)

    igt@drv_selftest@live_hangcheck:
      shard-kbl:          PASS -> DMESG-FAIL (fdo#106560, fdo#106947)

    igt@gem_workarounds@suspend-resume-context:
      shard-apl:          PASS -> FAIL (fdo#103375)

    igt@kms_flip@flip-vs-expired-vblank:
      shard-glk:          PASS -> FAIL (fdo#105189)

    igt@kms_flip_tiling@flip-x-tiled:
      shard-glk:          PASS -> FAIL (fdo#104724)

    igt@kms_setmode@basic:
      shard-hsw:          PASS -> FAIL (fdo#99912)

    
    ==== Possible fixes ====

    igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
      shard-glk:          FAIL (fdo#105454, fdo#106509) -> PASS

    igt@kms_flip@dpms-vs-vblank-race:
      shard-kbl:          FAIL (fdo#103060) -> PASS

fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105189 https://bugs.freedesktop.org/show_bug.cgi?id=105189
fdo#105347 https://bugs.freedesktop.org/show_bug.cgi?id=105347
fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4362 -> Patchwork_9385

CI_DRM_4362: 7159c27349b070831dfb3512ca055c8dbcf9e1fc @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4528: 6be300d405de5974b262e8b93a445be4ac618e6a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9385: f1178ae6d5f0ad56370f2557d746cf5fc09c0923 @ 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_9385/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx