msm: camera: utils: Route camera logs to ftrace
Add debugfs setting to route camera logs : ERR, WARN, INFO, DBG to ftrace. Add CAM_TRACE macro for adding any new traces in drivers. Usage: CAM_TRACE : By default printed in ftrace CAM_ERR, CAM_WARN, CAM_INFO, CAM_DBG : enable using debugfs debug_type = 1 or 2 For CAM_DBG : In addition to above enable debug_mdl with required mask. adb shell "echo <value> > /sys/module/camera/parameters/debug_type" All CAM_xx (except CAM_TRACE) logs are routed as below : 0 (default) - only logcat 1 - only ftrace 2 - both logcat and ftrace. CRs-Fixed: 2762931 Change-Id: I5254a7fef346c7ba21a3ea1eed21e5353f42fd03 Signed-off-by: Pavan Kumar Chilamkurthi <pchilamk@codeaurora.org>
This commit is contained in:
@@ -6,11 +6,17 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include "cam_trace.h"
|
||||
|
||||
#include "cam_debug_util.h"
|
||||
|
||||
static uint debug_mdl;
|
||||
module_param(debug_mdl, uint, 0644);
|
||||
|
||||
/* 0x0 - only logs, 0x1 - only trace, 0x2 - logs + trace */
|
||||
static uint debug_type;
|
||||
module_param(debug_type, uint, 0644);
|
||||
|
||||
struct camera_debug_settings cam_debug;
|
||||
|
||||
const struct camera_debug_settings *cam_debug_get_settings()
|
||||
@@ -217,6 +223,34 @@ const char *cam_get_module_name(unsigned int module_id)
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *cam_get_tag_name(unsigned int tag_id)
|
||||
{
|
||||
const char *name = NULL;
|
||||
|
||||
switch (tag_id) {
|
||||
case CAM_TYPE_TRACE:
|
||||
name = "CAM_TRACE";
|
||||
break;
|
||||
case CAM_TYPE_ERR:
|
||||
name = "CAM_ERR";
|
||||
break;
|
||||
case CAM_TYPE_WARN:
|
||||
name = "CAM_WARN";
|
||||
break;
|
||||
case CAM_TYPE_INFO:
|
||||
name = "CAM_INFO";
|
||||
break;
|
||||
case CAM_TYPE_DBG:
|
||||
name = "CAM_DBG";
|
||||
break;
|
||||
default:
|
||||
name = "CAM";
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void cam_debug_log(unsigned int module_id, const char *func, const int line,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
@@ -227,10 +261,47 @@ void cam_debug_log(unsigned int module_id, const char *func, const int line,
|
||||
|
||||
if (debug_mdl & module_id) {
|
||||
vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
|
||||
pr_info("CAM_DBG: %s: %s: %d: %s\n",
|
||||
cam_get_module_name(module_id),
|
||||
func, line, str_buffer);
|
||||
|
||||
if ((debug_type == 0) || (debug_type == 2)) {
|
||||
pr_info("CAM_DBG: %s: %s: %d: %s\n",
|
||||
cam_get_module_name(module_id),
|
||||
func, line, str_buffer);
|
||||
}
|
||||
|
||||
if ((debug_type == 1) || (debug_type == 2)) {
|
||||
char trace_buffer[STR_BUFFER_MAX_LENGTH];
|
||||
|
||||
snprintf(trace_buffer, sizeof(trace_buffer),
|
||||
"%s: %s: %s: %d: %s",
|
||||
cam_get_tag_name(CAM_TYPE_DBG),
|
||||
cam_get_module_name(module_id),
|
||||
func, line, str_buffer);
|
||||
trace_cam_log_debug(trace_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cam_debug_trace(unsigned int tag, unsigned int module_id,
|
||||
const char *func, const int line, const char *fmt, ...)
|
||||
{
|
||||
char str_buffer[STR_BUFFER_MAX_LENGTH];
|
||||
va_list args;
|
||||
|
||||
if ((tag == CAM_TYPE_TRACE) || (debug_type == 1) || (debug_type == 2)) {
|
||||
char trace_buffer[STR_BUFFER_MAX_LENGTH];
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
|
||||
|
||||
snprintf(trace_buffer, sizeof(trace_buffer),
|
||||
"%s: %s: %s: %d: %s",
|
||||
cam_get_tag_name(tag), cam_get_module_name(module_id),
|
||||
func, line, str_buffer);
|
||||
trace_cam_log_debug(trace_buffer);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
/* Module IDs used for debug logging */
|
||||
#define CAM_CDM (1 << 0)
|
||||
#define CAM_CORE (1 << 1)
|
||||
#define CAM_CPAS (1 << 2)
|
||||
@@ -31,23 +32,22 @@
|
||||
#define CAM_OIS (1 << 20)
|
||||
#define CAM_RES (1 << 21)
|
||||
#define CAM_MEM (1 << 22)
|
||||
|
||||
/* CAM_IRQ_CTRL: For events in irq controller */
|
||||
#define CAM_IRQ_CTRL (1 << 23)
|
||||
|
||||
/* CAM_REQ: Tracks a request submitted to KMD */
|
||||
#define CAM_REQ (1 << 24)
|
||||
|
||||
/* CAM_PERF: Used for performance (clock, BW etc) logs */
|
||||
#define CAM_PERF (1 << 25)
|
||||
#define CAM_CUSTOM (1 << 26)
|
||||
#define CAM_OPE (1 << 28)
|
||||
#define CAM_PRESIL (1 << 27)
|
||||
#define CAM_OPE (1 << 28)
|
||||
#define CAM_IO_ACCESS (1 << 29)
|
||||
|
||||
/* CAM_IO_ACCESS: Tracks IO read/write */
|
||||
#define CAM_IO_ACCESS (1 << 29)
|
||||
/* Log level types */
|
||||
#define CAM_TYPE_TRACE (1 << 0)
|
||||
#define CAM_TYPE_ERR (1 << 1)
|
||||
#define CAM_TYPE_WARN (1 << 2)
|
||||
#define CAM_TYPE_INFO (1 << 3)
|
||||
#define CAM_TYPE_DBG (1 << 4)
|
||||
|
||||
#define STR_BUFFER_MAX_LENGTH 1024
|
||||
#define STR_BUFFER_MAX_LENGTH 512
|
||||
|
||||
/**
|
||||
* struct cam_cpas_debug_settings - Sysfs debug settings for cpas driver
|
||||
@@ -91,6 +91,23 @@ struct camera_debug_settings {
|
||||
void cam_debug_log(unsigned int module_id, const char *func, const int line,
|
||||
const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* cam_debug_trace()
|
||||
*
|
||||
* @brief : Get the Module name from module ID and print
|
||||
* respective debug logs in ftrace
|
||||
*
|
||||
* @tag : Tag indicating whether TRACE, ERR, WARN, INFO, DBG
|
||||
* @module_id : Respective Module ID which is calling this function
|
||||
* @func : Function which is calling to print logs
|
||||
* @line : Line number associated with the function which is calling
|
||||
* to print log
|
||||
* @fmt : Formatted string which needs to be print in the log
|
||||
*
|
||||
*/
|
||||
void cam_debug_trace(unsigned int tag, unsigned int module_id,
|
||||
const char *func, const int line, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* cam_get_module_name()
|
||||
*
|
||||
@@ -100,6 +117,20 @@ void cam_debug_log(unsigned int module_id, const char *func, const int line,
|
||||
*/
|
||||
const char *cam_get_module_name(unsigned int module_id);
|
||||
|
||||
/*
|
||||
* CAM_TRACE
|
||||
* @brief : This Macro will print logs in ftrace
|
||||
*
|
||||
* @__module : Respective module id which is been calling this Macro
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_TRACE(__module, fmt, args...) \
|
||||
({ \
|
||||
cam_debug_trace(CAM_TYPE_TRACE, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_ERR
|
||||
* @brief : This Macro will print error logs
|
||||
@@ -108,9 +139,15 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_ERR(__module, fmt, args...) \
|
||||
pr_info("CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_ERR(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info("CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_ERR, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_WARN
|
||||
* @brief : This Macro will print warning logs
|
||||
@@ -119,9 +156,15 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_WARN(__module, fmt, args...) \
|
||||
pr_info("CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_WARN(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info("CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_ERR, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_INFO
|
||||
* @brief : This Macro will print Information logs
|
||||
@@ -130,9 +173,14 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_INFO(__module, fmt, args...) \
|
||||
pr_info("CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_INFO(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info("CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_INFO, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_INFO_RATE_LIMIT
|
||||
@@ -142,9 +190,14 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_INFO_RATE_LIMIT(__module, fmt, args...) \
|
||||
pr_info_ratelimited("CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_INFO_RATE_LIMIT(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info_ratelimited("CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_INFO, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_DBG
|
||||
@@ -161,9 +214,14 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* CAM_ERR_RATE_LIMIT
|
||||
* @brief : This Macro will print error print logs with ratelimit
|
||||
*/
|
||||
#define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
|
||||
pr_info_ratelimited("CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info_ratelimited("CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_INFO, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
/*
|
||||
* CAM_WARN_RATE_LIMIT
|
||||
* @brief : This Macro will print warning logs with ratelimit
|
||||
@@ -172,9 +230,14 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_WARN_RATE_LIMIT(__module, fmt, args...) \
|
||||
pr_info_ratelimited("CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, __LINE__, ##args)
|
||||
#define CAM_WARN_RATE_LIMIT(__module, fmt, args...) \
|
||||
({ \
|
||||
pr_info_ratelimited("CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_WARN, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
* CAM_WARN_RATE_LIMIT_CUSTOM
|
||||
@@ -186,16 +249,18 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_WARN_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
#define CAM_WARN_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_WARN: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_WARN, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
@@ -208,16 +273,18 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_INFO_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
#define CAM_INFO_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_INFO: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_INFO, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/*
|
||||
@@ -230,16 +297,18 @@ const char *cam_get_module_name(unsigned int module_id);
|
||||
* @fmt : Formatted string which needs to be print in log
|
||||
* @args : Arguments which needs to be print in log
|
||||
*/
|
||||
#define CAM_ERR_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
#define CAM_ERR_RATE_LIMIT_CUSTOM(__module, interval, burst, fmt, args...) \
|
||||
({ \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
(interval * HZ), \
|
||||
burst); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
pr_info( \
|
||||
"CAM_ERR: %s: %s: %d " fmt "\n", \
|
||||
cam_get_module_name(__module), __func__, \
|
||||
__LINE__, ##args); \
|
||||
cam_debug_trace(CAM_TYPE_ERR, __module, __func__, __LINE__, \
|
||||
fmt, ##args); \
|
||||
})
|
||||
|
||||
/**
|
||||
|
@@ -86,6 +86,21 @@ TRACE_EVENT(cam_log_event,
|
||||
)
|
||||
);
|
||||
|
||||
TRACE_EVENT(cam_log_debug,
|
||||
TP_PROTO(const char *string1),
|
||||
TP_ARGS(string1),
|
||||
TP_STRUCT__entry(
|
||||
__string(string1, string1)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__assign_str(string1, string1);
|
||||
),
|
||||
TP_printk(
|
||||
"%s",
|
||||
__get_str(string1)
|
||||
)
|
||||
);
|
||||
|
||||
TRACE_EVENT(cam_icp_fw_dbg,
|
||||
TP_PROTO(char *dbg_message, uint64_t timestamp),
|
||||
TP_ARGS(dbg_message, timestamp),
|
||||
|
Reference in New Issue
Block a user