From ea44f00a236726681f8fc154d7ea34e98712e2a2 Mon Sep 17 00:00:00 2001 From: Vishnu Reddy Mandalapu Date: Sat, 22 Jul 2017 16:32:39 -0700 Subject: dc: video: debugfs: Add flip stats node -- /sys/kernel/debugfs/tegradc.x/flip_stats node added. -- flip_stats node has two counters queued and skipped. -- Increment flips_queued counter for each queued fliip on a head. -- Increment flips_skipped counter for each skipped flip which are queued on a head. -- Increment flips_completed counter for each completed flip which are queued on a head. EVLR-1247 Bug 200275224 Change-Id: Ide33fc3446d127ee65fad9b922862f3204898229 Signed-off-by: Vishnu Reddy Mandalapu Reviewed-on: https://git-master.nvidia.com/r/1525014 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/video/tegra/dc/dc.c | 39 +++++++++++++++++++++++++++++++++++ drivers/video/tegra/dc/dc_priv_defs.h | 9 ++++++-- drivers/video/tegra/dc/ext/dev.c | 8 ++++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/video/tegra/dc/dc.c b/drivers/video/tegra/dc/dc.c index 9f4b8fc18..6bb4ec20b 100644 --- a/drivers/video/tegra/dc/dc.c +++ b/drivers/video/tegra/dc/dc.c @@ -2419,6 +2419,35 @@ static const struct file_operations dbg_hw_index_ops = { .release = single_release, }; +static int dbg_flip_stats_show(struct seq_file *m, void *unused) +{ + struct tegra_dc *dc = m->private; + + if (WARN_ON(!dc || !dc->out)) + return -EINVAL; + + seq_printf(m, "Flips queued: %ld\n", + atomic64_read(&dc->flip_stats.flips_queued)); + seq_printf(m, "Flips skipped: %ld\n", + atomic64_read(&dc->flip_stats.flips_skipped)); + seq_printf(m, "Flips completed: %ld\n", + atomic64_read(&dc->flip_stats.flips_cmpltd)); + + return 0; +} + +static int dbg_flip_stats_open(struct inode *inode, struct file *file) +{ + return single_open(file, dbg_flip_stats_show, inode->i_private); +} + +static const struct file_operations dbg_flip_stats_ops = { + .open = dbg_flip_stats_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static void tegra_dc_remove_debugfs(struct tegra_dc *dc) { if (dc->debugdir) @@ -2671,6 +2700,11 @@ static void tegra_dc_create_debugfs(struct tegra_dc *dc) if (!retval) goto remove_out; + retval = debugfs_create_file("flip_stats", S_IRUGO, dc->debugdir, + dc, &dbg_flip_stats_ops); + if (!retval) + goto remove_out; + if (dc->out_ops->get_connector_instance) { char sor_path[CHAR_BUF_SIZE_MAX]; int ctrl_num = -1; @@ -6211,6 +6245,11 @@ static int tegra_dc_probe(struct platform_device *ndev) } #endif + /* Initialize the flip stats to 0. */ + atomic64_set(&dc->flip_stats.flips_queued, 0); + atomic64_set(&dc->flip_stats.flips_skipped, 0); + atomic64_set(&dc->flip_stats.flips_cmpltd, 0); + tegra_dc_create_debugfs(dc); diff --git a/drivers/video/tegra/dc/dc_priv_defs.h b/drivers/video/tegra/dc/dc_priv_defs.h index c058550d4..6cf2e2f53 100644 --- a/drivers/video/tegra/dc/dc_priv_defs.h +++ b/drivers/video/tegra/dc/dc_priv_defs.h @@ -227,6 +227,12 @@ struct tegra_dc_hw_data { enum tegra_dc_hw version; }; +struct tegra_dc_flip_stats { + atomic64_t flips_skipped; + atomic64_t flips_queued; + atomic64_t flips_cmpltd; +}; + /* * struct tegra_dc_client_data - stores all per client specific data for * required for notifying when the requested events occur. @@ -569,8 +575,7 @@ struct tegra_dc { struct frame_lock_info frm_lck_info; unsigned long act_req_mask; struct tegra_dc_clients_info clients_info; - - u64 flips_queued; + struct tegra_dc_flip_stats flip_stats; struct tegra_dc_ring_buf flip_buf; /* Buffer to save flip requests */ struct tegra_dc_ring_buf crc_buf; /* Buffer to save HW generated CRCs */ diff --git a/drivers/video/tegra/dc/ext/dev.c b/drivers/video/tegra/dc/ext/dev.c index 12e2dcdbb..0edf51e6b 100644 --- a/drivers/video/tegra/dc/ext/dev.c +++ b/drivers/video/tegra/dc/ext/dev.c @@ -1224,6 +1224,9 @@ static void tegra_dc_ext_flip_worker(struct kthread_work *work) tegra_dc_incr_syncpt_min(dc, index, flip_win->syncpt_max); } + atomic64_inc(&dc->flip_stats.flips_cmpltd); + } else { + atomic64_inc(&dc->flip_stats.flips_skipped); } /* unpin and deref previous front buffers */ @@ -1918,11 +1921,10 @@ static int tegra_dc_ext_flip(struct tegra_dc_ext_user *user, #endif data->flags = flip_flags; - mutex_lock(&user->ext->dc->lock); - flip_id_local = user->ext->dc->flips_queued++; + flip_id_local = atomic64_inc_return + (&user->ext->dc->flip_stats.flips_queued); if (flip_id) *flip_id = flip_id_local; - mutex_unlock(&user->ext->dc->lock); /* Insert the flip in the flip queue if CRC is enabled */ if (atomic_read(&ext->dc->crc_ref_cnt.global)) { -- cgit v1.2.2