mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
debug: add trace tag and more trace print [1/2]
PD#SWPL-8124 Problem: There are too many trace info when enabled Lack some important trace info Solution: Add tag to enable/disable trace info for different modules Add more trace info Verify: P212 Change-Id: I9916b97071dc6b3a5e133bb0ea55eb9a9532cec8 Signed-off-by: Tao Guo <tao.guo@amlogic.com>
This commit is contained in:
@@ -14,8 +14,117 @@
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/meson_atrace.h>
|
||||
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(tracing_mark_write);
|
||||
static uint64_t atrace_tag;
|
||||
|
||||
#define TAG_INFO(name) \
|
||||
{ #name, KERNEL_ATRACE_TAG_ ## name }
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
int tag;
|
||||
} tag_info[] = {
|
||||
TAG_INFO(VIDEO),
|
||||
TAG_INFO(CODEC_MM),
|
||||
TAG_INFO(VDEC),
|
||||
TAG_INFO(TSYNC),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int get_atrace_tag_enabled(unsigned short tag)
|
||||
{
|
||||
if (tag == KERNEL_ATRACE_TAG_ALL)
|
||||
return 1;
|
||||
return atrace_tag & (1 << tag);
|
||||
}
|
||||
EXPORT_SYMBOL(get_atrace_tag_enabled);
|
||||
|
||||
void set_atrace_tag_enabled(unsigned short tag, int enable)
|
||||
{
|
||||
if (enable)
|
||||
atrace_tag |= 1 << tag;
|
||||
else
|
||||
atrace_tag &= ~(1 << tag);
|
||||
}
|
||||
EXPORT_SYMBOL(set_atrace_tag_enabled);
|
||||
|
||||
static ssize_t show_atrace_tag(struct class *class,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t size = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tag_info) && tag_info[i].name; i++) {
|
||||
size += sprintf(buf + size, "%2d %s %s\n",
|
||||
tag_info[i].tag, tag_info[i].name,
|
||||
get_atrace_tag_enabled(tag_info[i].tag) ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static ssize_t store_atrace_tag(struct class *class,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
unsigned int tag;
|
||||
ssize_t r;
|
||||
|
||||
r = kstrtouint(buf, 0, &tag);
|
||||
|
||||
if (r != 0)
|
||||
return -EINVAL;
|
||||
if (tag < KERNEL_ATRACE_TAG_MAX)
|
||||
set_atrace_tag_enabled(tag, !get_atrace_tag_enabled(tag));
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
static struct class_attribute debug_class_attrs[] = {
|
||||
__ATTR(atrace_tag, 0664, show_atrace_tag, store_atrace_tag),
|
||||
__ATTR_NULL
|
||||
};
|
||||
|
||||
static struct class debug_class = {
|
||||
.name = "debug",
|
||||
.class_attrs = debug_class_attrs,
|
||||
};
|
||||
|
||||
static int __init debug_module_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = class_register(&debug_class);
|
||||
|
||||
if (r) {
|
||||
pr_err("debug class create fail.\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit debug_module_exit(void)
|
||||
{
|
||||
class_unregister(&debug_class);
|
||||
}
|
||||
|
||||
void meson_atrace(int tag, const char *name, unsigned int flags,
|
||||
unsigned int value)
|
||||
{
|
||||
if (get_atrace_tag_enabled(tag))
|
||||
trace_tracing_mark_write(name, flags, value);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(meson_atrace);
|
||||
|
||||
|
||||
module_init(debug_module_init);
|
||||
module_exit(debug_module_exit);
|
||||
MODULE_DESCRIPTION("AMLOGIC meson debugger controller");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Tao Guo <tao.guo@amlogic.com>");
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "codec_mm_priv.h"
|
||||
#include "codec_mm_scatter_priv.h"
|
||||
#define KERNEL_ATRACE_TAG KERNEL_ATRACE_TAG_CODEC_MM
|
||||
#include <trace/events/meson_atrace.h>
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
#define KERNEL_ATRACE_TAG KERNEL_ATRACE_TAG_TSYNC
|
||||
#include <trace/events/meson_atrace.h>
|
||||
|
||||
|
||||
@@ -64,12 +65,14 @@ EXPORT_SYMBOL(timestamp_vpts_get);
|
||||
void timestamp_vpts_set(u32 pts)
|
||||
{
|
||||
video_pts = pts;
|
||||
ATRACE_COUNTER("VPTS", video_pts);
|
||||
}
|
||||
EXPORT_SYMBOL(timestamp_vpts_set);
|
||||
|
||||
void timestamp_vpts_inc(s32 val)
|
||||
{
|
||||
video_pts += val;
|
||||
ATRACE_COUNTER("VPTS", video_pts);
|
||||
}
|
||||
EXPORT_SYMBOL(timestamp_vpts_inc);
|
||||
|
||||
@@ -82,6 +85,7 @@ EXPORT_SYMBOL(timestamp_apts_get);
|
||||
void timestamp_apts_set(u32 pts)
|
||||
{
|
||||
audio_pts = pts;
|
||||
ATRACE_COUNTER("APTS", audio_pts);
|
||||
}
|
||||
EXPORT_SYMBOL(timestamp_apts_set);
|
||||
|
||||
@@ -92,6 +96,7 @@ void timestamp_apts_inc(s32 inc)
|
||||
inc = inc * timestamp_inc_factor / PLL_FACTOR;
|
||||
#endif
|
||||
audio_pts += inc;
|
||||
ATRACE_COUNTER("APTS", audio_pts);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(timestamp_apts_inc);
|
||||
@@ -161,8 +166,8 @@ 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;
|
||||
ATRACE_COUNTER("PCRSCR", pts);
|
||||
}
|
||||
EXPORT_SYMBOL(timestamp_pcrscr_set);
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/amlogic/media/video_sink/video_keeper.h>
|
||||
#include "video_priv.h"
|
||||
#define KERNEL_ATRACE_TAG KERNEL_ATRACE_TAG_VIDEO
|
||||
#include <trace/events/meson_atrace.h>
|
||||
|
||||
#if defined(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM)
|
||||
@@ -3532,6 +3533,7 @@ static void vsync_toggle_frame(struct vframe_s *vf, int line)
|
||||
ATRACE_COUNTER("vsync_toggle_frame_inc", diff_pts);
|
||||
else
|
||||
ATRACE_COUNTER("vsync_toggle_frame_inc", 0); /* discontinue */
|
||||
|
||||
last_pts = vf->pts;
|
||||
|
||||
frame_count++;
|
||||
|
||||
@@ -32,17 +32,36 @@
|
||||
#define KERNEL_ATRACE_COUNTER 0
|
||||
#define KERNEL_ATRACE_BEGIN 1
|
||||
#define KERNEL_ATRACE_END 2
|
||||
#define KERNEL_ATRACE_ASYNC_BEGIN 3
|
||||
#define KERNEL_ATRACE_ASYNC_END 4
|
||||
|
||||
#if !defined(TRACE_HEADER_MULTI_READ)
|
||||
|
||||
enum {
|
||||
KERNEL_ATRACE_TAG_VIDEO,
|
||||
KERNEL_ATRACE_TAG_CODEC_MM,
|
||||
KERNEL_ATRACE_TAG_VDEC,
|
||||
KERNEL_ATRACE_TAG_TSYNC,
|
||||
KERNEL_ATRACE_TAG_MAX = 64,
|
||||
KERNEL_ATRACE_TAG_ALL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#define print_flags_header(flags) __print_flags(flags, "", \
|
||||
{ (1UL << KERNEL_ATRACE_COUNTER), "C" }, \
|
||||
{ (1UL << KERNEL_ATRACE_BEGIN), "B" }, \
|
||||
{ (1UL << KERNEL_ATRACE_END), "E" })
|
||||
{ (1UL << KERNEL_ATRACE_COUNTER), "C" }, \
|
||||
{ (1UL << KERNEL_ATRACE_BEGIN), "B" }, \
|
||||
{ (1UL << KERNEL_ATRACE_END), "E" }, \
|
||||
{ (1UL << KERNEL_ATRACE_ASYNC_BEGIN), "S" }, \
|
||||
{ (1UL << KERNEL_ATRACE_ASYNC_END), "F" })
|
||||
|
||||
|
||||
#define print_flags_delim(flags) __print_flags(flags, "", \
|
||||
{ (1UL << KERNEL_ATRACE_COUNTER), "|1|" }, \
|
||||
{ (1UL << KERNEL_ATRACE_BEGIN), "|1|" }, \
|
||||
{ (1UL << KERNEL_ATRACE_END), "" })
|
||||
{ (1UL << KERNEL_ATRACE_COUNTER), "|1|" },\
|
||||
{ (1UL << KERNEL_ATRACE_BEGIN), "|1|" },\
|
||||
{ (1UL << KERNEL_ATRACE_END), "" }, \
|
||||
{ (1UL << KERNEL_ATRACE_ASYNC_BEGIN), "|1|" },\
|
||||
{ (1UL << KERNEL_ATRACE_ASYNC_END), "|1|" })
|
||||
|
||||
TRACE_EVENT(tracing_mark_write,
|
||||
|
||||
@@ -66,17 +85,32 @@ TRACE_EVENT(tracing_mark_write,
|
||||
print_flags_delim(__entry->flags),
|
||||
__get_str(name), __entry->value)
|
||||
);
|
||||
|
||||
#ifdef CONFIG_AMLOGIC_DEBUG_ATRACE
|
||||
void meson_atrace(int tag, const char *name, unsigned int flags,
|
||||
unsigned int value);
|
||||
|
||||
#define ATRACE_COUNTER(name, value) \
|
||||
trace_tracing_mark_write(name, (1 << KERNEL_ATRACE_COUNTER), value)
|
||||
meson_atrace(KERNEL_ATRACE_TAG, name, \
|
||||
(1 << KERNEL_ATRACE_COUNTER), value)
|
||||
#define ATRACE_BEGIN(name) \
|
||||
trace_tracing_mark_write(name, (1 << KERNEL_ATRACE_BEGIN), 0)
|
||||
meson_atrace(KERNEL_ATRACE_TAG, name, \
|
||||
(1 << KERNEL_ATRACE_BEGIN), 0)
|
||||
#define ATRACE_END(name) \
|
||||
trace_tracing_mark_write("", (1 << KERNEL_ATRACE_END), 1)
|
||||
meson_atrace(KERNEL_ATRACE_TAG, "", \
|
||||
(1 << KERNEL_ATRACE_END), 1)
|
||||
#define ATRACE_ASYNC_BEGIN(name, cookie) \
|
||||
meson_atrace(KERNEL_ATRACE_TAG, name, \
|
||||
(1 << KERNEL_ATRACE_ASYNC_BEGIN), cookie)
|
||||
#define ATRACE_ASYNC_END(name, cookie) \
|
||||
meson_atrace(KERNEL_ATRACE_TAG, name, \
|
||||
(1 << KERNEL_ATRACE_ASYNC_END), cookie)
|
||||
#else
|
||||
#define ATRACE_COUNTER(name, value)
|
||||
#define ATRACE_BEGIN(name)
|
||||
#define ATRACE_END(name)
|
||||
#define ATRACE_ASYNC_BEGIN(name, cookie)
|
||||
#define ATRACE_ASYNC_END(name, cookie)
|
||||
#endif
|
||||
|
||||
#endif /* _TRACE_MESON_BASE_H */
|
||||
|
||||
Reference in New Issue
Block a user