]> Pileus Git - ~andy/linux/commitdiff
drm/i915: Dynamically allocate the CRC circular buffer
authorDamien Lespiau <damien.lespiau@intel.com>
Tue, 15 Oct 2013 17:55:34 +0000 (18:55 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 16 Oct 2013 11:32:12 +0000 (13:32 +0200)
So we don't eat that memory when not needed.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_drv.h

index ec9151afa24075f3c9929878816865a95f2bb973..53a3f2224d1fef88f611eed62807bb1201264668 100644 (file)
@@ -1822,6 +1822,12 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
 
        /* none -> real source transition */
        if (source) {
+               pipe_crc->entries = kzalloc(sizeof(*pipe_crc->entries) *
+                                           INTEL_PIPE_CRC_ENTRIES_NR,
+                                           GFP_KERNEL);
+               if (!pipe_crc->entries)
+                       return -ENOMEM;
+
                atomic_set(&pipe_crc->head, 0);
                atomic_set(&pipe_crc->tail, 0);
        }
@@ -1847,6 +1853,12 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
        I915_WRITE(PIPE_CRC_CTL(pipe), val);
        POSTING_READ(PIPE_CRC_CTL(pipe));
 
+       /* real source -> none transition */
+       if (source == INTEL_PIPE_CRC_SOURCE_NONE) {
+               kfree(pipe_crc->entries);
+               pipe_crc->entries = NULL;
+       }
+
        return 0;
 }
 
index f8a36d038457d7ad344e5c3593a05662b7a555cc..1faeaac5f9f3902067fa53661840a3b1d4f32cf7 100644 (file)
@@ -1232,7 +1232,7 @@ struct intel_pipe_crc_entry {
 
 #define INTEL_PIPE_CRC_ENTRIES_NR      128
 struct intel_pipe_crc {
-       struct intel_pipe_crc_entry entries[INTEL_PIPE_CRC_ENTRIES_NR];
+       struct intel_pipe_crc_entry *entries;
        enum intel_pipe_crc_source source;
        atomic_t head, tail;
 };