2014-09-30 15:56:46 +07:00
|
|
|
/*
|
|
|
|
* Copyright © 2014 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Daniel Vetter <daniel.vetter@ffwll.ch>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "i915_drv.h"
|
|
|
|
#include "intel_drv.h"
|
2019-04-05 18:00:08 +07:00
|
|
|
#include "intel_fbc.h"
|
2019-04-29 19:29:24 +07:00
|
|
|
#include "intel_fifo_underrun.h"
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2014-09-30 15:56:50 +07:00
|
|
|
/**
|
|
|
|
* DOC: fifo underrun handling
|
|
|
|
*
|
|
|
|
* The i915 driver checks for display fifo underruns using the interrupt signals
|
|
|
|
* provided by the hardware. This is enabled by default and fairly useful to
|
|
|
|
* debug display issues, especially watermark settings.
|
|
|
|
*
|
|
|
|
* If an underrun is detected this is logged into dmesg. To avoid flooding logs
|
|
|
|
* and occupying the cpu underrun interrupts are disabled after the first
|
|
|
|
* occurrence until the next modeset on a given pipe.
|
|
|
|
*
|
|
|
|
* Note that underrun detection on gmch platforms is a bit more ugly since there
|
|
|
|
* is no interrupt (despite that the signalling bit is in the PIPESTAT pipe
|
|
|
|
* interrupt register). Also on some other platforms underrun interrupts are
|
|
|
|
* shared, which means that if we detect an underrun we need to disable underrun
|
|
|
|
* reporting on all pipes.
|
|
|
|
*
|
|
|
|
* The code also supports underrun detection on the PCH transcoder.
|
|
|
|
*/
|
|
|
|
|
2014-09-30 15:56:46 +07:00
|
|
|
static bool ivb_can_enable_err_int(struct drm_device *dev)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2014-09-30 15:56:46 +07:00
|
|
|
struct intel_crtc *crtc;
|
|
|
|
enum pipe pipe;
|
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2016-11-01 03:37:10 +07:00
|
|
|
crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (crtc->cpu_fifo_underrun_disabled)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool cpt_can_enable_serr_int(struct drm_device *dev)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2014-09-30 15:56:46 +07:00
|
|
|
enum pipe pipe;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
2016-11-01 03:37:10 +07:00
|
|
|
crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (crtc->pch_fifo_underrun_disabled)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-31 00:22:21 +07:00
|
|
|
static void i9xx_check_fifo_underruns(struct intel_crtc *crtc)
|
2014-09-30 15:56:46 +07:00
|
|
|
{
|
2015-10-31 00:22:21 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 20:33:26 +07:00
|
|
|
i915_reg_t reg = PIPESTAT(crtc->pipe);
|
2017-09-14 22:17:31 +07:00
|
|
|
u32 enable_mask;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2017-09-14 22:17:31 +07:00
|
|
|
if ((I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS) == 0)
|
2015-10-31 00:22:21 +07:00
|
|
|
return;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2017-09-14 22:17:31 +07:00
|
|
|
enable_mask = i915_pipestat_enable_mask(dev_priv, crtc->pipe);
|
|
|
|
I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS);
|
2015-10-31 00:22:21 +07:00
|
|
|
POSTING_READ(reg);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2017-03-03 00:15:08 +07:00
|
|
|
trace_intel_cpu_fifo_underrun(dev_priv, crtc->pipe);
|
2015-10-31 00:22:21 +07:00
|
|
|
DRM_ERROR("pipe %c underrun\n", pipe_name(crtc->pipe));
|
2014-09-30 15:56:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void i9xx_set_fifo_underrun_reporting(struct drm_device *dev,
|
|
|
|
enum pipe pipe,
|
|
|
|
bool enable, bool old)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 20:33:26 +07:00
|
|
|
i915_reg_t reg = PIPESTAT(pipe);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (enable) {
|
2017-09-14 22:17:31 +07:00
|
|
|
u32 enable_mask = i915_pipestat_enable_mask(dev_priv, pipe);
|
|
|
|
|
|
|
|
I915_WRITE(reg, enable_mask | PIPE_FIFO_UNDERRUN_STATUS);
|
2014-09-30 15:56:46 +07:00
|
|
|
POSTING_READ(reg);
|
|
|
|
} else {
|
2017-09-14 22:17:31 +07:00
|
|
|
if (old && I915_READ(reg) & PIPE_FIFO_UNDERRUN_STATUS)
|
2014-09-30 15:56:46 +07:00
|
|
|
DRM_ERROR("pipe %c underrun\n", pipe_name(pipe));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ironlake_set_fifo_underrun_reporting(struct drm_device *dev,
|
|
|
|
enum pipe pipe, bool enable)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 bit = (pipe == PIPE_A) ?
|
|
|
|
DE_PIPEA_FIFO_UNDERRUN : DE_PIPEB_FIFO_UNDERRUN;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (enable)
|
2015-11-23 23:06:16 +07:00
|
|
|
ilk_enable_display_irq(dev_priv, bit);
|
2014-09-30 15:56:46 +07:00
|
|
|
else
|
2015-11-23 23:06:16 +07:00
|
|
|
ilk_disable_display_irq(dev_priv, bit);
|
2014-09-30 15:56:46 +07:00
|
|
|
}
|
|
|
|
|
2015-10-31 00:22:21 +07:00
|
|
|
static void ivybridge_check_fifo_underruns(struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
|
|
|
enum pipe pipe = crtc->pipe;
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 err_int = I915_READ(GEN7_ERR_INT);
|
2015-10-31 00:22:21 +07:00
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2015-10-31 00:22:21 +07:00
|
|
|
|
|
|
|
if ((err_int & ERR_INT_FIFO_UNDERRUN(pipe)) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
|
|
|
|
POSTING_READ(GEN7_ERR_INT);
|
|
|
|
|
2017-03-03 00:15:08 +07:00
|
|
|
trace_intel_cpu_fifo_underrun(dev_priv, pipe);
|
2015-10-31 00:22:21 +07:00
|
|
|
DRM_ERROR("fifo underrun on pipe %c\n", pipe_name(pipe));
|
|
|
|
}
|
|
|
|
|
2014-09-30 15:56:46 +07:00
|
|
|
static void ivybridge_set_fifo_underrun_reporting(struct drm_device *dev,
|
|
|
|
enum pipe pipe,
|
|
|
|
bool enable, bool old)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2014-09-30 15:56:46 +07:00
|
|
|
if (enable) {
|
|
|
|
I915_WRITE(GEN7_ERR_INT, ERR_INT_FIFO_UNDERRUN(pipe));
|
|
|
|
|
|
|
|
if (!ivb_can_enable_err_int(dev))
|
|
|
|
return;
|
|
|
|
|
2015-11-23 23:06:16 +07:00
|
|
|
ilk_enable_display_irq(dev_priv, DE_ERR_INT_IVB);
|
2014-09-30 15:56:46 +07:00
|
|
|
} else {
|
2015-11-23 23:06:16 +07:00
|
|
|
ilk_disable_display_irq(dev_priv, DE_ERR_INT_IVB);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (old &&
|
|
|
|
I915_READ(GEN7_ERR_INT) & ERR_INT_FIFO_UNDERRUN(pipe)) {
|
|
|
|
DRM_ERROR("uncleared fifo underrun on pipe %c\n",
|
|
|
|
pipe_name(pipe));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void broadwell_set_fifo_underrun_reporting(struct drm_device *dev,
|
|
|
|
enum pipe pipe, bool enable)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (enable)
|
2015-11-23 23:06:17 +07:00
|
|
|
bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
|
2014-09-30 15:56:46 +07:00
|
|
|
else
|
2015-11-23 23:06:17 +07:00
|
|
|
bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_FIFO_UNDERRUN);
|
2014-09-30 15:56:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ibx_set_fifo_underrun_reporting(struct drm_device *dev,
|
2017-09-01 21:31:23 +07:00
|
|
|
enum pipe pch_transcoder,
|
2014-09-30 15:56:46 +07:00
|
|
|
bool enable)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 bit = (pch_transcoder == PIPE_A) ?
|
|
|
|
SDE_TRANSA_FIFO_UNDER : SDE_TRANSB_FIFO_UNDER;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (enable)
|
|
|
|
ibx_enable_display_interrupt(dev_priv, bit);
|
|
|
|
else
|
|
|
|
ibx_disable_display_interrupt(dev_priv, bit);
|
|
|
|
}
|
|
|
|
|
2015-10-31 00:22:21 +07:00
|
|
|
static void cpt_check_pch_fifo_underruns(struct intel_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
|
2017-09-01 21:31:23 +07:00
|
|
|
enum pipe pch_transcoder = crtc->pipe;
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 serr_int = I915_READ(SERR_INT);
|
2015-10-31 00:22:21 +07:00
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2015-10-31 00:22:21 +07:00
|
|
|
|
|
|
|
if ((serr_int & SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
I915_WRITE(SERR_INT, SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
|
|
|
|
POSTING_READ(SERR_INT);
|
|
|
|
|
2017-03-03 00:15:08 +07:00
|
|
|
trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder);
|
2017-09-01 21:31:23 +07:00
|
|
|
DRM_ERROR("pch fifo underrun on pch transcoder %c\n",
|
|
|
|
pipe_name(pch_transcoder));
|
2015-10-31 00:22:21 +07:00
|
|
|
}
|
|
|
|
|
2014-09-30 15:56:46 +07:00
|
|
|
static void cpt_set_fifo_underrun_reporting(struct drm_device *dev,
|
2017-09-01 21:31:23 +07:00
|
|
|
enum pipe pch_transcoder,
|
2014-09-30 15:56:46 +07:00
|
|
|
bool enable, bool old)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
if (enable) {
|
|
|
|
I915_WRITE(SERR_INT,
|
|
|
|
SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder));
|
|
|
|
|
|
|
|
if (!cpt_can_enable_serr_int(dev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ibx_enable_display_interrupt(dev_priv, SDE_ERROR_CPT);
|
|
|
|
} else {
|
|
|
|
ibx_disable_display_interrupt(dev_priv, SDE_ERROR_CPT);
|
|
|
|
|
|
|
|
if (old && I915_READ(SERR_INT) &
|
|
|
|
SERR_INT_TRANS_FIFO_UNDERRUN(pch_transcoder)) {
|
2017-09-01 21:31:23 +07:00
|
|
|
DRM_ERROR("uncleared pch fifo underrun on pch transcoder %c\n",
|
|
|
|
pipe_name(pch_transcoder));
|
2014-09-30 15:56:46 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
|
|
|
|
enum pipe pipe, bool enable)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2016-11-01 03:37:10 +07:00
|
|
|
struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
|
2014-09-30 15:56:46 +07:00
|
|
|
bool old;
|
|
|
|
|
2017-03-02 20:28:01 +07:00
|
|
|
lockdep_assert_held(&dev_priv->irq_lock);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2016-11-01 03:37:05 +07:00
|
|
|
old = !crtc->cpu_fifo_underrun_disabled;
|
|
|
|
crtc->cpu_fifo_underrun_disabled = !enable;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2019-02-05 05:25:38 +07:00
|
|
|
if (HAS_GMCH(dev_priv))
|
2014-09-30 15:56:46 +07:00
|
|
|
i9xx_set_fifo_underrun_reporting(dev, pipe, enable, old);
|
drm/i915: merge gen checks to use range
Instead of using IS_GEN() for consecutive gen checks, let's pass the
range to IS_GEN_RANGE(). By code inspection these were the ranges deemed
necessary for spatch:
@@
expression e;
@@
(
- IS_GEN(e, 3) || IS_GEN(e, 2)
+ IS_GEN_RANGE(e, 2, 3)
|
- IS_GEN(e, 3) || IS_GEN(e, 4)
+ IS_GEN_RANGE(e, 3, 4)
|
- IS_GEN(e, 5) || IS_GEN(e, 6)
+ IS_GEN_RANGE(e, 5, 6)
|
- IS_GEN(e, 6) || IS_GEN(e, 7)
+ IS_GEN_RANGE(e, 6, 7)
|
- IS_GEN(e, 7) || IS_GEN(e, 8)
+ IS_GEN_RANGE(e, 7, 8)
|
- IS_GEN(e, 8) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 8, 9)
|
- IS_GEN(e, 10) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 9, 10)
|
- IS_GEN(e, 9) || IS_GEN(e, 10)
+ IS_GEN_RANGE(e, 9, 10)
)
After conversion, checking we don't have any missing IS_GEN_RANGE() ||
IS_GEN() was also done.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-3-lucas.demarchi@intel.com
2018-12-13 01:10:44 +07:00
|
|
|
else if (IS_GEN_RANGE(dev_priv, 5, 6))
|
2014-09-30 15:56:46 +07:00
|
|
|
ironlake_set_fifo_underrun_reporting(dev, pipe, enable);
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-13 01:10:43 +07:00
|
|
|
else if (IS_GEN(dev_priv, 7))
|
2014-09-30 15:56:46 +07:00
|
|
|
ivybridge_set_fifo_underrun_reporting(dev, pipe, enable, old);
|
2017-06-10 05:26:13 +07:00
|
|
|
else if (INTEL_GEN(dev_priv) >= 8)
|
2014-09-30 15:56:46 +07:00
|
|
|
broadwell_set_fifo_underrun_reporting(dev, pipe, enable);
|
|
|
|
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
2014-09-30 15:56:50 +07:00
|
|
|
/**
|
|
|
|
* intel_set_cpu_fifo_underrun_reporting - set cpu fifo underrrun reporting state
|
|
|
|
* @dev_priv: i915 device instance
|
|
|
|
* @pipe: (CPU) pipe to set state for
|
|
|
|
* @enable: whether underruns should be reported or not
|
|
|
|
*
|
|
|
|
* This function sets the fifo underrun state for @pipe. It is used in the
|
|
|
|
* modeset code to avoid false positives since on many platforms underruns are
|
|
|
|
* expected when disabling or enabling the pipe.
|
|
|
|
*
|
|
|
|
* Notice that on some platforms disabling underrun reports for one pipe
|
|
|
|
* disables for all due to shared interrupts. Actual reporting is still per-pipe
|
|
|
|
* though.
|
|
|
|
*
|
|
|
|
* Returns the previous state of underrun reporting.
|
|
|
|
*/
|
2014-09-30 15:56:47 +07:00
|
|
|
bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
|
2014-09-30 15:56:46 +07:00
|
|
|
enum pipe pipe, bool enable)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev_priv->irq_lock, flags);
|
2016-07-05 16:40:23 +07:00
|
|
|
ret = __intel_set_cpu_fifo_underrun_reporting(&dev_priv->drm, pipe,
|
2014-09-30 15:56:47 +07:00
|
|
|
enable);
|
2014-09-30 15:56:46 +07:00
|
|
|
spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-30 15:56:50 +07:00
|
|
|
* intel_set_pch_fifo_underrun_reporting - set PCH fifo underrun reporting state
|
|
|
|
* @dev_priv: i915 device instance
|
2014-09-30 15:56:46 +07:00
|
|
|
* @pch_transcoder: the PCH transcoder (same as pipe on IVB and older)
|
2014-09-30 15:56:50 +07:00
|
|
|
* @enable: whether underruns should be reported or not
|
2014-09-30 15:56:46 +07:00
|
|
|
*
|
|
|
|
* This function makes us disable or enable PCH fifo underruns for a specific
|
|
|
|
* PCH transcoder. Notice that on some PCHs (e.g. CPT/PPT), disabling FIFO
|
|
|
|
* underrun reporting for one transcoder may also disable all the other PCH
|
|
|
|
* error interruts for the other transcoders, due to the fact that there's just
|
|
|
|
* one interrupt mask/enable bit for all the transcoders.
|
|
|
|
*
|
|
|
|
* Returns the previous state of underrun reporting.
|
|
|
|
*/
|
2014-09-30 15:56:47 +07:00
|
|
|
bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
|
2017-07-18 01:14:03 +07:00
|
|
|
enum pipe pch_transcoder,
|
2014-09-30 15:56:46 +07:00
|
|
|
bool enable)
|
|
|
|
{
|
2016-11-01 03:37:10 +07:00
|
|
|
struct intel_crtc *crtc =
|
2017-07-18 01:14:03 +07:00
|
|
|
intel_get_crtc_for_pipe(dev_priv, pch_transcoder);
|
2014-09-30 15:56:46 +07:00
|
|
|
unsigned long flags;
|
|
|
|
bool old;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Pre-LPT has a fixed cpu pipe -> pch transcoder mapping, but LPT
|
|
|
|
* has only one pch transcoder A that all pipes can use. To avoid racy
|
|
|
|
* pch transcoder -> pipe lookups from interrupt code simply store the
|
|
|
|
* underrun statistics in crtc A. Since we never expose this anywhere
|
|
|
|
* nor use it outside of the fifo underrun code here using the "wrong"
|
|
|
|
* crtc on LPT won't cause issues.
|
|
|
|
*/
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev_priv->irq_lock, flags);
|
|
|
|
|
2016-11-01 03:37:05 +07:00
|
|
|
old = !crtc->pch_fifo_underrun_disabled;
|
|
|
|
crtc->pch_fifo_underrun_disabled = !enable;
|
2014-09-30 15:56:46 +07:00
|
|
|
|
2016-04-07 15:08:05 +07:00
|
|
|
if (HAS_PCH_IBX(dev_priv))
|
2016-07-05 16:40:23 +07:00
|
|
|
ibx_set_fifo_underrun_reporting(&dev_priv->drm,
|
|
|
|
pch_transcoder,
|
2014-09-30 15:56:47 +07:00
|
|
|
enable);
|
2014-09-30 15:56:46 +07:00
|
|
|
else
|
2016-07-05 16:40:23 +07:00
|
|
|
cpt_set_fifo_underrun_reporting(&dev_priv->drm,
|
|
|
|
pch_transcoder,
|
2014-09-30 15:56:47 +07:00
|
|
|
enable, old);
|
2014-09-30 15:56:46 +07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
|
|
|
|
return old;
|
|
|
|
}
|
2014-09-30 15:56:48 +07:00
|
|
|
|
2014-09-30 15:56:50 +07:00
|
|
|
/**
|
2015-01-26 23:47:32 +07:00
|
|
|
* intel_cpu_fifo_underrun_irq_handler - handle CPU fifo underrun interrupt
|
2014-09-30 15:56:50 +07:00
|
|
|
* @dev_priv: i915 device instance
|
|
|
|
* @pipe: (CPU) pipe to set state for
|
|
|
|
*
|
|
|
|
* This handles a CPU fifo underrun interrupt, generating an underrun warning
|
|
|
|
* into dmesg if underrun reporting is enabled and then disables the underrun
|
|
|
|
* interrupt to avoid an irq storm.
|
|
|
|
*/
|
2014-09-30 15:56:48 +07:00
|
|
|
void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe)
|
|
|
|
{
|
2016-11-01 03:37:10 +07:00
|
|
|
struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
|
2015-02-26 22:53:02 +07:00
|
|
|
|
|
|
|
/* We may be called too early in init, thanks BIOS! */
|
|
|
|
if (crtc == NULL)
|
|
|
|
return;
|
|
|
|
|
2014-09-30 15:56:49 +07:00
|
|
|
/* GMCH can't disable fifo underruns, filter them. */
|
2019-02-05 05:25:38 +07:00
|
|
|
if (HAS_GMCH(dev_priv) &&
|
2016-11-01 03:37:05 +07:00
|
|
|
crtc->cpu_fifo_underrun_disabled)
|
2014-09-30 15:56:49 +07:00
|
|
|
return;
|
|
|
|
|
2017-03-03 00:15:08 +07:00
|
|
|
if (intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false)) {
|
|
|
|
trace_intel_cpu_fifo_underrun(dev_priv, pipe);
|
2014-09-30 15:56:48 +07:00
|
|
|
DRM_ERROR("CPU pipe %c FIFO underrun\n",
|
|
|
|
pipe_name(pipe));
|
2017-03-03 00:15:08 +07:00
|
|
|
}
|
2016-09-13 20:38:57 +07:00
|
|
|
|
|
|
|
intel_fbc_handle_fifo_underrun_irq(dev_priv);
|
2014-09-30 15:56:48 +07:00
|
|
|
}
|
|
|
|
|
2014-09-30 15:56:50 +07:00
|
|
|
/**
|
|
|
|
* intel_pch_fifo_underrun_irq_handler - handle PCH fifo underrun interrupt
|
|
|
|
* @dev_priv: i915 device instance
|
|
|
|
* @pch_transcoder: the PCH transcoder (same as pipe on IVB and older)
|
|
|
|
*
|
|
|
|
* This handles a PCH fifo underrun interrupt, generating an underrun warning
|
|
|
|
* into dmesg if underrun reporting is enabled and then disables the underrun
|
|
|
|
* interrupt to avoid an irq storm.
|
|
|
|
*/
|
2014-09-30 15:56:48 +07:00
|
|
|
void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
|
2017-07-18 01:14:03 +07:00
|
|
|
enum pipe pch_transcoder)
|
2014-09-30 15:56:48 +07:00
|
|
|
{
|
|
|
|
if (intel_set_pch_fifo_underrun_reporting(dev_priv, pch_transcoder,
|
2017-03-03 00:15:08 +07:00
|
|
|
false)) {
|
|
|
|
trace_intel_pch_fifo_underrun(dev_priv, pch_transcoder);
|
2017-09-01 21:31:23 +07:00
|
|
|
DRM_ERROR("PCH transcoder %c FIFO underrun\n",
|
|
|
|
pipe_name(pch_transcoder));
|
2017-03-03 00:15:08 +07:00
|
|
|
}
|
2014-09-30 15:56:48 +07:00
|
|
|
}
|
2015-10-31 00:22:21 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_check_cpu_fifo_underruns - check for CPU fifo underruns immediately
|
|
|
|
* @dev_priv: i915 device instance
|
|
|
|
*
|
|
|
|
* Check for CPU fifo underruns immediately. Useful on IVB/HSW where the shared
|
|
|
|
* error interrupt may have been disabled, and so CPU fifo underruns won't
|
|
|
|
* necessarily raise an interrupt, and on GMCH platforms where underruns never
|
|
|
|
* raise an interrupt.
|
|
|
|
*/
|
|
|
|
void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
spin_lock_irq(&dev_priv->irq_lock);
|
|
|
|
|
2016-07-05 16:40:23 +07:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2015-10-31 00:22:21 +07:00
|
|
|
if (crtc->cpu_fifo_underrun_disabled)
|
|
|
|
continue;
|
|
|
|
|
2019-02-05 05:25:38 +07:00
|
|
|
if (HAS_GMCH(dev_priv))
|
2015-10-31 00:22:21 +07:00
|
|
|
i9xx_check_fifo_underruns(crtc);
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-13 01:10:43 +07:00
|
|
|
else if (IS_GEN(dev_priv, 7))
|
2015-10-31 00:22:21 +07:00
|
|
|
ivybridge_check_fifo_underruns(crtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irq(&dev_priv->irq_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_check_pch_fifo_underruns - check for PCH fifo underruns immediately
|
|
|
|
* @dev_priv: i915 device instance
|
|
|
|
*
|
|
|
|
* Check for PCH fifo underruns immediately. Useful on CPT/PPT where the shared
|
|
|
|
* error interrupt may have been disabled, and so PCH fifo underruns won't
|
|
|
|
* necessarily raise an interrupt.
|
|
|
|
*/
|
|
|
|
void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
|
|
|
|
spin_lock_irq(&dev_priv->irq_lock);
|
|
|
|
|
2016-07-05 16:40:23 +07:00
|
|
|
for_each_intel_crtc(&dev_priv->drm, crtc) {
|
2015-10-31 00:22:21 +07:00
|
|
|
if (crtc->pch_fifo_underrun_disabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (HAS_PCH_CPT(dev_priv))
|
|
|
|
cpt_check_pch_fifo_underruns(crtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irq(&dev_priv->irq_lock);
|
|
|
|
}
|