drm/i915/tgl: Access the right register when handling PSR interruptions

For older gens PSR IIR and IMR have fixed addresses. From TGL onwards those
registers moved to each transcoder offset. The bits for the registers
are defined without an offset per transcoder as right now we have one
register per transcoder. So add a fake "trans_shift" when calculating
the bits offsets: it will be 0 for gen12+ and psr.transcoder otherwise.

v2 (Lucas): change the implementation to use trans_shift instead of
getting each bit value with a different macro

Cc: Imre Deak <imre.deak@intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190904213419.27547-3-jose.souza@intel.com
parent 2f3b8712
...@@ -90,18 +90,33 @@ static bool intel_psr2_enabled(struct drm_i915_private *dev_priv, ...@@ -90,18 +90,33 @@ static bool intel_psr2_enabled(struct drm_i915_private *dev_priv,
static void psr_irq_control(struct drm_i915_private *dev_priv) static void psr_irq_control(struct drm_i915_private *dev_priv)
{ {
enum transcoder trans = dev_priv->psr.transcoder; enum transcoder trans_shift;
u32 val, mask; u32 mask, val;
i915_reg_t imr_reg;
mask = EDP_PSR_ERROR(trans); /*
* gen12+ has registers relative to transcoder and one per transcoder
* using the same bit definition: handle it as TRANSCODER_EDP to force
* 0 shift in bit definition
*/
if (INTEL_GEN(dev_priv) >= 12) {
trans_shift = 0;
imr_reg = TRANS_PSR_IMR(dev_priv->psr.transcoder);
} else {
trans_shift = dev_priv->psr.transcoder;
imr_reg = EDP_PSR_IMR;
}
mask = EDP_PSR_ERROR(trans_shift);
if (dev_priv->psr.debug & I915_PSR_DEBUG_IRQ) if (dev_priv->psr.debug & I915_PSR_DEBUG_IRQ)
mask |= EDP_PSR_POST_EXIT(trans) | EDP_PSR_PRE_ENTRY(trans); mask |= EDP_PSR_POST_EXIT(trans_shift) |
EDP_PSR_PRE_ENTRY(trans_shift);
/* Warning: it is masking/setting reserved bits too */ /* Warning: it is masking/setting reserved bits too */
val = I915_READ(EDP_PSR_IMR); val = I915_READ(imr_reg);
val &= ~EDP_PSR_TRANS_MASK(trans); val &= ~EDP_PSR_TRANS_MASK(trans_shift);
val |= ~mask; val |= ~mask;
I915_WRITE(EDP_PSR_IMR, val); I915_WRITE(imr_reg, val);
} }
static void psr_event_print(u32 val, bool psr2_enabled) static void psr_event_print(u32 val, bool psr2_enabled)
...@@ -144,15 +159,25 @@ static void psr_event_print(u32 val, bool psr2_enabled) ...@@ -144,15 +159,25 @@ static void psr_event_print(u32 val, bool psr2_enabled)
void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir)
{ {
enum transcoder cpu_transcoder = dev_priv->psr.transcoder; enum transcoder cpu_transcoder = dev_priv->psr.transcoder;
enum transcoder trans_shift;
i915_reg_t imr_reg;
ktime_t time_ns = ktime_get(); ktime_t time_ns = ktime_get();
if (psr_iir & EDP_PSR_PRE_ENTRY(cpu_transcoder)) { if (INTEL_GEN(dev_priv) >= 12) {
trans_shift = 0;
imr_reg = TRANS_PSR_IMR(dev_priv->psr.transcoder);
} else {
trans_shift = dev_priv->psr.transcoder;
imr_reg = EDP_PSR_IMR;
}
if (psr_iir & EDP_PSR_PRE_ENTRY(trans_shift)) {
dev_priv->psr.last_entry_attempt = time_ns; dev_priv->psr.last_entry_attempt = time_ns;
DRM_DEBUG_KMS("[transcoder %s] PSR entry attempt in 2 vblanks\n", DRM_DEBUG_KMS("[transcoder %s] PSR entry attempt in 2 vblanks\n",
transcoder_name(cpu_transcoder)); transcoder_name(cpu_transcoder));
} }
if (psr_iir & EDP_PSR_POST_EXIT(cpu_transcoder)) { if (psr_iir & EDP_PSR_POST_EXIT(trans_shift)) {
dev_priv->psr.last_exit = time_ns; dev_priv->psr.last_exit = time_ns;
DRM_DEBUG_KMS("[transcoder %s] PSR exit completed\n", DRM_DEBUG_KMS("[transcoder %s] PSR exit completed\n",
transcoder_name(cpu_transcoder)); transcoder_name(cpu_transcoder));
...@@ -166,7 +191,7 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) ...@@ -166,7 +191,7 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir)
} }
} }
if (psr_iir & EDP_PSR_ERROR(cpu_transcoder)) { if (psr_iir & EDP_PSR_ERROR(trans_shift)) {
u32 val; u32 val;
DRM_WARN("[transcoder %s] PSR aux error\n", DRM_WARN("[transcoder %s] PSR aux error\n",
...@@ -182,9 +207,9 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir) ...@@ -182,9 +207,9 @@ void intel_psr_irq_handler(struct drm_i915_private *dev_priv, u32 psr_iir)
* again so we don't care about unmask the interruption * again so we don't care about unmask the interruption
* or unset irq_aux_error. * or unset irq_aux_error.
*/ */
val = I915_READ(EDP_PSR_IMR); val = I915_READ(imr_reg);
val |= EDP_PSR_ERROR(cpu_transcoder); val |= EDP_PSR_ERROR(trans_shift);
I915_WRITE(EDP_PSR_IMR, val); I915_WRITE(imr_reg, val);
schedule_work(&dev_priv->psr.work); schedule_work(&dev_priv->psr.work);
} }
...@@ -731,8 +756,13 @@ static void intel_psr_enable_locked(struct drm_i915_private *dev_priv, ...@@ -731,8 +756,13 @@ static void intel_psr_enable_locked(struct drm_i915_private *dev_priv,
* first time that PSR HW tries to activate so lets keep PSR disabled * first time that PSR HW tries to activate so lets keep PSR disabled
* to avoid any rendering problems. * to avoid any rendering problems.
*/ */
if (INTEL_GEN(dev_priv) >= 12) {
val = I915_READ(TRANS_PSR_IIR(dev_priv->psr.transcoder));
val &= EDP_PSR_ERROR(0);
} else {
val = I915_READ(EDP_PSR_IIR); val = I915_READ(EDP_PSR_IIR);
val &= EDP_PSR_ERROR(dev_priv->psr.transcoder); val &= EDP_PSR_ERROR(dev_priv->psr.transcoder);
}
if (val) { if (val) {
dev_priv->psr.sink_not_reliable = true; dev_priv->psr.sink_not_reliable = true;
DRM_DEBUG_KMS("PSR interruption error set, not enabling PSR\n"); DRM_DEBUG_KMS("PSR interruption error set, not enabling PSR\n");
......
...@@ -2613,11 +2613,21 @@ gen8_de_misc_irq_handler(struct drm_i915_private *dev_priv, u32 iir) ...@@ -2613,11 +2613,21 @@ gen8_de_misc_irq_handler(struct drm_i915_private *dev_priv, u32 iir)
} }
if (iir & GEN8_DE_EDP_PSR) { if (iir & GEN8_DE_EDP_PSR) {
u32 psr_iir = I915_READ(EDP_PSR_IIR); u32 psr_iir;
i915_reg_t iir_reg;
intel_psr_irq_handler(dev_priv, psr_iir); if (INTEL_GEN(dev_priv) >= 12)
I915_WRITE(EDP_PSR_IIR, psr_iir); iir_reg = TRANS_PSR_IIR(dev_priv->psr.transcoder);
else
iir_reg = EDP_PSR_IIR;
psr_iir = I915_READ(iir_reg);
I915_WRITE(iir_reg, psr_iir);
if (psr_iir)
found = true; found = true;
intel_psr_irq_handler(dev_priv, psr_iir);
} }
if (!found) if (!found)
...@@ -3233,8 +3243,23 @@ static void gen11_irq_reset(struct drm_i915_private *dev_priv) ...@@ -3233,8 +3243,23 @@ static void gen11_irq_reset(struct drm_i915_private *dev_priv)
intel_uncore_write(uncore, GEN11_DISPLAY_INT_CTL, 0); intel_uncore_write(uncore, GEN11_DISPLAY_INT_CTL, 0);
if (INTEL_GEN(dev_priv) >= 12) {
enum transcoder trans;
for (trans = TRANSCODER_A; trans <= TRANSCODER_D; trans++) {
enum intel_display_power_domain domain;
domain = POWER_DOMAIN_TRANSCODER(trans);
if (!intel_display_power_is_enabled(dev_priv, domain))
continue;
intel_uncore_write(uncore, TRANS_PSR_IMR(trans), 0xffffffff);
intel_uncore_write(uncore, TRANS_PSR_IIR(trans), 0xffffffff);
}
} else {
intel_uncore_write(uncore, EDP_PSR_IMR, 0xffffffff); intel_uncore_write(uncore, EDP_PSR_IMR, 0xffffffff);
intel_uncore_write(uncore, EDP_PSR_IIR, 0xffffffff); intel_uncore_write(uncore, EDP_PSR_IIR, 0xffffffff);
}
for_each_pipe(dev_priv, pipe) for_each_pipe(dev_priv, pipe)
if (intel_display_power_is_enabled(dev_priv, if (intel_display_power_is_enabled(dev_priv,
...@@ -3740,7 +3765,21 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv) ...@@ -3740,7 +3765,21 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
else if (IS_BROADWELL(dev_priv)) else if (IS_BROADWELL(dev_priv))
de_port_enables |= GEN8_PORT_DP_A_HOTPLUG; de_port_enables |= GEN8_PORT_DP_A_HOTPLUG;
if (INTEL_GEN(dev_priv) >= 12) {
enum transcoder trans;
for (trans = TRANSCODER_A; trans <= TRANSCODER_D; trans++) {
enum intel_display_power_domain domain;
domain = POWER_DOMAIN_TRANSCODER(trans);
if (!intel_display_power_is_enabled(dev_priv, domain))
continue;
gen3_assert_iir_is_zero(uncore, TRANS_PSR_IIR(trans));
}
} else {
gen3_assert_iir_is_zero(uncore, EDP_PSR_IIR); gen3_assert_iir_is_zero(uncore, EDP_PSR_IIR);
}
for_each_pipe(dev_priv, pipe) { for_each_pipe(dev_priv, pipe) {
dev_priv->de_irq_mask[pipe] = ~de_pipe_masked; dev_priv->de_irq_mask[pipe] = ~de_pipe_masked;
......
...@@ -4222,9 +4222,17 @@ enum { ...@@ -4222,9 +4222,17 @@ enum {
#define EDP_PSR_TP1_TIME_0us (3 << 4) #define EDP_PSR_TP1_TIME_0us (3 << 4)
#define EDP_PSR_IDLE_FRAME_SHIFT 0 #define EDP_PSR_IDLE_FRAME_SHIFT 0
/* Bspec claims those aren't shifted but stay at 0x64800 */ /*
* Until TGL, IMR/IIR are fixed at 0x648xx. On TGL+ those registers are relative
* to transcoder and bits defined for each one as if using no shift (i.e. as if
* it was for TRANSCODER_EDP)
*/
#define EDP_PSR_IMR _MMIO(0x64834) #define EDP_PSR_IMR _MMIO(0x64834)
#define EDP_PSR_IIR _MMIO(0x64838) #define EDP_PSR_IIR _MMIO(0x64838)
#define _PSR_IMR_A 0x60814
#define _PSR_IIR_A 0x60818
#define TRANS_PSR_IMR(tran) _MMIO_TRANS2(tran, _PSR_IMR_A)
#define TRANS_PSR_IIR(tran) _MMIO_TRANS2(tran, _PSR_IIR_A)
#define _EDP_PSR_TRANS_SHIFT(trans) ((trans) == TRANSCODER_EDP ? \ #define _EDP_PSR_TRANS_SHIFT(trans) ((trans) == TRANSCODER_EDP ? \
0 : ((trans) - TRANSCODER_A + 1) * 8) 0 : ((trans) - TRANSCODER_A + 1) * 8)
#define EDP_PSR_TRANS_MASK(trans) (0x7 << _EDP_PSR_TRANS_SHIFT(trans)) #define EDP_PSR_TRANS_MASK(trans) (0x7 << _EDP_PSR_TRANS_SHIFT(trans))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment