summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_irq.c
diff options
context:
space:
mode:
authorDamien Lespiau2013-10-15 19:55:29 +0200
committerDaniel Vetter2013-10-16 13:32:10 +0200
commitb2c88f5b1dea77b57759387728917a124eb1c098 (patch)
treeb82258528bfb2cbb7b2ff03cced9ba30e818a30c /drivers/gpu/drm/i915/i915_irq.c
parentdrm/i915: Add a control file for pipe CRCs (diff)
downloadkernel-qcow2-linux-b2c88f5b1dea77b57759387728917a124eb1c098.tar.gz
kernel-qcow2-linux-b2c88f5b1dea77b57759387728917a124eb1c098.tar.xz
kernel-qcow2-linux-b2c88f5b1dea77b57759387728917a124eb1c098.zip
drm/i915: Keep the CRC values into a circular buffer
There are a few good properties to a circular buffer, for instance it has a number of entries (before we were always dumping the full buffer). Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_irq.c')
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index d2074f129a36..73d76af13ed4 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -30,6 +30,7 @@
#include <linux/sysrq.h>
#include <linux/slab.h>
+#include <linux/circ_buf.h>
#include <drm/drmP.h>
#include <drm/i915_drm.h>
#include "i915_drv.h"
@@ -1195,20 +1196,30 @@ static void ivb_pipe_crc_update(struct drm_device *dev, enum pipe pipe)
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
ktime_t now;
- int ts, slot;
+ int ts, head, tail;
+
+ head = atomic_read(&pipe_crc->head);
+ tail = atomic_read(&pipe_crc->tail);
+
+ if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+ DRM_ERROR("CRC buffer overflowing\n");
+ return;
+ }
+
+ entry = &pipe_crc->entries[head];
now = ktime_get();
ts = ktime_to_us(now);
- slot = (atomic_read(&pipe_crc->slot) + 1) % INTEL_PIPE_CRC_ENTRIES_NR;
- entry = &pipe_crc->entries[slot];
entry->timestamp = ts;
entry->crc[0] = I915_READ(PIPE_CRC_RES_1_IVB(pipe));
entry->crc[1] = I915_READ(PIPE_CRC_RES_2_IVB(pipe));
entry->crc[2] = I915_READ(PIPE_CRC_RES_3_IVB(pipe));
entry->crc[3] = I915_READ(PIPE_CRC_RES_4_IVB(pipe));
entry->crc[4] = I915_READ(PIPE_CRC_RES_5_IVB(pipe));
- atomic_set(&dev_priv->pipe_crc[pipe].slot, slot);
+
+ head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+ atomic_set(&pipe_crc->head, head);
}
#else
static void ivb_pipe_crc_update(struct drm_device *dev, int pipe) {}