misc: tegra-profiler: send buffer fill count
Igor Nabirushkin [Tue, 24 Sep 2013 11:46:16 +0000 (15:46 +0400)]
Tegra Profiler misc driver: transmit the maximum buffer
occupancy to the user space.

Bug 1374266

Change-Id: Id078083a5493552c1f3bb697a1d3e4a5504e3f82
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/324051
(cherry picked from commit 9e94874e5edee9baa2e6be21712fa67a967eb6bc)
Reviewed-on: http://git-master/r/340006
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>

drivers/misc/tegra-profiler/comm.c
drivers/misc/tegra-profiler/comm.h
drivers/misc/tegra-profiler/version.h
include/linux/tegra_profiler.h

index e7a21ea..9273d8a 100644 (file)
@@ -46,6 +46,7 @@ static void rb_reset(struct quadd_ring_buffer *rb)
        rb->pos_read = 0;
        rb->pos_write = 0;
        rb->fill_count = 0;
+       rb->max_fill_count = 0;
 }
 
 static int rb_init(struct quadd_ring_buffer *rb, size_t size)
@@ -225,6 +226,10 @@ write_sample(struct quadd_record_data *sample, void *extra_data,
                        return;
                }
        }
+
+       if (rb->fill_count > rb->max_fill_count)
+               rb->max_fill_count = rb->fill_count;
+
        spin_unlock_irqrestore(&rb->lock, flags);
 }
 
@@ -541,6 +546,8 @@ device_ioctl(struct file *file,
                spin_lock_irqsave(&rb->lock, flags);
                state.buffer_fill_size =
                        comm_ctx.rb_size - rb_get_free_space(rb);
+               state.reserved[QUADD_MOD_STATE_IDX_RB_MAX_FILL_COUNT] =
+                       rb->max_fill_count;
                spin_unlock_irqrestore(&rb->lock, flags);
 
                if (copy_to_user((void __user *)ioctl_param, &state,
index e3c7e28..f519f17 100644 (file)
@@ -32,6 +32,7 @@ struct quadd_ring_buffer {
        size_t pos_read;
        size_t pos_write;
        size_t fill_count;
+       size_t max_fill_count;
 };
 
 struct quadd_parameters;
index 8d2eec0..2d55c51 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.31"
+#define QUADD_MODULE_VERSION           "1.32"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */
index 5840ba3..2efa9c1 100644 (file)
 #include <linux/ioctl.h>
 
 #define QUADD_SAMPLES_VERSION  16
-#define QUADD_IO_VERSION       5
+#define QUADD_IO_VERSION       6
 
-#define QUADD_IO_VERSION_DYNAMIC_RB    5
+#define QUADD_IO_VERSION_DYNAMIC_RB            5
+#define QUADD_IO_VERSION_RB_MAX_FILL_COUNT     6
 
 #define QUADD_MAX_COUNTERS     32
 #define QUADD_MAX_PROCESS      64
@@ -283,6 +284,10 @@ struct quadd_comm_cap {
        u32 reserved[16];       /* reserved fields for future extensions */
 };
 
+enum {
+       QUADD_MOD_STATE_IDX_RB_MAX_FILL_COUNT = 0,
+};
+
 struct quadd_module_state {
        u64 nr_all_samples;
        u64 nr_skipped_samples;