diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2013-10-15 13:55:29 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-10-16 07:32:10 -0400 |
commit | b2c88f5b1dea77b57759387728917a124eb1c098 (patch) | |
tree | b82258528bfb2cbb7b2ff03cced9ba30e818a30c /drivers/gpu/drm/i915/i915_irq.c | |
parent | 926321d503406d1fefb2fae9651beca14160529a (diff) |
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.c | 19 |
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 @@ | |||
30 | 30 | ||
31 | #include <linux/sysrq.h> | 31 | #include <linux/sysrq.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/circ_buf.h> | ||
33 | #include <drm/drmP.h> | 34 | #include <drm/drmP.h> |
34 | #include <drm/i915_drm.h> | 35 | #include <drm/i915_drm.h> |
35 | #include "i915_drv.h" | 36 | #include "i915_drv.h" |
@@ -1195,20 +1196,30 @@ static void ivb_pipe_crc_update(struct drm_device *dev, enum pipe pipe) | |||
1195 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; | 1196 | struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe]; |
1196 | struct intel_pipe_crc_entry *entry; | 1197 | struct intel_pipe_crc_entry *entry; |
1197 | ktime_t now; | 1198 | ktime_t now; |
1198 | int ts, slot; | 1199 | int ts, head, tail; |
1200 | |||
1201 | head = atomic_read(&pipe_crc->head); | ||
1202 | tail = atomic_read(&pipe_crc->tail); | ||
1203 | |||
1204 | if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) { | ||
1205 | DRM_ERROR("CRC buffer overflowing\n"); | ||
1206 | return; | ||
1207 | } | ||
1208 | |||
1209 | entry = &pipe_crc->entries[head]; | ||
1199 | 1210 | ||
1200 | now = ktime_get(); | 1211 | now = ktime_get(); |
1201 | ts = ktime_to_us(now); | 1212 | ts = ktime_to_us(now); |
1202 | 1213 | ||
1203 | slot = (atomic_read(&pipe_crc->slot) + 1) % INTEL_PIPE_CRC_ENTRIES_NR; | ||
1204 | entry = &pipe_crc->entries[slot]; | ||
1205 | entry->timestamp = ts; | 1214 | entry->timestamp = ts; |
1206 | entry->crc[0] = I915_READ(PIPE_CRC_RES_1_IVB(pipe)); | 1215 | entry->crc[0] = I915_READ(PIPE_CRC_RES_1_IVB(pipe)); |
1207 | entry->crc[1] = I915_READ(PIPE_CRC_RES_2_IVB(pipe)); | 1216 | entry->crc[1] = I915_READ(PIPE_CRC_RES_2_IVB(pipe)); |
1208 | entry->crc[2] = I915_READ(PIPE_CRC_RES_3_IVB(pipe)); | 1217 | entry->crc[2] = I915_READ(PIPE_CRC_RES_3_IVB(pipe)); |
1209 | entry->crc[3] = I915_READ(PIPE_CRC_RES_4_IVB(pipe)); | 1218 | entry->crc[3] = I915_READ(PIPE_CRC_RES_4_IVB(pipe)); |
1210 | entry->crc[4] = I915_READ(PIPE_CRC_RES_5_IVB(pipe)); | 1219 | entry->crc[4] = I915_READ(PIPE_CRC_RES_5_IVB(pipe)); |
1211 | atomic_set(&dev_priv->pipe_crc[pipe].slot, slot); | 1220 | |
1221 | head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1); | ||
1222 | atomic_set(&pipe_crc->head, head); | ||
1212 | } | 1223 | } |
1213 | #else | 1224 | #else |
1214 | static void ivb_pipe_crc_update(struct drm_device *dev, int pipe) {} | 1225 | static void ivb_pipe_crc_update(struct drm_device *dev, int pipe) {} |