msm: vidc: print session and codec type in dprintk

[1] Maintain log_ctxt cookie to track debug information.
[2] Print codec type and session type by default in logs.

Change-Id: I6c01f3238ba868fdc525f5c60f58545a07bdef3a
Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
This commit is contained in:
Govindaraj Rajagopal 2019-09-04 01:11:59 +05:30
parent c705bf58ef
commit 2548b43adb
5 changed files with 140 additions and 9 deletions

View File

@ -657,7 +657,8 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
"%s: session not supported\n", __func__);
goto err_invalid_fmt;
}
update_log_ctxt(inst->sid, inst->session_type,
mplane->pixelformat);
memcpy(f, &fmt->v4l2_fmt, sizeof(struct v4l2_format));
}

View File

@ -1323,7 +1323,8 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
"%s: session not supported\n", __func__);
goto exit;
}
update_log_ctxt(inst->sid, inst->session_type,
mplane->pixelformat);
memcpy(f, &fmt->v4l2_fmt, sizeof(struct v4l2_format));
} else if (f->type == INPUT_MPLANE) {
fmt = &inst->fmts[INPUT_PORT];

View File

@ -1528,10 +1528,17 @@ void *msm_vidc_open(int core_id, int session_type)
rc = -ENOMEM;
goto err_invalid_core;
}
inst->sid = hash32_ptr(inst);
mutex_lock(&core->lock);
rc = get_sid(&inst->sid, session_type);
mutex_unlock(&core->lock);
if (rc) {
d_vpr_e("Total instances count reached to max value\n");
goto err_invalid_sid;
}
pr_info(VIDC_DBG_TAG "Opening video instance: %pK, %d\n",
"high", inst->sid, inst, session_type);
"high", inst->sid, get_codec_name(inst->sid),
inst, session_type);
mutex_init(&inst->sync_lock);
mutex_init(&inst->bufq[OUTPUT_PORT].lock);
mutex_init(&inst->bufq[INPUT_PORT].lock);
@ -1668,6 +1675,8 @@ fail_bufq_capture:
DEINIT_MSM_VIDC_LIST(&inst->fbd_data);
DEINIT_MSM_VIDC_LIST(&inst->window_data);
err_invalid_sid:
put_sid(inst->sid);
kfree(inst);
inst = NULL;
err_invalid_core:
@ -1803,7 +1812,9 @@ int msm_vidc_destroy(struct msm_vidc_inst *inst)
msm_vidc_debugfs_deinit_inst(inst);
pr_info(VIDC_DBG_TAG "Closed video instance: %pK\n",
"high", inst->sid, inst);
"high", inst->sid, get_codec_name(inst->sid),
inst);
put_sid(inst->sid);
kfree(inst);
return 0;
}

View File

@ -30,6 +30,8 @@ bool msm_vidc_cvp_usage = true;
atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\
})
static struct log_cookie ctxt[MAX_SUPPORTED_INSTANCES];
struct core_inst_pair {
struct msm_vidc_core *core;
struct msm_vidc_inst *inst;
@ -596,3 +598,106 @@ int msm_vidc_check_ratelimit(void)
return __ratelimit(&_rs);
}
/**
* get_sid() must be called under "&core->lock"
* to avoid race condition in occurring empty slot.
*/
int get_sid(u32 *sid, u32 session_type)
{
int i;
for (i = 0; i < MAX_SUPPORTED_INSTANCES; i++) {
if (!ctxt[i].used) {
ctxt[i].used = 1;
*sid = i+1;
update_log_ctxt(*sid, session_type, 0);
break;
}
}
return (i == MAX_SUPPORTED_INSTANCES);
}
void put_sid(u32 sid)
{
if (!sid || sid > MAX_SUPPORTED_INSTANCES) {
d_vpr_e("%s: invalid sid %#x\n",
__func__, sid);
return;
}
if (ctxt[sid-1].used)
ctxt[sid-1].used = 0;
}
inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc)
{
const char *codec;
char type;
if (!sid || sid > MAX_SUPPORTED_INSTANCES) {
d_vpr_e("%s: invalid sid %#x\n",
__func__, sid);
}
switch (fourcc) {
case V4L2_PIX_FMT_H264:
case V4L2_PIX_FMT_H264_NO_SC:
codec = "h264";
break;
case V4L2_PIX_FMT_H264_MVC:
codec = " mvc";
break;
case V4L2_PIX_FMT_MPEG1:
codec = "mpg1";
break;
case V4L2_PIX_FMT_MPEG2:
codec = "mpg2";
break;
case V4L2_PIX_FMT_VP8:
codec = " vp8";
break;
case V4L2_PIX_FMT_VP9:
codec = " vp9";
break;
case V4L2_PIX_FMT_HEVC:
codec = "h265";
break;
case V4L2_PIX_FMT_TME:
codec = " tme";
break;
case V4L2_PIX_FMT_CVP:
codec = " cvp";
break;
default:
codec = "....";
break;
}
switch (session_type) {
case MSM_VIDC_ENCODER:
type = 'e';
break;
case MSM_VIDC_DECODER:
type = 'd';
break;
case MSM_VIDC_CVP:
type = 'c';
default:
type = '.';
break;
}
ctxt[sid-1].session_type = session_type;
ctxt[sid-1].codec_type = fourcc;
memcpy(&ctxt[sid-1].name, codec, 4);
ctxt[sid-1].name[4] = type;
ctxt[sid-1].name[5] = '\0';
}
char *get_codec_name(u32 sid)
{
if (!sid || sid > MAX_SUPPORTED_INSTANCES)
return ".....";
return ctxt[sid-1].name;
}

