<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div><br>
</div>
<div id="mail-editor-reference-message-container" dir="auto"><br>
<hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" style="font-size: 11pt;"><strong>From:</strong> Hogander, Jouni <jouni.hogander@intel.com><br>
<strong>Sent:</strong> Friday, September 20, 2024 12:11:19 pm<br>
<strong>To:</strong> Kandpal, Suraj <suraj.kandpal@intel.com>; Shankar, Uma <uma.shankar@intel.com>; intel-gfx@lists.freedesktop.org <intel-gfx@lists.freedesktop.org><br>
<strong>Cc:</strong> Deak, Imre <imre.deak@intel.com><br>
<strong>Subject:</strong> Re: [PATCH] drm/i915/psr: Implment WA to help reach PC10<br>
</div>
<br>
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><font size="2"><span style="font-size:11pt;">
<div class="PlainText" dir="auto">On Fri, 2024-09-20 at 06:29 +0000, Kandpal, Suraj wrote:<br>
> <br>
> <br>
> > -----Original Message-----<br>
> > From: Hogander, Jouni <jouni.hogander@intel.com><br>
> > Sent: Friday, September 20, 2024 11:06 AM<br>
> > To: Shankar, Uma <uma.shankar@intel.com>; Kandpal, Suraj<br>
> > <suraj.kandpal@intel.com>; intel-gfx@lists.freedesktop.org<br>
> > Cc: Deak, Imre <imre.deak@intel.com><br>
> > Subject: Re: [PATCH] drm/i915/psr: Implment WA to help reach PC10<br>
> > <br>
> > On Thu, 2024-09-19 at 12:14 +0000, Shankar, Uma wrote:<br>
> > > <br>
> > > <br>
> > > > -----Original Message-----<br>
> > > > From: Kandpal, Suraj <suraj.kandpal@intel.com><br>
> > > > Sent: Monday, September 9, 2024 12:02 PM<br>
> > > > To: intel-gfx@lists.freedesktop.org<br>
> > > > Cc: Shankar, Uma <uma.shankar@intel.com>; Hogander, Jouni<br>
> > > > <jouni.hogander@intel.com>; Deak, Imre <imre.deak@intel.com>;<br>
> > > > Kandpal, Suraj <suraj.kandpal@intel.com><br>
> > > > Subject: [PATCH] drm/i915/psr: Implment WA to help reach PC10<br>
> > > <br>
> > > Not: Typo in implement<br>
> > > <br>
> > > > To reach PC10 when PKG_C_LATENCY is configure we must do the<br>
> > > > following things<br>
> > > > 1) Enter PSR1 only when delayed_vblank < 6 lines and DC5 can be<br>
> > > > entered<br>
> > > > 2) Allow PSR2 deep sleep when DC5 can be entered<br>
> > > > 3) DC5 can be entered when all transocoder have either PSR1,<br>
> > > > PSR2 or<br>
> > > > eDP 1.5 PR ALPM enabled and VBI is disabled and flips and<br>
> > > > pushes are<br>
> > > > not happening.<br>
> > > > <br>
> > > > --v2<br>
> > > > -Switch condition and do an early return [Jani] -Do some checks<br>
> > > > in<br>
> > > > compute_config [Jani] -Do not use register reads as a method of<br>
> > > > checking states for DPKGC or delayed vblank [Jani] -Use another<br>
> > > > way<br>
> > > > to see is vblank interrupts are disabled or not [Jani]<br>
> > > > <br>
> > > > --v3<br>
> > > > -Use has_psr to check if psr can be enabled or not for<br>
> > > > dc5_entry<br>
> > > > cond [Uma] - Move the dc5 entry computation to<br>
> > > > psr_compute_config<br>
> > > > [Jouni] -No need to change sequence of enabled and activate, so<br>
> > > > dont<br>
> > > > make hsw_psr1_activate return anything [Jouni] -Use has_psr to<br>
> > > > stop<br>
> > > > psr1 activation [Jouni] -Use lineage no. in WA -Add the display<br>
> > > > ver<br>
> > > > restrictions for WA<br>
> > > > <br>
> > > > --v4<br>
> > > > -use more appropriate name for check_vblank_limit() [Jouni] -<br>
> > > > Cover<br>
> > > > the case for idle frames when dpkgc is not configured [Jouni] -<br>
> > > > Check<br>
> > > > psr only for edp [Jouni]<br>
> > > > <br>
> > > > --v5<br>
> > > > -move psr1 handling to plane update [Jouni] -add todo for cases<br>
> > > > when<br>
> > > > vblank is enabled when psr enabled [Jouni] -use intel_display<br>
> > > > instead of drm_i915_private<br>
> > > > <br>
> > > > --v6<br>
> > > > -check target_dc_state [Jouni]<br>
> > > > -fix condition in pre/post plane update [Jouni]<br>
> > > > <br>
> > > > WA: 22019444797<br>
> > > > Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com><br>
> > > > ---<br>
> > > > .../drm/i915/display/intel_display_types.h | 3 +<br>
> > > > drivers/gpu/drm/i915/display/intel_psr.c | 112<br>
> > > > +++++++++++++++++-<br>
> > > > 2 files changed, 114 insertions(+), 1 deletion(-)<br>
> > > > <br>
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> > > > b/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> > > > index 733de5edcfdb..59c81f0a3abd 100644<br>
> > > > --- a/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> > > > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h<br>
> > > > @@ -1577,6 +1577,9 @@ struct intel_psr {<br>
> > > > #define I915_PSR_DEBUG_PANEL_REPLAY_DISABLE 0x40<br>
> > > > <br>
> > > > u32 debug;<br>
> > > > + bool is_dpkgc_configured;<br>
> > > > + bool is_dc5_entry_possible;<br>
> > > > + bool is_wa_delayed_vblank_limit;<br>
> > > > bool sink_support;<br>
> > > > bool source_support;<br>
> > > > bool enabled;<br>
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_psr.c<br>
> > > > b/drivers/gpu/drm/i915/display/intel_psr.c<br>
> > > > index b30fa067ce6e..e50b476494a0 100644<br>
> > > > --- a/drivers/gpu/drm/i915/display/intel_psr.c<br>
> > > > +++ b/drivers/gpu/drm/i915/display/intel_psr.c<br>
> > > > @@ -26,6 +26,7 @@<br>
> > > > #include <drm/drm_atomic_helper.h><br>
> > > > #include <drm/drm_damage_helper.h><br>
> > > > #include <drm/drm_debugfs.h><br>
> > > > +#include <drm/drm_vblank.h><br>
> > > > <br>
> > > > #include "i915_drv.h"<br>
> > > > #include "i915_reg.h"<br>
> > > > @@ -874,6 +875,78 @@ static u8 psr_compute_idle_frames(struct<br>
> > > > intel_dp<br>
> > > > *intel_dp)<br>
> > > > return idle_frames;<br>
> > > > }<br>
> > > > <br>
> > > > +static bool<br>
> > > > +intel_psr_check_wa_delayed_vblank(const struct<br>
> > > > drm_display_mode<br>
> > > > +*adjusted_mode) {<br>
> > > > + return (adjusted_mode->crtc_vblank_start -<br>
> > > > +adjusted_mode->crtc_vdisplay) >= 6; }<br>
> > > > +<br>
> > > > +/*<br>
> > > > + * PKG_C_LATENCY is configured only when DISPLAY_VER >= 20 and<br>
> > > > + * VRR is not enabled<br>
> > > > + */<br>
> > > > +static bool intel_psr_is_dpkgc_configured(struct intel_display<br>
> > > > *display,<br>
> > > > + struct<br>
> > > > intel_atomic_state<br>
> > > > *state) {<br>
> > > > + struct intel_crtc *intel_crtc;<br>
> > > > + struct intel_crtc_state *crtc_state;<br>
> > > > + int i;<br>
> > > > +<br>
> > > > + if (DISPLAY_VER(display) < 20)<br>
> > > > + return false;<br>
> > > > +<br>
> > > > + for_each_new_intel_crtc_in_state(state, intel_crtc,<br>
> > > > crtc_state, i) {<br>
> > > > + if (!intel_crtc->active)<br>
> > > > + continue;<br>
> > > > +<br>
> > > > + if (crtc_state->vrr.enable)<br>
> > > > + return false;<br>
> > > > + }<br>
> > > > +<br>
> > > > + return true;<br>
> > > > +}<br>
> > > > +<br>
> > > > +/*<br>
> > > > + * DC5 entry is only possible if vblank interrupt is disabled<br>
> > > > + * and either psr1, psr2, edp 1.5 pr alpm is enabled on all<br>
> > > > + * enabled encoders.<br>
> > > > + */<br>
> > > > +static bool<br>
> > > > +intel_psr_is_dc5_entry_possible(struct intel_display *display,<br>
> > > > + struct intel_atomic_state<br>
> > > > *state) {<br>
> > > > + struct intel_crtc *intel_crtc;<br>
> > > > + struct intel_crtc_state *crtc_state;<br>
> > > > + int i;<br>
> > > > +<br>
> > > > + if ((display->power.domains.target_dc_state &<br>
> > > > + DC_STATE_EN_UPTO_DC5_DC6_MASK) == 0)<br>
> > > > + return false;<br>
> > > > +<br>
> > > > + for_each_new_intel_crtc_in_state(state, intel_crtc,<br>
> > > > crtc_state, i) {<br>
> > > > + struct drm_crtc *crtc = &intel_crtc->base;<br>
> > > > + struct drm_vblank_crtc *vblank;<br>
> > > > + struct intel_encoder *encoder;<br>
> > > > +<br>
> > > > + if (!intel_crtc->active)<br>
> > > > + continue;<br>
> > > > +<br>
> > > > + vblank = drm_crtc_vblank_crtc(crtc);<br>
> > > > +<br>
> > > > + if (vblank->enabled)<br>
> > > > + return false;<br>
> > > > +<br>
> > > > + if (crtc_state->has_psr)<br>
> > > > + return false;<br>
> > > <br>
> > > It should be !has_psr<br>
> > > > +<br>
> > > > + for_each_encoder_on_crtc(display->drm, crtc,<br>
> > > > encoder)<br>
> > > > + if (encoder->type != INTEL_OUTPUT_EDP)<br>
> > > > + return false;<br>
> > <br>
> > I'm not sure if we need to care about dual eDP case. One PSR and<br>
> > another non-<br>
> > PSR. That will return true from this function even thought it's not<br>
> > possible. That<br>
> > can be solved by checking CAN_PSR(intel_dp) here.<br>
> <br>
> So ,<br>
> if (encoder->type != INTEL_OUTPUT_EDP &&<br>
> CAN_PSR(intel_dp))<br>
> return false;<br>
> > <br>
> > > > + }<br>
> > > > +<br>
> > > > + return true;<br>
> > > > +}<br>
> > > > +<br>
> > > > static void hsw_activate_psr1(struct intel_dp *intel_dp) {<br>
> > > > struct intel_display *display =<br>
> > > > to_intel_display(intel_dp);<br>
> > > > @@ -986,7<br>
> > > > +1059,15 @@ static void hsw_activate_psr2(struct intel_dp<br>
> > > > *intel_dp)<br>
> > > > u32 val = EDP_PSR2_ENABLE;<br>
> > > > u32 psr_val = 0;<br>
> > > > <br>
> > > > - val |=<br>
> > > > EDP_PSR2_IDLE_FRAMES(psr_compute_idle_frames(intel_dp));<br>
> > > > + /*<br>
> > > > + * Wa_22019444797<br>
> > > > + * TODO: Disable idle frames when vblank gets enabled<br>
> > > > while<br>
> > > > + * PSR2 is enabled<br>
> > > > + */<br>
> > > > + if (DISPLAY_VER(dev_priv) != 20 ||<br>
> > > > + !intel_dp->psr.is_dpkgc_configured ||<br>
> > > <br>
> > > Why ! for dpkgc, Here this can be enabled if dpkgc_configured<br>
> > > right ?<br>
> > > <br>
> > > > + intel_dp->psr.is_dc5_entry_possible)<br>
> > > > + val |=<br>
> > > > EDP_PSR2_IDLE_FRAMES(psr_compute_idle_frames(intel_dp));<br>
> > > > <br>
> > > > if (DISPLAY_VER(display) < 14 &&<br>
> > > > !IS_ALDERLAKE_P(dev_priv))<br>
> > > > val |= EDP_SU_TRACK_ENABLE; @@ -2667,10<br>
> > > > +2748,20 @@<br>
> > > > void intel_psr_pre_plane_update(struct intel_atomic_state<br>
> > > > *state,<br>
> > > > const struct intel_crtc_state *new_crtc_state =<br>
> > > > intel_atomic_get_new_crtc_state(state, crtc);<br>
> > > > struct intel_encoder *encoder;<br>
> > > > + bool dpkgc_configured = false, dc5_entry_possible =<br>
> > > > false;<br>
> > > > + bool wa_delayed_vblank_limit = false;<br>
> > > > <br>
> > > > if (!HAS_PSR(display))<br>
> > > > return;<br>
> > > > <br>
> > > > + if (DISPLAY_VER(display) == 20) {<br>
> > > > + dpkgc_configured =<br>
> > > > intel_psr_is_dpkgc_configured(display,<br>
> > > > state);<br>
> > > > + dc5_entry_possible =<br>
> > > > + intel_psr_is_dc5_entry_possible(display<br>
> > > > ,<br>
> > > > state);<br>
> > > > + wa_delayed_vblank_limit =<br>
> > > > + intel_psr_check_wa_delayed_vblank(&new_<br>
> > > > crtc<br>
> > > > _state-<br>
> > > > > hw.adjusted_mode);<br>
> > > > + }<br>
> > > > +<br>
> > > > for_each_intel_encoder_mask_with_psr(state->base.dev,<br>
> > > > encoder,<br>
> > > > old_crtc_state-<br>
> > > > > uapi.encoder_mask)<br>
> > > > {<br>
> > > > struct intel_dp *intel_dp =<br>
> > > > enc_to_intel_dp(encoder); @@ -<br>
> > > > 2679,6 +2770,12 @@ void intel_psr_pre_plane_update(struct<br>
> > > > intel_atomic_state *state,<br>
> > > > <br>
> > > > mutex_lock(&psr->lock);<br>
> > > > <br>
> > > > + if (DISPLAY_VER(i915) == 20) {<br>
> > > > + psr->is_dpkgc_configured =<br>
> > > > dpkgc_configured;<br>
> > > > + psr->is_dc5_entry_possible =<br>
> > > > dc5_entry_possible;<br>
> > > > + psr->is_wa_delayed_vblank_limit =<br>
> > > > wa_delayed_vblank_limit;<br>
> > > <br>
> > > We can drop the variables and directly assign this to psr->...<br>
> > > and use<br>
> > > it subsequently.<br>
> > > Also it would be good to have this done in compute and than just<br>
> > > use<br>
> > > it here.<br>
> > > <br>
> > > > + }<br>
> > > > +<br>
> > > > /*<br>
> > > > * Reasons to disable:<br>
> > > > * - PSR disabled in new state @@ -2686,6<br>
> > > > +2783,7 @@<br>
> > > > void intel_psr_pre_plane_update(struct intel_atomic_state<br>
> > > > *state,<br>
> > > > * - Changing between PSR versions<br>
> > > > * - Region Early Transport changing<br>
> > > > * - Display WA #1136: skl, bxt<br>
> > > > + * - Display WA_22019444797<br>
> > > > */<br>
> > > > needs_to_disable |=<br>
> > > > intel_crtc_needs_modeset(new_crtc_state);<br>
> > > > needs_to_disable |= !new_crtc_state->has_psr;<br>
> > > > @@ -<br>
> > > > 2695,6<br>
> > > > +2793,10 @@ void intel_psr_pre_plane_update(struct<br>
> > > > intel_atomic_state *state,<br>
> > > > psr->su_region_et_enabled;<br>
> > > > needs_to_disable |= DISPLAY_VER(i915) < 11 &&<br>
> > > > new_crtc_state->wm_level_disabled;<br>
> > > > + /* TODO: Disable PSR1 when vblank gets enabled<br>
> > > > while PSR1 is<br>
> > > > enabled */<br>
> > > > + needs_to_disable |= DISPLAY_VER(display) == 20<br>
> > > > &&<br>
> > > > dpkgc_configured &&<br>
> > > > + (wa_delayed_vblank_limit ||<br>
> > > > dc5_entry_possible) &&<br>
> > > > + !new_crtc_state->has_sel_update &&<br>
> > > > +!new_crtc_state->has_panel_replay;<br>
> > > <br>
> > > Good to move this to a small helper function which can be<br>
> > > extended if<br>
> > > required as well.<br>
> > > Also seems used in post_plane as well.<br>
> > > <br>
> > > @Hogander, Jouni Can you also ack if this handling for PSR is ok.<br>
> > <br>
> > This need_to_disable/keep_disabled is ok. I think there is a bug in<br>
> > check itself:<br>
> > <br>
> > dc5_entry_possible should be !dc5_entry_possible<br>
> > <br>
> > What do you think?<br>
> > <br>
> <br>
> Dc5_entry_possible returns true when we can enter dc5.<br>
> And the condition to disable ps1 is to have a delayed_vblank > 6 or<br>
> When dc5 can be entered so that check would be correct<br>
<br>
"When PKG_C_LATENCY is configured (not all 1s), enable PSR1(SRD_CTL SRD<br>
Enable == 1) only when the transcoder has Vblank delayed less than 6<br>
lines OR DC5 can be entered. "<br>
<br>
I think this emphasizes suggestion from Uma, move this as a helper.<br>
Also add explanation there.</div>
<div class="PlainText" dir="auto">--------</div>
<div class="PlainText" dir="auto"><br>
</div>
<div class="PlainText" dir="auto">I see what went wrong here it's should be !dc5_entry_possible will move this into its own helper too</div>
<div class="PlainText" dir="auto"><br>
</div>
<div class="PlainText" dir="auto">Regards,</div>
<div class="PlainText" dir="auto">Suraj Kandpal<br>
<br>
<br>
--------<br>
BR,<br>
<br>
Jouni Högander<br>
> <br>
> Regards,<br>
> Suraj Kandpal<br>
> <br>
> > BR,<br>
> > <br>
> > Jouni Högander<br>
> > <br>
> > > <br>
> > > > if (psr->enabled && needs_to_disable)<br>
> > > > intel_psr_disable_locked(intel_dp);<br>
> > > > @@ -2735,6 +2837,14 @@ void intel_psr_post_plane_update(struct<br>
> > > > intel_atomic_state *state,<br>
> > > > keep_disabled |= DISPLAY_VER(display) < 11 &&<br>
> > > > crtc_state->wm_level_disabled;<br>
> > > > <br>
> > > > + /*<br>
> > > > + * Wa_22019444797<br>
> > > > + * TODO: Disable PSR1 when vblank gets enabled<br>
> > > > while PSR1 is<br>
> > > > enabled<br>
> > > > + */<br>
> > > > + keep_disabled |= DISPLAY_VER(display) == 20 &&<br>
> > > > psr-<br>
> > > > > is_dpkgc_configured &&<br>
> > > > + (psr->is_wa_delayed_vblank_limit ||<br>
> > > > psr-<br>
> > > > > is_dc5_entry_possible) &&<br>
> > > > + !crtc_state->has_sel_update &&<br>
> > > > !crtc_state-<br>
> > > > > has_panel_replay;<br>
> > > > +<br>
> > > > if (!psr->enabled && !keep_disabled)<br>
> > > > intel_psr_enable_locked(intel_dp,<br>
> > > > crtc_state);<br>
> > > > else if (psr->enabled && !crtc_state-<br>
> > > > > wm_level_disabled)<br>
> > > > --<br>
> > > > 2.43.2<br>
> > > <br>
> <br>
<br>
</div>
</span></font><br>
</div>
</body>
</html>