Message ID | 20230510103131.1618266-14-imre.deak@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/tc: Add a workaround for an IOM/TCSS firmware hang issue | expand |
On Wed, May 10, 2023 at 01:31:30PM +0300, Imre Deak wrote: > Call the TypeC port flush_work and cleanup handlers without the modeset > locks held. These don't require the locks, as the work takes - as it > should be able to at any point in time - any locks it needs and by the > time cleanup is called and after cleanup returns the encoder is not in > use. > > This is required by the next patch canceling a TypeC port work > synchronously during encoder suspend and shutdown, where the work can > take modeset locks as well, hence the canceling must be done without > holding the locks. > > I also considered moving the modeset locking down to each encoder > suspend()/shutdown() hook instead, however locking the full modeset > state for each encoder separately would be odd, and the bigger change - > affecting all encoders - is beyond the scope of this patchset. Hmm. What is it in the encoder shutdown/suspend hooks that actually needs the modeset locks? > > 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 | 27 +++++++++---------- > .../drm/i915/display/intel_display_types.h | 12 +++++++++ > drivers/gpu/drm/i915/i915_driver.c | 8 ++++++ > 3 files changed, 33 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c > index 813be957ed11b..7d09bd2412352 100644 > --- a/drivers/gpu/drm/i915/display/intel_ddi.c > +++ b/drivers/gpu/drm/i915/display/intel_ddi.c > @@ -4617,31 +4617,27 @@ static bool intel_ddi_is_tc(struct drm_i915_private *i915, enum port port) > > static void intel_ddi_encoder_suspend(struct intel_encoder *encoder) > { > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > - enum phy phy = intel_port_to_phy(i915, encoder->port); > - > intel_dp_encoder_suspend(encoder); > +} > > - if (!intel_phy_is_tc(i915, phy)) > - return; > +static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) > +{ > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > intel_tc_port_flush_work(dig_port); > } > > static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) > { > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > - enum phy phy = intel_port_to_phy(i915, encoder->port); > - > intel_dp_encoder_shutdown(encoder); > intel_hdmi_encoder_shutdown(encoder); > +} > > - if (!intel_phy_is_tc(i915, phy)) > - return; > +static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder) > +{ > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > intel_tc_port_cleanup(dig_port); > } > @@ -4908,6 +4904,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) > is_legacy ? "legacy" : "non-legacy"); > } > > + encoder->suspend_complete = intel_ddi_tc_encoder_suspend_complete; > + encoder->shutdown_complete = intel_ddi_tc_encoder_shutdown_complete; > + > if (intel_tc_port_init(dig_port, is_legacy) < 0) > goto err; > } > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h > index 270c4c84a2920..88b2a55d19f21 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > @@ -233,13 +233,25 @@ struct intel_encoder { > * Called during system suspend after all pending requests for the > * encoder are flushed (for example for DP AUX transactions) and > * device interrupts are disabled. > + * All modeset locks are held while the hook is called. > */ > void (*suspend)(struct intel_encoder *); > + /* > + * Called without the modeset locks held after the suspend() hook for > + * all encoders have been called. > + */ > + void (*suspend_complete)(struct intel_encoder *encoder); > /* > * Called during system reboot/shutdown after all the > * encoders have been disabled and suspended. > + * All modeset locks are held while the hook is called. > */ > void (*shutdown)(struct intel_encoder *encoder); > + /* > + * Called without the modeset locks held after the shutdown() hook for > + * all encoders have been called. > + */ > + void (*shutdown_complete)(struct intel_encoder *encoder); > /* > * Enable/disable the clock to the port. > */ > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c > index fd198700272b1..705ba65f2ff9a 100644 > --- a/drivers/gpu/drm/i915/i915_driver.c > +++ b/drivers/gpu/drm/i915/i915_driver.c > @@ -964,6 +964,10 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) > if (encoder->suspend) > encoder->suspend(encoder); > drm_modeset_unlock_all(&dev_priv->drm); > + > + for_each_intel_encoder(&dev_priv->drm, encoder) > + if (encoder->suspend_complete) > + encoder->suspend_complete(encoder); > } > > static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > @@ -978,6 +982,10 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > if (encoder->shutdown) > encoder->shutdown(encoder); > drm_modeset_unlock_all(&dev_priv->drm); > + > + for_each_intel_encoder(&dev_priv->drm, encoder) > + if (encoder->shutdown_complete) > + encoder->shutdown_complete(encoder); > } > > void i915_driver_shutdown(struct drm_i915_private *i915) > -- > 2.37.2
On Wed, May 10, 2023 at 05:03:17PM +0300, Ville Syrjälä wrote: > On Wed, May 10, 2023 at 01:31:30PM +0300, Imre Deak wrote: > > Call the TypeC port flush_work and cleanup handlers without the modeset > > locks held. These don't require the locks, as the work takes - as it > > should be able to at any point in time - any locks it needs and by the > > time cleanup is called and after cleanup returns the encoder is not in > > use. > > > > This is required by the next patch canceling a TypeC port work > > synchronously during encoder suspend and shutdown, where the work can > > take modeset locks as well, hence the canceling must be done without > > holding the locks. > > > > I also considered moving the modeset locking down to each encoder > > suspend()/shutdown() hook instead, however locking the full modeset > > state for each encoder separately would be odd, and the bigger change - > > affecting all encoders - is beyond the scope of this patchset. > > Hmm. What is it in the encoder shutdown/suspend hooks that > actually needs the modeset locks? In the case of intel_dp_encoder_suspend() for instance, I assume nothing, since the VDD work and intel_pps_vdd_off_sync() should take whatever locks they require. So presumably most (all) of those could be made lockless. However, I would like to leave that kind of change for a follow-up if possible, not to affect in this patchset any other encoder types (again because of possible need for CC stable). > > > > > 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 | 27 +++++++++---------- > > .../drm/i915/display/intel_display_types.h | 12 +++++++++ > > drivers/gpu/drm/i915/i915_driver.c | 8 ++++++ > > 3 files changed, 33 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c > > index 813be957ed11b..7d09bd2412352 100644 > > --- a/drivers/gpu/drm/i915/display/intel_ddi.c > > +++ b/drivers/gpu/drm/i915/display/intel_ddi.c > > @@ -4617,31 +4617,27 @@ static bool intel_ddi_is_tc(struct drm_i915_private *i915, enum port port) > > > > static void intel_ddi_encoder_suspend(struct intel_encoder *encoder) > > { > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > - > > intel_dp_encoder_suspend(encoder); > > +} > > > > - if (!intel_phy_is_tc(i915, phy)) > > - return; > > +static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) > > +{ > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > intel_tc_port_flush_work(dig_port); > > } > > > > static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) > > { > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > - > > intel_dp_encoder_shutdown(encoder); > > intel_hdmi_encoder_shutdown(encoder); > > +} > > > > - if (!intel_phy_is_tc(i915, phy)) > > - return; > > +static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder) > > +{ > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > intel_tc_port_cleanup(dig_port); > > } > > @@ -4908,6 +4904,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) > > is_legacy ? "legacy" : "non-legacy"); > > } > > > > + encoder->suspend_complete = intel_ddi_tc_encoder_suspend_complete; > > + encoder->shutdown_complete = intel_ddi_tc_encoder_shutdown_complete; > > + > > if (intel_tc_port_init(dig_port, is_legacy) < 0) > > goto err; > > } > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h > > index 270c4c84a2920..88b2a55d19f21 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > > @@ -233,13 +233,25 @@ struct intel_encoder { > > * Called during system suspend after all pending requests for the > > * encoder are flushed (for example for DP AUX transactions) and > > * device interrupts are disabled. > > + * All modeset locks are held while the hook is called. > > */ > > void (*suspend)(struct intel_encoder *); > > + /* > > + * Called without the modeset locks held after the suspend() hook for > > + * all encoders have been called. > > + */ > > + void (*suspend_complete)(struct intel_encoder *encoder); > > /* > > * Called during system reboot/shutdown after all the > > * encoders have been disabled and suspended. > > + * All modeset locks are held while the hook is called. > > */ > > void (*shutdown)(struct intel_encoder *encoder); > > + /* > > + * Called without the modeset locks held after the shutdown() hook for > > + * all encoders have been called. > > + */ > > + void (*shutdown_complete)(struct intel_encoder *encoder); > > /* > > * Enable/disable the clock to the port. > > */ > > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c > > index fd198700272b1..705ba65f2ff9a 100644 > > --- a/drivers/gpu/drm/i915/i915_driver.c > > +++ b/drivers/gpu/drm/i915/i915_driver.c > > @@ -964,6 +964,10 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) > > if (encoder->suspend) > > encoder->suspend(encoder); > > drm_modeset_unlock_all(&dev_priv->drm); > > + > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > + if (encoder->suspend_complete) > > + encoder->suspend_complete(encoder); > > } > > > > static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > @@ -978,6 +982,10 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > if (encoder->shutdown) > > encoder->shutdown(encoder); > > drm_modeset_unlock_all(&dev_priv->drm); > > + > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > + if (encoder->shutdown_complete) > > + encoder->shutdown_complete(encoder); > > } > > > > void i915_driver_shutdown(struct drm_i915_private *i915) > > -- > > 2.37.2 > > -- > Ville Syrjälä > Intel
On Wed, May 10, 2023 at 05:10:22PM +0300, Imre Deak wrote: > On Wed, May 10, 2023 at 05:03:17PM +0300, Ville Syrjälä wrote: > > On Wed, May 10, 2023 at 01:31:30PM +0300, Imre Deak wrote: > > > Call the TypeC port flush_work and cleanup handlers without the modeset > > > locks held. These don't require the locks, as the work takes - as it > > > should be able to at any point in time - any locks it needs and by the > > > time cleanup is called and after cleanup returns the encoder is not in > > > use. > > > > > > This is required by the next patch canceling a TypeC port work > > > synchronously during encoder suspend and shutdown, where the work can > > > take modeset locks as well, hence the canceling must be done without > > > holding the locks. > > > > > > I also considered moving the modeset locking down to each encoder > > > suspend()/shutdown() hook instead, however locking the full modeset > > > state for each encoder separately would be odd, and the bigger change - > > > affecting all encoders - is beyond the scope of this patchset. > > > > Hmm. What is it in the encoder shutdown/suspend hooks that > > actually needs the modeset locks? > > In the case of intel_dp_encoder_suspend() for instance, I assume > nothing, since the VDD work and intel_pps_vdd_off_sync() should take > whatever locks they require. > > So presumably most (all) of those could be made lockless. However, I > would like to leave that kind of change for a follow-up if possible, not > to affect in this patchset any other encoder types (again because of > possible need for CC stable). Yeah sure. A bit irksome to have to add vfuncs and whatnot for it though, but it's not the end of the world. Reviewed-by: Ville Syrjälä <ville.syrjala@linux.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 | 27 +++++++++---------- > > > .../drm/i915/display/intel_display_types.h | 12 +++++++++ > > > drivers/gpu/drm/i915/i915_driver.c | 8 ++++++ > > > 3 files changed, 33 insertions(+), 14 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c > > > index 813be957ed11b..7d09bd2412352 100644 > > > --- a/drivers/gpu/drm/i915/display/intel_ddi.c > > > +++ b/drivers/gpu/drm/i915/display/intel_ddi.c > > > @@ -4617,31 +4617,27 @@ static bool intel_ddi_is_tc(struct drm_i915_private *i915, enum port port) > > > > > > static void intel_ddi_encoder_suspend(struct intel_encoder *encoder) > > > { > > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > > - > > > intel_dp_encoder_suspend(encoder); > > > +} > > > > > > - if (!intel_phy_is_tc(i915, phy)) > > > - return; > > > +static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) > > > +{ > > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > > > intel_tc_port_flush_work(dig_port); > > > } > > > > > > static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) > > > { > > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > > - > > > intel_dp_encoder_shutdown(encoder); > > > intel_hdmi_encoder_shutdown(encoder); > > > +} > > > > > > - if (!intel_phy_is_tc(i915, phy)) > > > - return; > > > +static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder) > > > +{ > > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > > > intel_tc_port_cleanup(dig_port); > > > } > > > @@ -4908,6 +4904,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) > > > is_legacy ? "legacy" : "non-legacy"); > > > } > > > > > > + encoder->suspend_complete = intel_ddi_tc_encoder_suspend_complete; > > > + encoder->shutdown_complete = intel_ddi_tc_encoder_shutdown_complete; > > > + > > > if (intel_tc_port_init(dig_port, is_legacy) < 0) > > > goto err; > > > } > > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h > > > index 270c4c84a2920..88b2a55d19f21 100644 > > > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > > > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > > > @@ -233,13 +233,25 @@ struct intel_encoder { > > > * Called during system suspend after all pending requests for the > > > * encoder are flushed (for example for DP AUX transactions) and > > > * device interrupts are disabled. > > > + * All modeset locks are held while the hook is called. > > > */ > > > void (*suspend)(struct intel_encoder *); > > > + /* > > > + * Called without the modeset locks held after the suspend() hook for > > > + * all encoders have been called. > > > + */ > > > + void (*suspend_complete)(struct intel_encoder *encoder); > > > /* > > > * Called during system reboot/shutdown after all the > > > * encoders have been disabled and suspended. > > > + * All modeset locks are held while the hook is called. > > > */ > > > void (*shutdown)(struct intel_encoder *encoder); > > > + /* > > > + * Called without the modeset locks held after the shutdown() hook for > > > + * all encoders have been called. > > > + */ > > > + void (*shutdown_complete)(struct intel_encoder *encoder); > > > /* > > > * Enable/disable the clock to the port. > > > */ > > > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c > > > index fd198700272b1..705ba65f2ff9a 100644 > > > --- a/drivers/gpu/drm/i915/i915_driver.c > > > +++ b/drivers/gpu/drm/i915/i915_driver.c > > > @@ -964,6 +964,10 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) > > > if (encoder->suspend) > > > encoder->suspend(encoder); > > > drm_modeset_unlock_all(&dev_priv->drm); > > > + > > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > > + if (encoder->suspend_complete) > > > + encoder->suspend_complete(encoder); > > > } > > > > > > static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > > @@ -978,6 +982,10 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > > if (encoder->shutdown) > > > encoder->shutdown(encoder); > > > drm_modeset_unlock_all(&dev_priv->drm); > > > + > > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > > + if (encoder->shutdown_complete) > > > + encoder->shutdown_complete(encoder); > > > } > > > > > > void i915_driver_shutdown(struct drm_i915_private *i915) > > > -- > > > 2.37.2 > > > > -- > > Ville Syrjälä > > Intel
On Thu, May 11, 2023 at 08:40:58PM +0300, Ville Syrjälä wrote: > On Wed, May 10, 2023 at 05:10:22PM +0300, Imre Deak wrote: > > On Wed, May 10, 2023 at 05:03:17PM +0300, Ville Syrjälä wrote: > > > On Wed, May 10, 2023 at 01:31:30PM +0300, Imre Deak wrote: > > > > Call the TypeC port flush_work and cleanup handlers without the modeset > > > > locks held. These don't require the locks, as the work takes - as it > > > > should be able to at any point in time - any locks it needs and by the > > > > time cleanup is called and after cleanup returns the encoder is not in > > > > use. > > > > > > > > This is required by the next patch canceling a TypeC port work > > > > synchronously during encoder suspend and shutdown, where the work can > > > > take modeset locks as well, hence the canceling must be done without > > > > holding the locks. > > > > > > > > I also considered moving the modeset locking down to each encoder > > > > suspend()/shutdown() hook instead, however locking the full modeset > > > > state for each encoder separately would be odd, and the bigger change - > > > > affecting all encoders - is beyond the scope of this patchset. > > > > > > Hmm. What is it in the encoder shutdown/suspend hooks that > > > actually needs the modeset locks? > > > > In the case of intel_dp_encoder_suspend() for instance, I assume > > nothing, since the VDD work and intel_pps_vdd_off_sync() should take > > whatever locks they require. > > > > So presumably most (all) of those could be made lockless. However, I > > would like to leave that kind of change for a follow-up if possible, not > > to affect in this patchset any other encoder types (again because of > > possible need for CC stable). > > Yeah sure. Ok, will add a TODO comment about this. > A bit irksome to have to add vfuncs and whatnot for > it though, but it's not the end of the world. Direct intel_tc calls from intel_suspend/shutdown_encoders didn't seem ideal either, but can do that if you think that's better. > Reviewed-by: Ville Syrjälä <ville.syrjala@linux.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 | 27 +++++++++---------- > > > > .../drm/i915/display/intel_display_types.h | 12 +++++++++ > > > > drivers/gpu/drm/i915/i915_driver.c | 8 ++++++ > > > > 3 files changed, 33 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c > > > > index 813be957ed11b..7d09bd2412352 100644 > > > > --- a/drivers/gpu/drm/i915/display/intel_ddi.c > > > > +++ b/drivers/gpu/drm/i915/display/intel_ddi.c > > > > @@ -4617,31 +4617,27 @@ static bool intel_ddi_is_tc(struct drm_i915_private *i915, enum port port) > > > > > > > > static void intel_ddi_encoder_suspend(struct intel_encoder *encoder) > > > > { > > > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > > > - > > > > intel_dp_encoder_suspend(encoder); > > > > +} > > > > > > > > - if (!intel_phy_is_tc(i915, phy)) > > > > - return; > > > > +static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) > > > > +{ > > > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > > > > > intel_tc_port_flush_work(dig_port); > > > > } > > > > > > > > static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) > > > > { > > > > - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > > - struct drm_i915_private *i915 = dp_to_i915(intel_dp); > > > > - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > - enum phy phy = intel_port_to_phy(i915, encoder->port); > > > > - > > > > intel_dp_encoder_shutdown(encoder); > > > > intel_hdmi_encoder_shutdown(encoder); > > > > +} > > > > > > > > - if (!intel_phy_is_tc(i915, phy)) > > > > - return; > > > > +static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder) > > > > +{ > > > > + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); > > > > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > > > > > > > > intel_tc_port_cleanup(dig_port); > > > > } > > > > @@ -4908,6 +4904,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) > > > > is_legacy ? "legacy" : "non-legacy"); > > > > } > > > > > > > > + encoder->suspend_complete = intel_ddi_tc_encoder_suspend_complete; > > > > + encoder->shutdown_complete = intel_ddi_tc_encoder_shutdown_complete; > > > > + > > > > if (intel_tc_port_init(dig_port, is_legacy) < 0) > > > > goto err; > > > > } > > > > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h > > > > index 270c4c84a2920..88b2a55d19f21 100644 > > > > --- a/drivers/gpu/drm/i915/display/intel_display_types.h > > > > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h > > > > @@ -233,13 +233,25 @@ struct intel_encoder { > > > > * Called during system suspend after all pending requests for the > > > > * encoder are flushed (for example for DP AUX transactions) and > > > > * device interrupts are disabled. > > > > + * All modeset locks are held while the hook is called. > > > > */ > > > > void (*suspend)(struct intel_encoder *); > > > > + /* > > > > + * Called without the modeset locks held after the suspend() hook for > > > > + * all encoders have been called. > > > > + */ > > > > + void (*suspend_complete)(struct intel_encoder *encoder); > > > > /* > > > > * Called during system reboot/shutdown after all the > > > > * encoders have been disabled and suspended. > > > > + * All modeset locks are held while the hook is called. > > > > */ > > > > void (*shutdown)(struct intel_encoder *encoder); > > > > + /* > > > > + * Called without the modeset locks held after the shutdown() hook for > > > > + * all encoders have been called. > > > > + */ > > > > + void (*shutdown_complete)(struct intel_encoder *encoder); > > > > /* > > > > * Enable/disable the clock to the port. > > > > */ > > > > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c > > > > index fd198700272b1..705ba65f2ff9a 100644 > > > > --- a/drivers/gpu/drm/i915/i915_driver.c > > > > +++ b/drivers/gpu/drm/i915/i915_driver.c > > > > @@ -964,6 +964,10 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) > > > > if (encoder->suspend) > > > > encoder->suspend(encoder); > > > > drm_modeset_unlock_all(&dev_priv->drm); > > > > + > > > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > > > + if (encoder->suspend_complete) > > > > + encoder->suspend_complete(encoder); > > > > } > > > > > > > > static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > > > @@ -978,6 +982,10 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) > > > > if (encoder->shutdown) > > > > encoder->shutdown(encoder); > > > > drm_modeset_unlock_all(&dev_priv->drm); > > > > + > > > > + for_each_intel_encoder(&dev_priv->drm, encoder) > > > > + if (encoder->shutdown_complete) > > > > + encoder->shutdown_complete(encoder); > > > > } > > > > > > > > void i915_driver_shutdown(struct drm_i915_private *i915) > > > > -- > > > > 2.37.2 > > > > > > -- > > > Ville Syrjälä > > > Intel > > -- > Ville Syrjälä > Intel
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 813be957ed11b..7d09bd2412352 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -4617,31 +4617,27 @@ static bool intel_ddi_is_tc(struct drm_i915_private *i915, enum port port) static void intel_ddi_encoder_suspend(struct intel_encoder *encoder) { - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); - struct drm_i915_private *i915 = dp_to_i915(intel_dp); - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); - enum phy phy = intel_port_to_phy(i915, encoder->port); - intel_dp_encoder_suspend(encoder); +} - if (!intel_phy_is_tc(i915, phy)) - return; +static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder) +{ + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); intel_tc_port_flush_work(dig_port); } static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder) { - struct intel_dp *intel_dp = enc_to_intel_dp(encoder); - struct drm_i915_private *i915 = dp_to_i915(intel_dp); - struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); - enum phy phy = intel_port_to_phy(i915, encoder->port); - intel_dp_encoder_shutdown(encoder); intel_hdmi_encoder_shutdown(encoder); +} - if (!intel_phy_is_tc(i915, phy)) - return; +static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder) +{ + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); intel_tc_port_cleanup(dig_port); } @@ -4908,6 +4904,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) is_legacy ? "legacy" : "non-legacy"); } + encoder->suspend_complete = intel_ddi_tc_encoder_suspend_complete; + encoder->shutdown_complete = intel_ddi_tc_encoder_shutdown_complete; + if (intel_tc_port_init(dig_port, is_legacy) < 0) goto err; } diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 270c4c84a2920..88b2a55d19f21 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -233,13 +233,25 @@ struct intel_encoder { * Called during system suspend after all pending requests for the * encoder are flushed (for example for DP AUX transactions) and * device interrupts are disabled. + * All modeset locks are held while the hook is called. */ void (*suspend)(struct intel_encoder *); + /* + * Called without the modeset locks held after the suspend() hook for + * all encoders have been called. + */ + void (*suspend_complete)(struct intel_encoder *encoder); /* * Called during system reboot/shutdown after all the * encoders have been disabled and suspended. + * All modeset locks are held while the hook is called. */ void (*shutdown)(struct intel_encoder *encoder); + /* + * Called without the modeset locks held after the shutdown() hook for + * all encoders have been called. + */ + void (*shutdown_complete)(struct intel_encoder *encoder); /* * Enable/disable the clock to the port. */ diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index fd198700272b1..705ba65f2ff9a 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -964,6 +964,10 @@ static void intel_suspend_encoders(struct drm_i915_private *dev_priv) if (encoder->suspend) encoder->suspend(encoder); drm_modeset_unlock_all(&dev_priv->drm); + + for_each_intel_encoder(&dev_priv->drm, encoder) + if (encoder->suspend_complete) + encoder->suspend_complete(encoder); } static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) @@ -978,6 +982,10 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) if (encoder->shutdown) encoder->shutdown(encoder); drm_modeset_unlock_all(&dev_priv->drm); + + for_each_intel_encoder(&dev_priv->drm, encoder) + if (encoder->shutdown_complete) + encoder->shutdown_complete(encoder); } void i915_driver_shutdown(struct drm_i915_private *i915)
Call the TypeC port flush_work and cleanup handlers without the modeset locks held. These don't require the locks, as the work takes - as it should be able to at any point in time - any locks it needs and by the time cleanup is called and after cleanup returns the encoder is not in use. This is required by the next patch canceling a TypeC port work synchronously during encoder suspend and shutdown, where the work can take modeset locks as well, hence the canceling must be done without holding the locks. I also considered moving the modeset locking down to each encoder suspend()/shutdown() hook instead, however locking the full modeset state for each encoder separately would be odd, and the bigger change - affecting all encoders - is beyond the scope of this patchset. 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 | 27 +++++++++---------- .../drm/i915/display/intel_display_types.h | 12 +++++++++ drivers/gpu/drm/i915/i915_driver.c | 8 ++++++ 3 files changed, 33 insertions(+), 14 deletions(-)