View File

@ -23,7 +23,8 @@
#define VIDC_DBG_SESSION_RATELIMIT_INTERVAL (1 * HZ)
#define VIDC_DBG_SESSION_RATELIMIT_BURST 6
#define VIDC_DBG_TAG VIDC_DBG_LABEL ": %6s: %8x: "
#define VIDC_DBG_TAG VIDC_DBG_LABEL ": %6s: %08x: %5s: "
#define FW_DBG_TAG VIDC_DBG_LABEL ": %6s: "
#define DEFAULT_SID ((u32)-1)
/* To enable messages OR these values and
@ -69,6 +70,13 @@ extern bool msm_vidc_syscache_disable;
extern bool msm_vidc_lossless_encode;
extern bool msm_vidc_cvp_usage;
struct log_cookie {
u32 used;
u32 session_type;
u32 codec_type;
char name[20];
};
#define dprintk(__level, sid, __fmt, ...) \
do { \
if (msm_vidc_debug & __level) { \
@ -79,6 +87,7 @@ extern bool msm_vidc_cvp_usage;
VIDC_DBG_TAG __fmt, \
get_debug_level_str(__level), \
sid, \
get_codec_name(sid), \
##__VA_ARGS__); \
trace_msm_vidc_printf(trace_logbuf, \
log_length); \
@ -87,6 +96,7 @@ extern bool msm_vidc_cvp_usage;
pr_info(VIDC_DBG_TAG __fmt, \
get_debug_level_str(__level), \
sid, \
get_codec_name(sid), \
##__VA_ARGS__); \
} \
} \
@ -120,14 +130,14 @@ extern bool msm_vidc_cvp_usage;
char trace_logbuf[MAX_TRACER_LOG_LENGTH]; \
int log_length = snprintf(trace_logbuf, \
MAX_TRACER_LOG_LENGTH, \
VIDC_DBG_TAG __fmt, \
FW_DBG_TAG __fmt, \
"fw", \
##__VA_ARGS__); \
trace_msm_vidc_printf(trace_logbuf, \
log_length); \
} \
if (__level & FW_PRINTK) { \
pr_info(VIDC_DBG_TAG __fmt, \
pr_info(FW_DBG_TAG __fmt, \
"fw", \
##__VA_ARGS__); \
} \
@ -146,7 +156,6 @@ extern bool msm_vidc_cvp_usage;
BUG_ON(value); \
} while (0)
struct dentry *msm_vidc_debugfs_init_drv(void);
struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core,
struct dentry *parent);
@ -156,6 +165,10 @@ void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst);
void msm_vidc_debugfs_update(struct msm_vidc_inst *inst,
enum msm_vidc_debugfs_event e);
int msm_vidc_check_ratelimit(void);
int get_sid(u32 *sid, u32 session_type);
void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc);
char *get_codec_name(u32 sid);
void put_sid(u32 sid);
static inline char *get_debug_level_str(int level)
{