public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: imre.deak@intel.com
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-gfx] [PATCH v6 3/4] drm/i915/display: add hotplug.suspended flag
Date: Tue, 23 Aug 2022 23:48:01 +0200	[thread overview]
Message-ID: <45384b73-bfd0-083c-98dc-e2cef51411ee@intel.com> (raw)
In-Reply-To: <YwO8cAQZ22hEBX3P@ideak-desk.fi.intel.com>



On 22.08.2022 19:27, Imre Deak wrote:
> On Fri, Jul 22, 2022 at 02:51:42PM +0200, Andrzej Hajda wrote:
>> HPD events during driver removal can be generated by hardware and
>> software frameworks - drm_dp_mst, the former we can avoid by disabling
>> interrupts, the latter can be triggered by any drm_dp_mst transaction,
>> and this is too late. Introducing suspended flag allows to solve this
>> chicken-egg problem.
> intel_hpd_cancel_work() is always called after suspending MST and
> disabling IRQs (with the order I suggested in patch 1). If both of these
> have disabled the corresponding functionality (MST, IRQs) properly with
> all their MST/IRQ scheduled works guaranteed to not get rescheduled,
> then it's not clear how could either intel_hpd_trigger_irq() or an IRQ
> work run. So the problematic sequence would need a better explanation.

I am not familiar with MST but as I understand from earlier discussion 
MST framework can be called during driver removal code even after 
intel_dp_mst_suspend. And since MST transfer can timeout it can trigger 
drm_dp_mst_wait_tx_reply --> mgr->cbs->poll_hpd_irq(mgr) --> 
intel_dp_mst_poll_hpd_irq --> intel_hpd_trigger_irq.

So actually this patch supersedes the 1st patch.

>
> There's also already
> dev_priv->runtime_pm.irqs_enabled
> showing if hotplug interrupts are disabled (along with all other IRQs).

So it is slightly different, this patch introduces flag indicating if 
HPD is enabled, we can have IRQs not related to HPD, and HPD events not 
related to IRQs.

Regards
Andrzej

