From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 17/19] drm/i915: vlv: factor out valleyview_display_irq_install
Date: Thu, 20 Feb 2014 11:56:16 -0800 [thread overview]
Message-ID: <20140220115616.023016a5@jbarnes-desktop> (raw)
In-Reply-To: <1392674540-10915-18-git-send-email-imre.deak@intel.com>
On Tue, 18 Feb 2014 00:02:18 +0200
Imre Deak <imre.deak@intel.com> wrote:
> We'll need to disable/re-enable the display-side IRQs when turning
> off/on the VLV display power well. Factor out the helper functions
> for this. For now keep the display IRQs enabled by default, so the
> functionality doesn't change. This will be changed to enable/disable
> the IRQs on-demand when adding support for VLV power wells in an
> upcoming patch.
>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
> drivers/gpu/drm/i915/i915_dma.c | 1 +
> drivers/gpu/drm/i915/i915_drv.h | 5 ++
> drivers/gpu/drm/i915/i915_irq.c | 122 ++++++++++++++++++++++++++++++++--------
> 3 files changed, 103 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index f8f7a59..dca4dc3 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1668,6 +1668,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
> goto out_mtrrfree;
> }
>
> + dev_priv->display_irqs_enabled = true;
> intel_irq_init(dev);
> intel_uncore_sanitize(dev);
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 632f9d8..227c349 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1454,6 +1454,8 @@ typedef struct drm_i915_private {
> /* protects the irq masks */
> spinlock_t irq_lock;
>
> + bool display_irqs_enabled;
> +
> /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
> struct pm_qos_request pm_qos;
>
> @@ -2052,6 +2054,9 @@ void
> i915_disable_pipestat(drm_i915_private_t *dev_priv, enum pipe pipe,
> u32 status_mask);
>
> +void valleyview_enable_display_irqs(struct drm_i915_private *dev_priv);
> +void valleyview_disable_display_irqs(struct drm_i915_private *dev_priv);
> +
> /* i915_gem.c */
> int i915_gem_init_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file_priv);
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 75dd0a8..6078d06 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -3016,41 +3016,109 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
> return 0;
> }
>
> +static void valleyview_display_irqs_install(struct drm_i915_private *dev_priv)
> +{
> + unsigned long irqflags;
> + u32 pipestat_mask;
> + u32 iir_mask;
> +
> + pipestat_mask = PIPESTAT_INT_STATUS_MASK |
> + PIPE_FIFO_UNDERRUN_STATUS;
> + I915_WRITE(PIPESTAT(PIPE_A), pipestat_mask);
> + I915_WRITE(PIPESTAT(PIPE_B), pipestat_mask);
> + POSTING_READ(PIPESTAT(PIPE_A));
> +
> + pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
> + PIPE_CRC_DONE_INTERRUPT_STATUS;
> +
> + spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
> + i915_enable_pipestat(dev_priv, PIPE_A, pipestat_mask |
> + PIPE_GMBUS_INTERRUPT_STATUS);
> + i915_enable_pipestat(dev_priv, PIPE_B, pipestat_mask);
> + spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
> +
> + iir_mask = I915_DISPLAY_PORT_INTERRUPT |
> + I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
> + I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
> + dev_priv->irq_mask &= ~iir_mask;
> +
> + I915_WRITE(VLV_IIR, iir_mask);
> + I915_WRITE(VLV_IIR, iir_mask);
> + I915_WRITE(VLV_IMR, dev_priv->irq_mask);
> + I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
> + POSTING_READ(VLV_IER);
> +}
> +
> +static void valleyview_display_irqs_uninstall(struct drm_i915_private *dev_priv)
> +{
> + unsigned long irqflags;
> + u32 pipestat_mask;
> + u32 iir_mask;
> +
> + iir_mask = I915_DISPLAY_PORT_INTERRUPT |
> + I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
> + I915_DISPLAY_PIPE_A_EVENT_INTERRUPT;
> + dev_priv->irq_mask |= iir_mask;
> + I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
> + I915_WRITE(VLV_IMR, dev_priv->irq_mask);
> + I915_WRITE(VLV_IIR, iir_mask);
> + I915_WRITE(VLV_IIR, iir_mask);
> + POSTING_READ(VLV_IIR);
> +
> + pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
> + PIPE_CRC_DONE_INTERRUPT_STATUS;
> +
> + spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
> + i915_disable_pipestat(dev_priv, PIPE_A, pipestat_mask |
> + PIPE_GMBUS_INTERRUPT_STATUS);
> + i915_disable_pipestat(dev_priv, PIPE_B, pipestat_mask);
> + spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
> +
> + pipestat_mask = PIPESTAT_INT_STATUS_MASK |
> + PIPE_FIFO_UNDERRUN_STATUS;
> + I915_WRITE(PIPESTAT(PIPE_A), pipestat_mask);
> + I915_WRITE(PIPESTAT(PIPE_B), pipestat_mask);
> + POSTING_READ(PIPESTAT(PIPE_A));
> +}
> +
> +void valleyview_enable_display_irqs(struct drm_i915_private *dev_priv)
> +{
> + if (dev_priv->display_irqs_enabled)
> + return;
> +
> + dev_priv->display_irqs_enabled = true;
> +
> + if (dev_priv->dev->irq_enabled)
> + valleyview_display_irqs_install(dev_priv);
> +}
> +
> +void valleyview_disable_display_irqs(struct drm_i915_private *dev_priv)
> +{
> + if (!dev_priv->display_irqs_enabled)
> + return;
> +
> + dev_priv->display_irqs_enabled = false;
> +
> + if (dev_priv->dev->irq_enabled)
> + valleyview_display_irqs_uninstall(dev_priv);
> +}
> +
> static int valleyview_irq_postinstall(struct drm_device *dev)
> {
> drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
> - u32 enable_mask;
> - u32 pipestat_enable = PLANE_FLIP_DONE_INT_STATUS_VLV |
> - PIPE_CRC_DONE_INTERRUPT_STATUS;
> - unsigned long irqflags;
>
> - enable_mask = I915_DISPLAY_PORT_INTERRUPT;
> - enable_mask |= I915_DISPLAY_PIPE_A_EVENT_INTERRUPT |
> - I915_DISPLAY_PIPE_B_EVENT_INTERRUPT;
> -
> - /*
> - *Leave vblank interrupts masked initially. enable/disable will
> - * toggle them based on usage.
> - */
> - dev_priv->irq_mask = ~enable_mask;
> + dev_priv->irq_mask = ~0;
>
> I915_WRITE(PORT_HOTPLUG_EN, 0);
> POSTING_READ(PORT_HOTPLUG_EN);
>
> I915_WRITE(VLV_IMR, dev_priv->irq_mask);
> - I915_WRITE(VLV_IER, enable_mask);
> + I915_WRITE(VLV_IER, ~dev_priv->irq_mask);
> I915_WRITE(VLV_IIR, 0xffffffff);
> - I915_WRITE(PIPESTAT(0), 0xffff);
> - I915_WRITE(PIPESTAT(1), 0xffff);
> POSTING_READ(VLV_IER);
>
> - /* Interrupt setup is already guaranteed to be single-threaded, this is
> - * just to make the assert_spin_locked check happy. */
> - spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
> - i915_enable_pipestat(dev_priv, PIPE_A, pipestat_enable);
> - i915_enable_pipestat(dev_priv, PIPE_A, PIPE_GMBUS_INTERRUPT_STATUS);
> - i915_enable_pipestat(dev_priv, PIPE_B, pipestat_enable);
> - spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
> + if (dev_priv->display_irqs_enabled)
> + valleyview_display_irqs_install(dev_priv);
>
> I915_WRITE(VLV_IIR, 0xffffffff);
> I915_WRITE(VLV_IIR, 0xffffffff);
> @@ -3193,8 +3261,12 @@ static void valleyview_irq_uninstall(struct drm_device *dev)
> I915_WRITE(HWSTAM, 0xffffffff);
> I915_WRITE(PORT_HOTPLUG_EN, 0);
> I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
> - for_each_pipe(pipe)
> - I915_WRITE(PIPESTAT(pipe), 0xffff);
> +
> + if (dev_priv->display_irqs_enabled)
> + valleyview_display_irqs_uninstall(dev_priv);
> +
> + dev_priv->irq_mask = 0;
> +
> I915_WRITE(VLV_IIR, 0xffffffff);
> I915_WRITE(VLV_IMR, 0xffffffff);
> I915_WRITE(VLV_IER, 0x0);
IRQ enable state and reg state may be another good thing to cross
check. And on disable, it might be a good thing to just write all of
the pipestat irq status bits to avoid stuck interrupts (I think the
order is ok though). But you've probably tested it already so I assume
it works ok.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
--
Jesse Barnes, Intel Open Source Technology Center
next prev parent reply other threads:[~2014-02-20 19:56 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 22:02 [PATCH 00/19] drm/i915: vlv power domains support Imre Deak
2014-02-17 22:02 ` [PATCH 01/19] drm/i915: use drm_i915_private everywhere in the power domain api Imre Deak
2014-02-20 19:16 ` Jesse Barnes
2014-02-17 22:02 ` [PATCH 02/19] drm/i915: fold in __intel_power_well_get/put functions Imre Deak
2014-02-20 19:17 ` Jesse Barnes
2014-02-20 19:44 ` Chris Wilson
2014-02-24 13:23 ` Paulo Zanoni
2014-02-24 14:07 ` Imre Deak
2014-02-17 22:02 ` [PATCH 03/19] drm/i915: move modeset_update_power_wells earlier Imre Deak
2014-02-20 19:18 ` Jesse Barnes
2014-02-17 22:02 ` [PATCH 04/19] drm/i915: move power domain macros to intel_pm.c Imre Deak
2014-02-20 19:21 ` Jesse Barnes
2014-02-24 13:38 ` Paulo Zanoni
2014-02-24 13:54 ` Imre Deak
2014-02-17 22:02 ` [PATCH 05/19] drm/i915: power domains: add power well ops Imre Deak
2014-02-20 19:26 ` Jesse Barnes
2014-02-24 11:42 ` Imre Deak
2014-02-17 22:02 ` [PATCH 06/19] drm/i915: remove power_well->always_on flag Imre Deak
2014-02-20 19:27 ` Jesse Barnes
2014-02-17 22:02 ` [PATCH 07/19] drm/i915: add port power domains Imre Deak
2014-02-20 19:31 ` Jesse Barnes
2014-02-24 11:52 ` Imre Deak
2014-03-05 10:11 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 08/19] drm/i915: get port power domain in connector detect Imre Deak
2014-02-19 12:35 ` Ville Syrjälä
2014-02-19 12:39 ` Imre Deak
2014-02-20 19:33 ` Jesse Barnes
2014-02-24 11:56 ` Imre Deak
2014-03-05 10:15 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 09/19] drm/i915: check port power domain when reading the encoder hw state Imre Deak
2014-02-20 19:36 ` Jesse Barnes
2014-02-24 12:53 ` Imre Deak
2014-03-05 10:21 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 10/19] drm/i915: check pipe power domain when reading its " Imre Deak
2014-02-20 19:37 ` Jesse Barnes
2014-03-05 10:24 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 11/19] drm/i915: vlv: keep first level vblank IRQs masked Imre Deak
2014-02-18 16:54 ` Ville Syrjälä
2014-02-17 22:02 ` [PATCH 12/19] drm/i915: sanitize PUNIT register macro definitions Imre Deak
2014-02-20 19:46 ` Jesse Barnes
2014-02-24 13:12 ` Imre Deak
2014-02-17 22:02 ` [PATCH 13/19] drm/i915: factor out reset_vblank_counter Imre Deak
2014-02-18 16:55 ` Ville Syrjälä
2014-02-17 22:02 ` [PATCH 14/19] drm/i915: switch order of power domain init wrt. irq install Imre Deak
2014-02-20 19:48 ` Jesse Barnes
2014-02-24 13:23 ` Imre Deak
2014-03-05 10:29 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 15/19] drm/i915: use power domain api to check vga power state Imre Deak
2014-02-20 19:51 ` Jesse Barnes
2014-03-05 10:31 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 16/19] drm/i915: sanity check power well sw state against hw state Imre Deak
2014-02-18 16:55 ` Ville Syrjälä
2014-02-18 17:37 ` Imre Deak
2014-02-18 17:59 ` Ville Syrjälä
2014-03-05 10:32 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 17/19] drm/i915: vlv: factor out valleyview_display_irq_install Imre Deak
2014-02-20 19:56 ` Jesse Barnes [this message]
2014-02-24 13:34 ` Imre Deak
2014-02-17 22:02 ` [PATCH 18/19] drm/i915: move hsw power domain comment to its right place Imre Deak
2014-02-20 19:53 ` Jesse Barnes
2014-03-05 10:34 ` Daniel Vetter
2014-02-17 22:02 ` [PATCH 19/19] drm/i915: power domains: add vlv power wells Imre Deak
2014-02-19 12:29 ` Ville Syrjälä
2014-02-20 19:58 ` Jesse Barnes
2014-02-26 18:02 ` Imre Deak
2014-02-26 19:52 ` Jesse Barnes
2014-02-27 10:03 ` Imre Deak
2014-03-05 10:38 ` Daniel Vetter
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=20140220115616.023016a5@jbarnes-desktop \
--to=jbarnes@virtuousgeek.org \
--cc=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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