debug: add atrace support [1/1]

PD#SWPL-4956

Problem:
Need atrace to debug multimedia issue

Solution:
Add atrace functions

Verify:
P212

Change-Id: I0f07387dfa35a33c25e538a474a3a12bd88d5092
Signed-off-by: Tao Guo <tao.guo@amlogic.com>
This commit is contained in:
Tao Guo
2019-01-16 17:11:54 +08:00
committed by Jianxin Pan
parent 755c783ef1
commit 76a5e27b93
7 changed files with 80 additions and 11 deletions

View File

@@ -14512,6 +14512,7 @@ F: drivers/amlogic/defendkey/*
AMLOGIC DEBUG
M: Jianxin Pan <jianxin.pan@amlogic.com>
M: Tao Guo <tao.guo@amlogic.com>
F: drivers/amlogic/debug/*
AMLOGIC G12A spdif channel status

View File

@@ -13,3 +13,9 @@ config AMLOGIC_DEBUG_LOCKUP
Debug lockup in isr and deaklock whit irq disabled.
When enable this config, Watchdog should be disabled.
config AMLOGIC_DEBUG_ATRACE
bool "Amlogic Kernel ATrace"
depends on AMLOGIC_DEBUG
default y
help
Add android atrace compatible function

View File

@@ -1 +1,2 @@
obj-$(CONFIG_AMLOGIC_DEBUG_LOCKUP) += debug_lockup.o
obj-$(CONFIG_AMLOGIC_DEBUG_ATRACE) += meson_atrace.o

View File

@@ -0,0 +1,21 @@
/*
* drivers/amlogic/debug/meson_atrace.c
*
* Copyright (C) 2017 Amlogic, Inc. 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.
*
*/
#define CREATE_TRACE_POINTS
#include <trace/events/meson_atrace.h>
EXPORT_TRACEPOINT_SYMBOL_GPL(tracing_mark_write);

View File

@@ -22,6 +22,7 @@
#include <linux/amlogic/media/utils/vdec_reg.h>
#include <linux/amlogic/media/registers/register.h>
#include <linux/amlogic/media/vout/vout_notify.h>
#include <trace/events/meson_atrace.h>
u32 acc_apts_inc;
@@ -147,6 +148,7 @@ EXPORT_SYMBOL(timestamp_tsdemux_pcr_get);
void timestamp_pcrscr_set(u32 pts)
{
/*pr_info("timestamp_pcrscr_set system time = %x\n", pts);*/
ATRACE_COUNTER("PCRSCR", pts);
system_time = pts;
}
EXPORT_SYMBOL(timestamp_pcrscr_set);
@@ -210,6 +212,7 @@ void timestamp_pcrscr_inc(s32 inc)
inc = inc * timestamp_inc_factor / PLL_FACTOR;
#endif
system_time += inc + system_time_inc_adj;
ATRACE_COUNTER("PCRSCR", system_time);
}
}
EXPORT_SYMBOL(timestamp_pcrscr_inc);
@@ -234,6 +237,7 @@ void timestamp_pcrscr_inc_scale(s32 inc, u32 base)
system_time++;
system_time_scale_remainder -= system_time_scale_base;
}
ATRACE_COUNTER("PCRSCR", system_time);
}
}
EXPORT_SYMBOL(timestamp_pcrscr_inc_scale);

View File

