From a5408cee2613ab60becdf04e289d0944c8e44603 Mon Sep 17 00:00:00 2001 From: Somasundaram S Date: Mon, 1 Sep 2014 17:41:29 +0530 Subject: [PATCH] media: tegra: nvavp: Add tracing support for nvavp Add run-time tracing support for NVAVP driver Bug 200018378 Change-Id: I1e786e52295d387a4d60991aac125aaa097e5950 Signed-off-by: Somasundaram S Reviewed-on: http://git-master/r/494479 (cherry picked from commit a149aa766cf33a0edd798d331d213589b1983f61) Reviewed-on: http://git-master/r/504669 (cherry picked from commit f2c62cf27fa14a1334727f8f765f3d9afe141ceb) Reviewed-on: http://git-master/r/540022 Reviewed-by: Eric Chuang Tested-by: Eric Chuang --- .../media/platform/tegra/nvavp/nvavp_dev.c | 52 +++ include/trace/events/nvavp.h | 324 ++++++++++++++++++ 2 files changed, 376 insertions(+) create mode 100644 include/trace/events/nvavp.h diff --git a/drivers/media/platform/tegra/nvavp/nvavp_dev.c b/drivers/media/platform/tegra/nvavp/nvavp_dev.c index b3948013da1..6a12156fcfd 100644 --- a/drivers/media/platform/tegra/nvavp/nvavp_dev.c +++ b/drivers/media/platform/tegra/nvavp/nvavp_dev.c @@ -8,6 +8,9 @@ * kind, whether express or implied. */ +#define CREATE_TRACE_POINTS +#include + #include #include #include @@ -616,6 +619,11 @@ static void clock_disable_handler(struct work_struct *work) channel_info = nvavp_get_channel_info(nvavp, NVAVP_VIDEO_CHANNEL); mutex_lock(&channel_info->pushbuffer_lock); mutex_lock(&nvavp->open_lock); + + trace_nvavp_clock_disable_handler(channel_info->os_control->put, + channel_info->os_control->get, + nvavp->pending); + if (nvavp_check_idle(nvavp, NVAVP_VIDEO_CHANNEL) && nvavp->pending) { nvavp->pending = false; nvavp_clks_disable(nvavp); @@ -978,6 +986,10 @@ static int nvavp_pushbuffer_update(struct nvavp_info *nvavp, u32 phys_addr, syncpt->value = value; } + trace_nvavp_pushbuffer_update(channel_id, control->put, control->get, + phys_addr, gather_count, + sizeof(struct nvavp_syncpt), syncpt); + err_exit: mutex_unlock(&channel_info->pushbuffer_lock); nvavp_runtime_put(nvavp); @@ -1381,6 +1393,8 @@ static int nvavp_map_iova(struct file *filp, unsigned int cmd, map_arg.addr = (__u32)addr; + trace_nvavp_map_iova(clientctx->channel_id, map_arg.fd, map_arg.addr); + if (copy_to_user((void __user *)arg, &map_arg, sizeof(struct nvavp_map_args))) { dev_err(&nvavp->nvhost_dev->dev, @@ -1413,6 +1427,8 @@ static int nvavp_unmap_iova(struct file *filp, unsigned long arg) return PTR_ERR(dmabuf); } + trace_nvavp_unmap_iova(clientctx->channel_id, map_arg.fd, map_arg.addr); + nvavp_release_iova_addr(clientctx, dmabuf, (dma_addr_t)map_arg.addr); dma_buf_put(dmabuf); @@ -1449,6 +1465,10 @@ static int nvavp_set_clock_ioctl(struct file *filp, unsigned int cmd, config.rate = clk_get_rate(c); clk_disable_unprepare(c); + + trace_nvavp_set_clock_ioctl(clientctx->channel_id, config.id, + config.rate); + if (copy_to_user((void __user *)arg, &config, sizeof(struct nvavp_clock_args))) return -EFAULT; @@ -1474,6 +1494,9 @@ static int nvavp_get_clock_ioctl(struct file *filp, unsigned int cmd, config.rate = clk_get_rate(c); clk_disable_unprepare(c); + trace_nvavp_get_clock_ioctl(clientctx->channel_id, config.id, + config.rate); + if (copy_to_user((void __user *)arg, &config, sizeof(struct nvavp_clock_args))) return -EFAULT; @@ -1493,6 +1516,9 @@ static int nvavp_get_syncpointid_ioctl(struct file *filp, unsigned int cmd, else return 0; } + + trace_nvavp_get_syncpointid_ioctl(clientctx->channel_id, id); + return -EFAULT; } @@ -1609,6 +1635,10 @@ target_dmabuf_fail: goto err_reloc_info; } + trace_nvavp_pushbuffer_submit_ioctl(clientctx->channel_id, + hdr.cmdbuf.mem, hdr.cmdbuf.offset, + hdr.cmdbuf.words, hdr.num_relocs, hdr.flags); + if (hdr.syncpt) { ret = nvavp_pushbuffer_update(nvavp, (phys_addr + hdr.cmdbuf.offset), @@ -1745,6 +1775,9 @@ static int nvavp_force_clock_stay_on_ioctl(struct file *filp, unsigned int cmd, return -EINVAL; } + trace_nvavp_force_clock_stay_on_ioctl(clientctx->channel_id, + clock.state, clientctx->clk_reqs); + if (clock.state) { mutex_lock(&nvavp->open_lock); if (clientctx->clk_reqs++ == 0) { @@ -1775,6 +1808,8 @@ int nvavp_enable_audio_clocks(nvavp_clientctx_t client, u32 clk_id) dev_dbg(&nvavp->nvhost_dev->dev, "%s: clk_id = %d\n", __func__, clk_id); + trace_nvavp_enable_audio_clocks(clientctx->channel_id, clk_id); + mutex_lock(&nvavp->open_lock); if (clk_id == NVAVP_MODULE_ID_VCP) clk_prepare_enable(nvavp->vcp_clk); @@ -1793,6 +1828,8 @@ int nvavp_disable_audio_clocks(nvavp_clientctx_t client, u32 clk_id) dev_dbg(&nvavp->nvhost_dev->dev, "%s: clk_id = %d\n", __func__, clk_id); + trace_nvavp_disable_audio_clocks(clientctx->channel_id, clk_id); + mutex_lock(&nvavp->open_lock); if (clk_id == NVAVP_MODULE_ID_VCP) clk_disable_unprepare(nvavp->vcp_clk); @@ -1830,6 +1867,9 @@ static int nvavp_set_min_online_cpus_ioctl(struct file *filp, unsigned int cmd, dev_dbg(&nvavp->nvhost_dev->dev, "%s: min_online_cpus=%d\n", __func__, config.min_online_cpus); + trace_nvavp_set_min_online_cpus_ioctl(clientctx->channel_id, + config.min_online_cpus); + if (config.min_online_cpus > 0) pm_qos_update_request(&nvavp->min_online_cpus_req, config.min_online_cpus); @@ -1866,6 +1906,9 @@ static int tegra_nvavp_open(struct nvavp_info *nvavp, nvavp->audio_refcnt++; } + trace_tegra_nvavp_open(channel_id, nvavp->refcount, + nvavp->video_refcnt, nvavp->audio_refcnt); + clientctx->nvavp = nvavp; clientctx->iova_handles = RB_ROOT; *client = clientctx; @@ -1956,6 +1999,9 @@ static int tegra_nvavp_release(struct nvavp_clientctx *clientctx, if (IS_AUDIO_CHANNEL_ID(channel_id)) nvavp->audio_refcnt--; + trace_tegra_nvavp_release(channel_id, nvavp->refcount, + nvavp->video_refcnt, nvavp->audio_refcnt); + out: nvavp_remove_iova_mapping(clientctx); kfree(clientctx); @@ -2558,6 +2604,9 @@ static int tegra_nvavp_runtime_suspend(struct device *dev) } } + trace_tegra_nvavp_runtime_suspend(nvavp->refcount, nvavp->video_refcnt, + nvavp->audio_refcnt); + mutex_unlock(&nvavp->open_lock); return ret; @@ -2577,6 +2626,9 @@ static int tegra_nvavp_runtime_resume(struct device *dev) nvavp_init(nvavp, NVAVP_AUDIO_CHANNEL); #endif + trace_tegra_nvavp_runtime_resume(nvavp->refcount, nvavp->video_refcnt, + nvavp->audio_refcnt); + mutex_unlock(&nvavp->open_lock); return 0; diff --git a/include/trace/events/nvavp.h b/include/trace/events/nvavp.h new file mode 100644 index 00000000000..0175207921b --- /dev/null +++ b/include/trace/events/nvavp.h @@ -0,0 +1,324 @@ +/* + * NVAVP event logging to ftrace. + * + * Copyright (c) 2014, NVIDIA Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM nvavp + +#if !defined(_TRACE_NVAVP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_NVAVP_H + +#include +#include + +DECLARE_EVENT_CLASS(nvavp, + TP_PROTO(u32 channel_id, u32 refcount, + u32 video_refcount, u32 audio_refcount), + TP_ARGS(channel_id, refcount, video_refcount, audio_refcount), + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, refcount) + __field(u32, video_refcount) + __field(u32, audio_refcount) + ), + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->refcount = refcount; + __entry->video_refcount = video_refcount; + __entry->audio_refcount = audio_refcount; + ), + TP_printk("channel_id=%d, refcnt=%d, vid_refcnt=%d, aud_refcnt=%d", + __entry->channel_id, __entry->refcount, __entry->video_refcount, + __entry->audio_refcount) +); + +DEFINE_EVENT(nvavp, tegra_nvavp_open, + TP_PROTO(u32 channel_id, u32 refcount, + u32 video_refcount, u32 audio_refcount), + TP_ARGS(channel_id, refcount, video_refcount, audio_refcount) +); + +DEFINE_EVENT(nvavp, tegra_nvavp_release, + TP_PROTO(u32 channel_id, u32 refcount, + u32 video_refcount, u32 audio_refcount), + TP_ARGS(channel_id, refcount, video_refcount, audio_refcount) +); + +TRACE_EVENT(nvavp_clock_disable_handler, + TP_PROTO(u32 put_ptr, u32 get_ptr, u32 nvavp_pending), + + TP_ARGS(put_ptr, get_ptr, nvavp_pending), + + TP_STRUCT__entry( + __field(u32, put_ptr) + __field(u32, get_ptr) + __field(u32, nvavp_pending) + ), + + TP_fast_assign( + __entry->put_ptr = put_ptr; + __entry->get_ptr = get_ptr; + __entry->nvavp_pending = nvavp_pending; + ), + + TP_printk("put_ptr=%u, get_ptr=%u, nvavp_pending=%d", + __entry->put_ptr, __entry->get_ptr, __entry->nvavp_pending) +); + +TRACE_EVENT(nvavp_pushbuffer_update, + TP_PROTO(u32 channel_id, u32 put_ptr, u32 get_ptr, + phys_addr_t phys_addr, u32 gather_count, + u32 syncpt_len, void *syncpt), + + TP_ARGS(channel_id, put_ptr, get_ptr, phys_addr, + gather_count, syncpt_len, syncpt), + + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, put_ptr) + __field(u32, get_ptr) + __field(phys_addr_t, phys_addr) + __field(u32, gather_count) + __field(u32, syncpt_len) + __field(bool, syncpt) + __dynamic_array(u32, syncpt, syncpt_len) + ), + + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->put_ptr = put_ptr; + __entry->get_ptr = get_ptr; + __entry->phys_addr = phys_addr; + __entry->gather_count = gather_count; + __entry->syncpt_len = syncpt_len; + __entry->syncpt = syncpt; + if (syncpt) + memcpy(__get_dynamic_array(syncpt), syncpt, syncpt_len); + ), + + TP_printk("channel_id=%d, put_ptr=%d, get_ptr=%d, phys_addr=%08llx, gather_count=%d, syncpt_len=%d, syncpt=%s", + __entry->channel_id, __entry->put_ptr, + __entry->get_ptr, (u64)__entry->phys_addr, + __entry->gather_count, __entry->syncpt_len, + __print_hex(__get_dynamic_array(syncpt), + __entry->syncpt ? __entry->syncpt_len : 0)) +); + +DECLARE_EVENT_CLASS(nvavp_iova, + TP_PROTO(u32 channel_id, s32 fd, dma_addr_t addr), + TP_ARGS(channel_id, fd, addr), + TP_STRUCT__entry( + __field(u32, channel_id) + __field(s32, fd) + __field(dma_addr_t, addr) + ), + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->fd = fd; + __entry->addr = addr; + ), + TP_printk("channel_id=%d, fd=%d, addr=%08llx", + __entry->channel_id, __entry->fd, (u64) __entry->addr) +); + +DEFINE_EVENT(nvavp_iova, nvavp_map_iova, + TP_PROTO(u32 channel_id, s32 fd, dma_addr_t addr), + TP_ARGS(channel_id, fd, addr) +); + +DEFINE_EVENT(nvavp_iova, nvavp_unmap_iova, + TP_PROTO(u32 channel_id, s32 fd, dma_addr_t addr), + TP_ARGS(channel_id, fd, addr) +); + +DECLARE_EVENT_CLASS(nvavp_clock, + TP_PROTO(u32 channel_id, u32 clk_id, u32 rate), + TP_ARGS(channel_id, clk_id, rate), + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, clk_id) + __field(u32, rate) + ), + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->clk_id = clk_id; + __entry->rate = rate; + ), + TP_printk("channel_id=%d, clk_id=%d, rate=%u", + __entry->channel_id, __entry->clk_id, __entry->rate) +); + +DEFINE_EVENT(nvavp_clock, nvavp_set_clock_ioctl, + TP_PROTO(u32 channel_id, u32 clk_id, u32 rate), + TP_ARGS(channel_id, clk_id, rate) +); + +DEFINE_EVENT(nvavp_clock, nvavp_get_clock_ioctl, + TP_PROTO(u32 channel_id, u32 clk_id, u32 rate), + TP_ARGS(channel_id, clk_id, rate) +); + +TRACE_EVENT(nvavp_get_syncpointid_ioctl, + TP_PROTO(u32 channel_id, u32 syncpt_id), + + TP_ARGS(channel_id, syncpt_id), + + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, syncpt_id) + ), + + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->syncpt_id = syncpt_id; + ), + + TP_printk("channel_id=%d, syncpt_id=%d", + __entry->channel_id, __entry->syncpt_id) +); + +TRACE_EVENT(nvavp_pushbuffer_submit_ioctl, + TP_PROTO(u32 channel_id, u32 mem, u32 offset, u32 words, + u32 num_relocs, u32 flags), + + TP_ARGS(channel_id, mem, offset, words, + num_relocs, flags), + + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, mem) + __field(u32, offset) + __field(u32, words) + __field(u32, num_relocs) + __field(u32, flags) + ), + + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->mem = mem; + __entry->offset = offset; + __entry->words = words; + __entry->num_relocs = num_relocs; + __entry->flags = flags; + ), + + TP_printk( + "channel_id=%d, mem=%u, offset=%d, words=%d, num_relocs = %d, flags=%d", + __entry->channel_id, __entry->mem, __entry->offset, + __entry->words, __entry->num_relocs, __entry->flags + ) +); + +TRACE_EVENT(nvavp_force_clock_stay_on_ioctl, + TP_PROTO(u32 channel_id, u32 clk_state, u32 clk_reqs), + + TP_ARGS(channel_id, clk_state, clk_reqs), + + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, clk_state) + __field(u32, clk_reqs) + ), + + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->clk_state = clk_state; + __entry->clk_reqs = clk_reqs; + ), + + TP_printk("channel_id=%d, clk_state=%d, clk_reqs=%d", + __entry->channel_id, __entry->clk_state, __entry->clk_reqs) +); + +DECLARE_EVENT_CLASS(nvavp_audio_clocks, + TP_PROTO(u32 channel_id, u32 clk_id), + TP_ARGS(channel_id, clk_id), + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, clk_id) + ), + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->clk_id = clk_id; + ), + TP_printk("channel_id=%d, clk_id=%d", + __entry->channel_id, __entry->clk_id) +); + +DEFINE_EVENT(nvavp_audio_clocks, nvavp_enable_audio_clocks, + TP_PROTO(u32 channel_id, u32 clk_id), + TP_ARGS(channel_id, clk_id) +); + +DEFINE_EVENT(nvavp_audio_clocks, nvavp_disable_audio_clocks, + TP_PROTO(u32 channel_id, u32 clk_id), + TP_ARGS(channel_id, clk_id) +); + +TRACE_EVENT(nvavp_set_min_online_cpus_ioctl, + TP_PROTO(u32 channel_id, u32 num_cpus), + + TP_ARGS(channel_id, num_cpus), + + TP_STRUCT__entry( + __field(u32, channel_id) + __field(u32, num_cpus) + ), + + TP_fast_assign( + __entry->channel_id = channel_id; + __entry->num_cpus = num_cpus; + ), + + TP_printk("channel_id=%d, num_cpus=%d", + __entry->channel_id, __entry->num_cpus) +); + +DECLARE_EVENT_CLASS(nvavp_suspend_resume, + TP_PROTO(u32 refcount, u32 video_refcount, u32 audio_refcount), + TP_ARGS(refcount, video_refcount, audio_refcount), + TP_STRUCT__entry( + __field(u32, refcount) + __field(u32, video_refcount) + __field(u32, audio_refcount) + ), + TP_fast_assign( + __entry->refcount = refcount; + __entry->video_refcount = video_refcount; + __entry->audio_refcount = audio_refcount; + ), + TP_printk("refcnt=%d, vid_refcnt=%d, aud_refcnt=%d", + __entry->refcount, __entry->video_refcount, + __entry->audio_refcount) +); + +DEFINE_EVENT(nvavp_suspend_resume, tegra_nvavp_runtime_suspend, + TP_PROTO(u32 refcount, u32 video_refcount, u32 audio_refcount), + TP_ARGS(refcount, video_refcount, audio_refcount) +); + +DEFINE_EVENT(nvavp_suspend_resume, tegra_nvavp_runtime_resume, + TP_PROTO(u32 refcount, u32 video_refcount, u32 audio_refcount), + TP_ARGS(refcount, video_refcount, audio_refcount) +); + +#endif /* _TRACE_NVAVP_H */ + +/* This part must be outside protection */ +#include -- 2.39.2