>
>> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5950
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
>> Reviewed-by: Arun R Murthy <arun.r.murthy@intel.com>
>> ---
>>   drivers/gpu/drm/i915/display/intel_display.c |  2 +-
>>   drivers/gpu/drm/i915/display/intel_hotplug.c | 11 ++++++++++-
>>   drivers/gpu/drm/i915/display/intel_hotplug.h |  2 +-
>>   drivers/gpu/drm/i915/i915_driver.c           |  4 ++--
>>   drivers/gpu/drm/i915/i915_drv.h              |  2 ++
>>   5 files changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
>> index f1c765ac7ab8aa..cd6139bb36151b 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display.c
>> +++ b/drivers/gpu/drm/i915/display/intel_display.c
>> @@ -9022,7 +9022,7 @@ void intel_modeset_driver_remove_noirq(struct drm_i915_private *i915)
>>   	intel_dp_mst_suspend(i915);
>>   
>>   	/* MST is the last user of HPD work */
>> -	intel_hpd_cancel_work(i915);
>> +	intel_hpd_suspend(i915);
>>   
>>   	/* poll work can call into fbdev, hence clean that up afterwards */
>>   	intel_fbdev_fini(i915);
>> diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
>> index 5f8b4f481cff9a..e1d384cb99df6b 100644
>> --- a/drivers/gpu/drm/i915/display/intel_hotplug.c
>> +++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
>> @@ -303,6 +303,8 @@ static void i915_digport_work_func(struct work_struct *work)
>>   	u32 old_bits = 0;
>>   
>>   	spin_lock_irq(&dev_priv->irq_lock);
>> +	if (dev_priv->hotplug.suspended)
>> +		return spin_unlock_irq(&dev_priv->irq_lock);
>>   	long_port_mask = dev_priv->hotplug.long_port_mask;
>>   	dev_priv->hotplug.long_port_mask = 0;
>>   	short_port_mask = dev_priv->hotplug.short_port_mask;
>> @@ -353,6 +355,8 @@ void intel_hpd_trigger_irq(struct intel_digital_port *dig_port)
>>   	struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
>>   
>>   	spin_lock_irq(&i915->irq_lock);
>> +	if (i915->hotplug.suspended)
>> +		return spin_unlock_irq(&i915->irq_lock);
>>   	i915->hotplug.short_port_mask |= BIT(dig_port->base.port);
>>   	spin_unlock_irq(&i915->irq_lock);
>>   
>> @@ -475,6 +479,9 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
>>   
>>   	spin_lock(&dev_priv->irq_lock);
>>   
>> +	if (dev_priv->hotplug.suspended)
>> +		return spin_unlock(&dev_priv->irq_lock);
>> +
>>   	/*
>>   	 * Determine whether ->hpd_pulse() exists for each pin, and
>>   	 * whether we have a short or a long pulse. This is needed
>> @@ -603,6 +610,7 @@ void intel_hpd_init(struct drm_i915_private *dev_priv)
>>   	 * just to make the assert_spin_locked checks happy.
>>   	 */
>>   	spin_lock_irq(&dev_priv->irq_lock);
>> +	dev_priv->hotplug.suspended = false;
>>   	intel_hpd_irq_setup(dev_priv);
>>   	spin_unlock_irq(&dev_priv->irq_lock);
>>   }
>> @@ -721,13 +729,14 @@ void intel_hpd_init_work(struct drm_i915_private *dev_priv)
>>   			  intel_hpd_irq_storm_reenable_work);
>>   }
>>   
>> -void intel_hpd_cancel_work(struct drm_i915_private *dev_priv)
>> +void intel_hpd_suspend(struct drm_i915_private *dev_priv)
>>   {
>>   	if (!HAS_DISPLAY(dev_priv))
>>   		return;
>>   
>>   	spin_lock_irq(&dev_priv->irq_lock);
>>   
>> +	dev_priv->hotplug.suspended = true;
>>   	dev_priv->hotplug.long_port_mask = 0;
>>   	dev_priv->hotplug.short_port_mask = 0;
>>   	dev_priv->hotplug.event_bits = 0;
>> diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.h b/drivers/gpu/drm/i915/display/intel_hotplug.h
>> index b87e95d606e668..54bddc4dd63421 100644
>> --- a/drivers/gpu/drm/i915/display/intel_hotplug.h
>> +++ b/drivers/gpu/drm/i915/display/intel_hotplug.h
>> @@ -23,7 +23,7 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
>>   void intel_hpd_trigger_irq(struct intel_digital_port *dig_port);
>>   void intel_hpd_init(struct drm_i915_private *dev_priv);
>>   void intel_hpd_init_work(struct drm_i915_private *dev_priv);
>> -void intel_hpd_cancel_work(struct drm_i915_private *dev_priv);
>> +void intel_hpd_suspend(struct drm_i915_private *dev_priv);
>>   enum hpd_pin intel_hpd_pin_default(struct drm_i915_private *dev_priv,
>>   				   enum port port);
>>   bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
>> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
>> index deb8a8b76965a1..57a063a306e3a4 100644
>> --- a/drivers/gpu/drm/i915/i915_driver.c
>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>> @@ -1092,7 +1092,7 @@ void i915_driver_shutdown(struct drm_i915_private *i915)
>>   	intel_dp_mst_suspend(i915);
>>   
>>   	intel_runtime_pm_disable_interrupts(i915);
>> -	intel_hpd_cancel_work(i915);
>> +	intel_hpd_suspend(i915);
>>   
>>   	intel_suspend_encoders(i915);
>>   	intel_shutdown_encoders(i915);
>> @@ -1161,7 +1161,7 @@ static int i915_drm_suspend(struct drm_device *dev)
>>   	intel_dp_mst_suspend(dev_priv);
>>   
>>   	intel_runtime_pm_disable_interrupts(dev_priv);
>> -	intel_hpd_cancel_work(dev_priv);
>> +	intel_hpd_suspend(dev_priv);
>>   
>>   	intel_suspend_encoders(dev_priv);
>>   
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index d25647be25d18b..dc1562b95d7ade 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -106,6 +106,8 @@ struct vlv_s0ix_state;
>>   #define HPD_STORM_DEFAULT_THRESHOLD 50
>>   
>>   struct i915_hotplug {
>> +	bool suspended;
>> +
>>   	struct delayed_work hotplug_work;
>>   
>>   	const u32 *hpd, *pch_hpd;
>> -- 
>> 2.25.1
>>


  reply	other threads:[~2022-08-23 21:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22 12:51 [Intel-gfx] [PATCH v6 0/4] drm/i915/display: stop HPD workers before display driver unregister Andrzej Hajda
2022-07-22 12:51 ` [Intel-gfx] [PATCH v6 1/4] drm/i915/hpd: postpone HPD cancel work after last user suspension Andrzej Hajda
2022-08-22 17:08   ` Imre Deak
2022-08-23  7:41     ` Jani Nikula
2022-08-23  9:10       ` Imre Deak
2022-07-22 12:51 ` [Intel-gfx] [PATCH v6 2/4] drm/i915/fbdev: suspend HPD before fbdev unregistration Andrzej Hajda
2022-08-22 17:10   ` Imre Deak
2022-07-22 12:51 ` [Intel-gfx] [PATCH v6 3/4] drm/i915/display: add hotplug.suspended flag Andrzej Hajda
2022-08-22 17:27   ` Imre Deak
2022-08-23 21:48     ` Andrzej Hajda [this message]
2022-08-24 11:22       ` Imre Deak
2022-08-25 11:24         ` Andrzej Hajda
2022-08-25 14:57           ` Imre Deak
2022-07-22 12:51 ` [Intel-gfx] [PATCH v6 4/4] drm/i915/fbdev: do not create fbdev if HPD is suspended Andrzej Hajda
2022-07-26  6:50   ` Murthy, Arun R
2022-08-22 17:28   ` Imre Deak
2022-07-22 13:08 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/display: stop HPD workers before display driver unregister (rev12) Patchwork
2022-07-22 13:32 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-07-22 15:23 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-07-22 16:56 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/display: stop HPD workers before display driver unregister (rev13) Patchwork
2022-07-22 17:19 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-07-22 20:55 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-07-24 14:46 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/display: stop HPD workers before display driver unregister (rev14) Patchwork
2022-07-24 15:09 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-07-24 16:55 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-08-02 12:24 ` [Intel-gfx] [PATCH v6 0/4] drm/i915/display: stop HPD workers before display driver unregister Gwan-gyeong Mun
2022-08-11  8:33   ` Andrzej Hajda

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=45384b73-bfd0-083c-98dc-e2cef51411ee@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@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