@@ -49,6 +49,7 @@
#include <linux/sched.h>
#include <linux/amlogic/media/video_sink/video_keeper.h>
#include "video_priv.h"
#include <trace/events/meson_atrace.h>
#if defined(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM)
#include <linux/amlogic/media/amvecm/amvecm.h>
@@ -3535,8 +3536,10 @@ static u64 func_div(u64 number, u32 divid)
return tmp;
}
static void vsync_toggle_frame(struct vframe_s *vf)
static void vsync_toggle_frame(struct vframe_s *vf, int line)
{
static u32 last_pts;
u32 diff_pts;
u32 first_picture = 0;
unsigned long flags = 0;
bool vf_with_el = false;
@@ -3544,8 +3547,18 @@ static void vsync_toggle_frame(struct vframe_s *vf)
long long *clk_array;
bool is_mvc = false;
ATRACE_COUNTER(__func__, line);
if (vf == NULL)
return;
ATRACE_COUNTER("vsync_toggle_frame_pts", vf->pts);
diff_pts = vf->pts - last_pts;
if (last_pts && diff_pts < 90000)
ATRACE_COUNTER("vsync_toggle_frame_inc", diff_pts);
else
ATRACE_COUNTER("vsync_toggle_frame_inc", 0); /* discontinue */
last_pts = vf->pts;
frame_count++;
toggle_count++;
@@ -3628,6 +3641,7 @@ static void vsync_toggle_frame(struct vframe_s *vf)
if ((vf->width == 0) && (vf->height == 0)) {
amlog_level(LOG_LEVEL_ERROR,
"Video: invalid frame dimension\n");
ATRACE_COUNTER(__func__, __LINE__);
return;
}
@@ -3661,6 +3675,7 @@ static void vsync_toggle_frame(struct vframe_s *vf)
}
}
video_vf_put(vf);
ATRACE_COUNTER(__func__, __LINE__);
return;
}
}
@@ -4055,6 +4070,7 @@ static void vsync_toggle_frame(struct vframe_s *vf)
}
if (stop_update)
frame_par_ready_to_set = 0;
ATRACE_COUNTER(__func__, 0);
}
static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf)
@@ -6548,7 +6564,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
cur_index;
}
}
vsync_toggle_frame(cur_dispbuf);
vsync_toggle_frame(cur_dispbuf, __LINE__);
} else
video_property_changed = 0;
} else {
@@ -6561,11 +6577,12 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
/* setting video display property in underflow mode */
if ((!vf) && cur_dispbuf && (video_property_changed))
vsync_toggle_frame(cur_dispbuf);
vsync_toggle_frame(cur_dispbuf, __LINE__);
/*debug info for skip & repeate vframe case*/
if (!vf) {
underflow++;
ATRACE_COUNTER("underflow", 1);
if (video_dbg_vf&(1<<0))
dump_vframe_status("vdin0");
if (video_dbg_vf&(1<<1))
@@ -6576,6 +6593,8 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
dump_vframe_status("ppmgr");
if (video_dbg_vf&(1<<4))
dump_vdin_reg();
} else {
ATRACE_COUNTER("underflow", 0);
}
video_get_vf_cnt = 0;
if (platform_type == 1) {
@@ -6585,6 +6604,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
}
while (vf) {
if (vpts_expire(cur_dispbuf, vf, toggle_cnt) || show_nosync) {
ATRACE_COUNTER(MODULE_NAME, __LINE__);
if (debug_flag & DEBUG_FLAG_PTS_TRACE)
pr_info("vpts = 0x%x, c.dur=0x%x, n.pts=0x%x, scr = 0x%x, pcr-pts-diff=%d, ptstrace=%d\n",
timestamp_vpts_get(),
@@ -6634,8 +6654,10 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
hdmiin_frame_check_cnt = 0;
vf = video_vf_get();
if (!vf)
if (!vf) {
ATRACE_COUNTER(MODULE_NAME, __LINE__);
break;
}
if (debug_flag & DEBUG_FLAG_LATENCY) {
vf->ready_clock[2] = sched_clock();
pr_info("video get latency %lld ms vdin put latency %lld ms. first %lld ms.\n",
@@ -6643,8 +6665,10 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
func_div(vf->ready_clock[1], 1000),
func_div(vf->ready_clock[0], 1000));
}
if (video_vf_dirty_put(vf))
if (video_vf_dirty_put(vf)) {
ATRACE_COUNTER(MODULE_NAME, __LINE__);
break;
}
if (vf && hdmiin_frame_check && (vf->source_type ==
VFRAME_SOURCE_TYPE_HDMI) &&
video_vf_disp_mode_check(vf))
@@ -6662,7 +6686,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
video_3d_format = vf->trans_fmt;
}
}
vsync_toggle_frame(vf);
vsync_toggle_frame(vf, __LINE__);
toggle_frame = vf;
#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
if (is_dolby_vision_enable()) {
@@ -6709,6 +6733,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
if (video_get_vf_cnt >= 2)
video_drop_vf_cnt++;
} else {
ATRACE_COUNTER(MODULE_NAME, __LINE__);
/* check if current frame's duration has expired,
*in this example
* it compares current frame display duration
@@ -6720,6 +6745,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
* The playback can be smoother than previous method.
*/
if (slowsync_repeat_enable) {
ATRACE_COUNTER(MODULE_NAME, __LINE__);
if (duration_expire
(cur_dispbuf, vf,
frame_repeat_count * vsync_pts_inc)
@@ -6751,9 +6777,12 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
break;
#endif
vf = video_vf_get();
if (!vf)
if (!vf) {
ATRACE_COUNTER(MODULE_NAME,
__LINE__);
break;
vsync_toggle_frame(vf);
}
vsync_toggle_frame(vf, __LINE__);
toggle_frame = vf;
#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
if (is_dolby_vision_enable())
@@ -6786,9 +6815,11 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
if (blackout | force_blackout) {
if (cur_dispbuf != &vf_local)
vsync_toggle_frame(
cur_dispbuf);
cur_dispbuf,
__LINE__);
} else
vsync_toggle_frame(cur_dispbuf);
vsync_toggle_frame(cur_dispbuf,
__LINE__);
if (is_dolby_vision_enable()) {
pause_vf = cur_dispbuf;
video_pause_global = 1;

View File

@@ -66,13 +66,18 @@ TRACE_EVENT(tracing_mark_write,
print_flags_delim(__entry->flags),
__get_str(name), __entry->value)
);
#ifdef CONFIG_AMLOGIC_DEBUG_ATRACE
#define ATRACE_COUNTER(name, value) \
trace_tracing_mark_write(name, (1 << KERNEL_ATRACE_COUNTER), value)
#define ATRACE_BEGIN(name) \
trace_tracing_mark_write(name, (1 << KERNEL_ATRACE_BEGIN), 0)
#define ATRACE_END(name) \
trace_tracing_mark_write("", (1 << KERNEL_ATRACE_END), 1)
#else
#define ATRACE_COUNTER(name, value)
#define ATRACE_BEGIN(name)
#define ATRACE_END(name)
#endif
#endif /* _TRACE_MESON_BASE_H */