Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Jani Nikula <jani.nikula@linux.intel.com>,
	Jose Souza <jose.souza@intel.com>
Cc: "intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"ville.syrjala@linux.intel.com" <ville.syrjala@linux.intel.com>
Subject: Re: [Intel-gfx] [PATCH 01/13] drm/i915/tc: Fix TypeC port init/resume time sanitization
Date: Fri, 24 Sep 2021 14:06:04 +0300	[thread overview]
Message-ID: <20210924110604.GB1452431@ideak-desk.fi.intel.com> (raw)
In-Reply-To: <87tuia9r3c.fsf@intel.com>

On Fri, Sep 24, 2021 at 01:59:35PM +0300, Jani Nikula wrote:
> On Thu, 23 Sep 2021, "Souza, Jose" <jose.souza@intel.com> wrote:
> > On Tue, 2021-09-21 at 03:23 +0300, Imre Deak wrote:
> >> Atm during driver loading and system resume TypeC ports are accessed
> >> before their HW/SW state is synced. Move the TypeC port sanitization to
> >> the encoder's sync_state hook to fix this.
> >> 
> >> Fixes: f9e76a6e68d3 ("drm/i915: Add an encoder hook to sanitize its state during init/resume")
> >> Cc: José Roberto de Souza <jose.souza@intel.com>
> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> Signed-off-by: Imre Deak <imre.deak@intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/display/intel_ddi.c     |  8 +++++++-
> >>  drivers/gpu/drm/i915/display/intel_display.c | 20 +++++---------------
> >>  2 files changed, 12 insertions(+), 16 deletions(-)
> >> 
> >> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> >> index bba0ab99836b1..c4ed4675f5791 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> >> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> >> @@ -3840,7 +3840,13 @@ void hsw_ddi_get_config(struct intel_encoder *encoder,
> >>  static void intel_ddi_sync_state(struct intel_encoder *encoder,
> >>  				 const struct intel_crtc_state *crtc_state)
> >>  {
> >> -	if (intel_crtc_has_dp_encoder(crtc_state))
> >> +	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> >> +	enum phy phy = intel_port_to_phy(i915, encoder->port);
> >> +
> >> +	if (intel_phy_is_tc(i915, phy))
> >> +		intel_tc_port_sanitize(enc_to_dig_port(encoder));
> >
> > Okay at this point we will not have any mst encoder, so the check is not needed.
> >
> >> +
> >> +	if (crtc_state && intel_crtc_has_dp_encoder(crtc_state))
> >>  		intel_dp_sync_state(encoder, crtc_state);
> >>  }
> >>  
> >> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> >> index f6c0c595f6313..8547842935389 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_display.c
> >> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> >> @@ -12194,18 +12194,16 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
> >>  	readout_plane_state(dev_priv);
> >>  
> >>  	for_each_intel_encoder(dev, encoder) {
> >> +		struct intel_crtc_state *crtc_state = NULL;
> >> +
> >>  		pipe = 0;
> >>  
> >>  		if (encoder->get_hw_state(encoder, &pipe)) {
> >> -			struct intel_crtc_state *crtc_state;
> >> -
> >>  			crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
> >>  			crtc_state = to_intel_crtc_state(crtc->base.state);
> >>  
> >>  			encoder->base.crtc = &crtc->base;
> >>  			intel_encoder_get_config(encoder, crtc_state);
> >> -			if (encoder->sync_state)
> >> -				encoder->sync_state(encoder, crtc_state);
> >>  
> >>  			/* read out to slave crtc as well for bigjoiner */
> >>  			if (crtc_state->bigjoiner) {
> >> @@ -12220,6 +12218,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
> >>  			encoder->base.crtc = NULL;
> >>  		}
> >>  
> >> +		if (encoder->sync_state)
> >> +			encoder->sync_state(encoder, crtc_state);
> >
> > Call sync_state() with a null crtc_state will cause a crash in gen11_dsi_sync_state().

Yes, thanks for catching that.

> >
> > gen11_dsi_sync_state() is the only user of crtc_state but it only wants to know what is the pipe, maybe to be safer change the argument to enum pipe?
> 
> How would intel_ddi_sync_state() know when to call and not call
> intel_dp_sync_state() then? If the encoder's disabled, you shouldn't do
> that. That's the distinction NULL crtc_state gives (and obviously needs
> to be taken into account).

Yes, missed gen11_dsi_sync_state(), it should have the crtc_state != NULL check I added to
intel_ddi_sync_state().

> BR,
> Jani.
> 
> 
> >
> >> +
> >>  		drm_dbg_kms(&dev_priv->drm,
> >>  			    "[ENCODER:%d:%s] hw state readout: %s, pipe %c\n",
> >>  			    encoder->base.base.id, encoder->base.name,
> >> @@ -12502,17 +12503,6 @@ intel_modeset_setup_hw_state(struct drm_device *dev,
> >>  	intel_modeset_readout_hw_state(dev);
> >>  
> >>  	/* HW state is read out, now we need to sanitize this mess. */
> >> -
> >> -	/* Sanitize the TypeC port mode upfront, encoders depend on this */
> >> -	for_each_intel_encoder(dev, encoder) {
> >> -		enum phy phy = intel_port_to_phy(dev_priv, encoder->port);
> >> -
> >> -		/* We need to sanitize only the MST primary port. */
> >> -		if (encoder->type != INTEL_OUTPUT_DP_MST &&
> >> -		    intel_phy_is_tc(dev_priv, phy))
> >> -			intel_tc_port_sanitize(enc_to_dig_port(encoder));
> >> -	}
> >> -
> >>  	get_encoder_power_domains(dev_priv);
> >>  
> >>  	if (HAS_PCH_IBX(dev_priv))
> >
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2021-09-24 11:06 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21  0:23 [Intel-gfx] [PATCH 00/13] drm/i915/tc: Fix TypeC connect/disconnect sequences Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 01/13] drm/i915/tc: Fix TypeC port init/resume time sanitization Imre Deak
2021-09-23 23:10   ` Souza, Jose
2021-09-24 10:59     ` Jani Nikula
2021-09-24 11:06       ` Imre Deak [this message]
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-29 19:19     ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 02/13] drm/i915/adlp/tc: Fix PHY connected check for Thunderbolt mode Imre Deak
2021-09-23 23:18   ` Souza, Jose
2021-09-24 15:24     ` Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 03/13] drm/i915/tc: Remove waiting for PHY complete during releasing ownership Imre Deak
2021-09-24  0:17   ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 04/13] drm/i915/tc: Check for DP-alt, legacy sinks before taking PHY ownership Imre Deak
2021-09-24  0:30   ` Souza, Jose
2021-09-24 15:31     ` Imre Deak
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 05/13] drm/i915/tc: Add/use helpers to retrieve TypeC port properties Imre Deak
2021-09-24 19:54   ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 06/13] drm/i915/tc: Don't keep legacy TypeC ports in connected state w/o a sink Imre Deak
2021-09-24 19:57   ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 07/13] drm/i915/tc: Add a mode for the TypeC PHY's disconnected state Imre Deak
2021-09-27 21:16   ` Souza, Jose
2021-09-27 21:46     ` Imre Deak
2021-09-28 19:18       ` Souza, Jose
2021-09-28 19:34         ` Imre Deak
2021-09-28 19:45           ` Souza, Jose
2021-09-28 19:55             ` Imre Deak
2021-09-28 20:02               ` Souza, Jose
2021-09-28 20:08                 ` Imre Deak
2021-09-28 20:29                   ` Souza, Jose
2021-09-28 20:38                     ` Imre Deak
2021-09-28 20:56                       ` Souza, Jose
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 08/13] drm/i915/tc: Refactor TC-cold block/unblock helpers Imre Deak
2021-09-27 21:56   ` Souza, Jose
2021-09-27 22:13     ` Imre Deak
2021-09-27 22:21       ` Souza, Jose
2021-09-27 22:28         ` Imre Deak
2021-09-27 23:33           ` Souza, Jose
2021-09-27 23:51             ` Imre Deak
2021-09-28  0:14               ` Souza, Jose
2021-09-28  0:45                 ` Imre Deak
2021-09-28  1:03                   ` Souza, Jose
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 09/13] drm/i915/tc: Avoid using legacy AUX PW in TBT mode Imre Deak
2021-09-28 20:31   ` Souza, Jose
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 10/13] drm/i915/icl/tc: Remove the ICL special casing during TC-cold blocking Imre Deak
2021-09-27 22:02   ` Souza, Jose
2021-09-28 10:52     ` Imre Deak
2021-09-28 20:50       ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 11/13] drm/i915/tc: Fix TypeC PHY connect/disconnect logic on ADL-P Imre Deak
2021-09-28 20:51   ` Souza, Jose
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:23 ` [Intel-gfx] [PATCH 12/13] drm/i915/tc: Drop extra TC cold blocking from intel_tc_port_connected() Imre Deak
2021-09-28 20:51   ` Souza, Jose
2021-09-21  0:23 ` [Intel-gfx] [PATCH 13/13] drm/i915/tc: Fix system hang on ADL-P during TypeC PHY disconnect Imre Deak
2021-09-28 20:55   ` Souza, Jose
2021-09-29 13:28   ` [Intel-gfx] [PATCH v2 " Imre Deak
2021-09-21  0:30 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Fix TypeC connect/disconnect sequences Patchwork
2021-09-21  0:32 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-09-21  1:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-09-21  3:01 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2021-09-29 13:42 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Fix TypeC connect/disconnect sequences (rev8) Patchwork
2021-09-29 13:43 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-09-29 14:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-09-29 16:58 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-09-29 21:16   ` Imre Deak
2021-09-29 22:23     ` Vudum, Lakshminarayana
2021-09-29 21:47 ` Patchwork
2021-09-29 21:54 ` Patchwork
2021-09-29 22:21 ` [Intel-gfx] ✓ Fi.CI.IGT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210924110604.GB1452431@ideak-desk.fi.intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jose.souza@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox