diff options
author | Imre Deak <imre.deak@intel.com> | 2018-11-20 04:23:24 -0500 |
---|---|---|
committer | Imre Deak <imre.deak@intel.com> | 2018-11-21 06:38:20 -0500 |
commit | c0871805ce1c716889c02450e507b420cb5e6d26 (patch) | |
tree | 8a387f41788fd20a526e1921e293c70e3d31d69f /drivers | |
parent | 931f54920ba82427b2b9371e8d357b15853b1c15 (diff) |
drm/i915: Make EDP PSR flags not depend on enum values
Depending on the transcoder enum values to translate from transcoder
to EDP PSR flags can easily break if we add a new transcoder. So remove
the dependency by using an explicit mapping.
While at it also add a WARN for unexpected trancoders.
v2:
- Simplify things by defining flag shift values instead of indices.
- s/trans/cpu_transcoder/ (Ville)
v3:
- Define flags to look like separate bits instead of the values of
the same bitfield. (Ville)
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181120092325.21249-2-imre.deak@intel.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/i915_reg.h | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_psr.c | 55 |
2 files changed, 44 insertions, 21 deletions
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index edb58af1e903..e6b371e986ee 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
@@ -4150,9 +4150,13 @@ enum { | |||
4150 | /* Bspec claims those aren't shifted but stay at 0x64800 */ | 4150 | /* Bspec claims those aren't shifted but stay at 0x64800 */ |
4151 | #define EDP_PSR_IMR _MMIO(0x64834) | 4151 | #define EDP_PSR_IMR _MMIO(0x64834) |
4152 | #define EDP_PSR_IIR _MMIO(0x64838) | 4152 | #define EDP_PSR_IIR _MMIO(0x64838) |
4153 | #define EDP_PSR_ERROR(trans) (1 << (((trans) * 8 + 10) & 31)) | 4153 | #define EDP_PSR_ERROR(shift) (1 << ((shift) + 2)) |
4154 | #define EDP_PSR_POST_EXIT(trans) (1 << (((trans) * 8 + 9) & 31)) | 4154 | #define EDP_PSR_POST_EXIT(shift) (1 << ((shift) + 1)) |
4155 | #define EDP_PSR_PRE_ENTRY(trans) (1 << (((trans) * 8 + 8) & 31)) | 4155 | #define EDP_PSR_PRE_ENTRY(shift) (1 << (shift)) |
4156 | #define EDP_PSR_TRANSCODER_C_SHIFT 24 | ||
4157 | #define EDP_PSR_TRANSCODER_B_SHIFT 16 | ||
4158 | #define EDP_PSR_TRANSCODER_A_SHIFT 8 | ||
4159 | #define EDP_PSR_TRANSCODER_EDP_SHIFT 0 | ||
4156 | 4160 | ||
4157 | #define EDP_PSR_AUX_CTL _MMIO(dev_priv->psr_mmio_base + 0x10) | 4161 | #define EDP_PSR_AUX_CTL _MMIO(dev_priv->psr_mmio_base + 0x10) |
4158 | #define EDP_PSR_AUX_CTL_TIME_OUT_MASK (3 << 26) | 4162 | #define EDP_PSR_AUX_CTL_TIME_OUT_MASK (3 << 26) |
diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c index 48df16a02fac..26292961d693 100644 --- a/drivers/gpu/drm/i915/intel_psr.c +++ b/drivers/gpu/drm/i915/intel_psr.c | |||
@@ -83,25 +83,42 @@ static bool intel_psr2_enabled(struct drm_i915_private *dev_priv, | |||
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | static int edp_psr_shift(enum transcoder cpu_transcoder) | ||
87 | { | ||
88 | switch (cpu_transcoder) { | ||
89 | case TRANSCODER_A: | ||
90 | return EDP_PSR_TRANSCODER_A_SHIFT; | ||
91 | case TRANSCODER_B: | ||
92 | return EDP_PSR_TRANSCODER_B_SHIFT; | ||
93 | case TRANSCODER_C: | ||
94 | return EDP_PSR_TRANSCODER_C_SHIFT; | ||
95 | default: | ||
96 | MISSING_CASE(cpu_transcoder); | ||
97 | /* fallthrough */ | ||
98 | case TRANSCODER_EDP: | ||
99 | return EDP_PSR_TRANSCODER_EDP_SHIFT; | ||
100 | } | ||
101 | } | ||
102 | |||
86 | void intel_psr_irq_control(struct drm_i915_private *dev_priv, u32 debug) | 103 | void intel_psr_irq_control(struct drm_i915_private *dev_priv, u32 debug) |
87 | { | 104 | { |
88 | u32 debug_mask, mask; | 105 | u32 debug_mask, mask; |
106 | enum transcoder cpu_transcoder; | ||
107 | u32 transcoders = BIT(TRANSCODER_EDP); | ||
89 | 108 | ||
90 | mask = EDP_PSR_ERROR(TRANSCODER_EDP); | 109 | if (INTEL_GEN(dev_priv) >= 8) |
91 | debug_mask = EDP_PSR_POST_EXIT(TRANSCODER_EDP) | | 110 | transcoders |= BIT(TRANSCODER_A) | |
92 | EDP_PSR_PRE_ENTRY(TRANSCODER_EDP); | 111 | BIT(TRANSCODER_B) | |
93 | 112 | BIT(TRANSCODER_C); | |
94 | if (INTEL_GEN(dev_priv) >= 8) { | 113 | |
95 | mask |= EDP_PSR_ERROR(TRANSCODER_A) | | 114 | debug_mask = 0; |
96 | EDP_PSR_ERROR(TRANSCODER_B) | | 115 | mask = 0; |
97 | EDP_PSR_ERROR(TRANSCODER_C); | 116 | for_each_cpu_transcoder_masked(dev_priv, cpu_transcoder, transcoders) { |
98 | 117 | int shift = edp_psr_shift(cpu_transcoder); | |
99 | debug_mask |= EDP_PSR_POST_EXIT(TRANSCODER_A) | | 118 | |
100 | EDP_PSR_PRE_ENTRY(TRANSCODER_A) | | 119 | mask |= EDP_PSR_ERROR(shift); |
101 | EDP_PSR_POST_EXIT(TRANSCODER_B) | | 120 | debug_mask |= EDP_PSR_POST_EXIT(shift) | |
102 | EDP_PSR_PRE_ENTRY(TRANSCODER_B) | | 121 | EDP_PSR_PRE_ENTRY(shift); |
103 | EDP_PSR_POST_EXIT(TRANSCODER_C) | | ||
104 | EDP_PSR_PRE_ENTRY(TRANSCODER_C); | ||
105 | } | 122 | } |
106 | 123 | ||
107 | if (debug & I915_PSR_DEBUG_IRQ) | 124 | if (debug & I915_PSR_DEBUG_IRQ) |
@@ -159,18 +176,20 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) | |||
159 | BIT(TRANSCODER_C); | 176 | BIT(TRANSCODER_C); |
160 | 177 | ||
161 | for_each_cpu_transcoder_masked(dev_priv, cpu_transcoder, transcoders) { | 178 | for_each_cpu_transcoder_masked(dev_priv, cpu_transcoder, transcoders) { |
179 | int shift = edp_psr_shift(cpu_transcoder); | ||
180 | |||
162 | /* FIXME: Exit PSR and link train manually when this happens. */ | 181 | /* FIXME: Exit PSR and link train manually when this happens. */ |
163 | if (psr_iir & EDP_PSR_ERROR(cpu_transcoder)) | 182 | if (psr_iir & EDP_PSR_ERROR(shift)) |
164 | DRM_DEBUG_KMS("[transcoder %s] PSR aux error\n", | 183 | DRM_DEBUG_KMS("[transcoder %s] PSR aux error\n", |
165 | transcoder_name(cpu_transcoder)); | 184 | transcoder_name(cpu_transcoder)); |
166 | 185 | ||
167 | if (psr_iir & EDP_PSR_PRE_ENTRY(cpu_transcoder)) { | 186 | if (psr_iir & EDP_PSR_PRE_ENTRY(shift)) { |
168 | dev_priv->psr.last_entry_attempt = time_ns; | 187 | dev_priv->psr.last_entry_attempt = time_ns; |
169 | DRM_DEBUG_KMS("[transcoder %s] PSR entry attempt in 2 vblanks\n", | 188 | DRM_DEBUG_KMS("[transcoder %s] PSR entry attempt in 2 vblanks\n", |
170 | transcoder_name(cpu_transcoder)); | 189 | transcoder_name(cpu_transcoder)); |
171 | } | 190 | } |
172 | 191 | ||
173 | if (psr_iir & EDP_PSR_POST_EXIT(cpu_transcoder)) { | 192 | if (psr_iir & EDP_PSR_POST_EXIT(shift)) { |
174 | dev_priv->psr.last_exit = time_ns; | 193 | dev_priv->psr.last_exit = time_ns; |
175 | DRM_DEBUG_KMS("[transcoder %s] PSR exit completed\n", | 194 | DRM_DEBUG_KMS("[transcoder %s] PSR exit completed\n", |
176 | transcoder_name(cpu_transcoder)); | 195 | transcoder_name(cpu_transcoder)); |