video: driver: use char array for printing vidc logs

Instead of formulating session_id, codec_type, domain at
each log print, used pre-formatted char array to print
the vidc logs.

Change-Id: If7a93ecb25a7b1b98ebca6f39e3990079c00b5dd
Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
This commit is contained in:
Govindaraj Rajagopal
2021-02-26 20:59:25 +05:30
parent df69c42511
commit e743f5dd48
17 changed files with 203 additions and 207 deletions

View File

@@ -30,7 +30,7 @@ static u32 msm_vidc_decoder_bin_size_iris2(struct msm_vidc_inst *inst)
core = inst->core;
if (!core->capabilities) {
d_vpr_e("%s: invalid capabilities\n", __func__);
i_vpr_e(inst, "%s: invalid capabilities\n", __func__);
return size;
}
num_vpp_pipes = core->capabilities[NUM_VPP_PIPE].value;
@@ -133,7 +133,7 @@ static u32 msm_vidc_decoder_line_size_iris2(struct msm_vidc_inst *inst)
}
core = inst->core;
if (!core->capabilities) {
d_vpr_e("%s: invalid capabilities\n", __func__);
i_vpr_e(inst, "%s: invalid capabilities\n", __func__);
return size;
}
num_vpp_pipes = core->capabilities[NUM_VPP_PIPE].value;

View File

@@ -558,7 +558,7 @@ int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst* inst)
}
}
else {
d_vpr_e("%s: invalid session type\n", __func__);
i_vpr_e(inst, "%s: invalid session type\n", __func__);
return -EINVAL;
}
@@ -604,7 +604,7 @@ int msm_vidc_decide_work_route_iris2(struct msm_vidc_inst* inst)
work_route = MSM_VIDC_PIPE_1;
} else {
d_vpr_e("%s: invalid session type\n", __func__);
i_vpr_e(inst, "%s: invalid session type\n", __func__);
return -EINVAL;
}

View File

@@ -18,7 +18,8 @@
#define VIDC_DBG_SESSION_RATELIMIT_INTERVAL (1 * HZ)
#define VIDC_DBG_SESSION_RATELIMIT_BURST 6
#define VIDC_DBG_TAG VIDC_DBG_LABEL ": %6s: %08x: %5s: "
#define VIDC_DBG_TAG_INST VIDC_DBG_LABEL ": %4s: %s: "
#define VIDC_DBG_TAG_CORE VIDC_DBG_LABEL ": %4s: %08x: %s: "
#define FW_DBG_TAG VIDC_DBG_LABEL ": %6s: "
#define DEFAULT_SID ((u32)-1)
@@ -56,64 +57,55 @@ enum vidc_msg_prio {
#define FW_LOGSHIFT 16
#define FW_LOGMASK 0x0FFF0000
#define dprintk_inst(__level, inst, __fmt, ...) \
#define dprintk_inst(__level, __level_str, inst, __fmt, ...) \
do { \
if (inst && (msm_vidc_debug & __level)) { \
pr_err(VIDC_DBG_TAG __fmt, \
level_str(__level), \
get_sid(inst), \
codec_str(inst), \
pr_info(VIDC_DBG_TAG_INST __fmt, \
__level_str, \
inst->debug_str, \
##__VA_ARGS__); \
} \
} while (0)
#define i_vpr_e(inst, __fmt, ...) dprintk_inst(VIDC_ERR, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_i(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_h(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_l(inst, __fmt, ...) dprintk_inst(VIDC_LOW, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_p(inst, __fmt, ...) dprintk_inst(VIDC_PERF, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_t(inst, __fmt, ...) dprintk_inst(VIDC_PKT, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_b(inst, __fmt, ...) dprintk_inst(VIDC_BUS, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_hp(inst, __fmt, ...) \
dprintk_inst(VIDC_HIGH | VIDC_PERF, inst, __fmt, ##__VA_ARGS__)
#define i_vpr_e(inst, __fmt, ...) dprintk_inst(VIDC_ERR, "err ", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_i(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_h(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_l(inst, __fmt, ...) dprintk_inst(VIDC_LOW, "low ", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_p(inst, __fmt, ...) dprintk_inst(VIDC_PERF, "perf", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_t(inst, __fmt, ...) dprintk_inst(VIDC_PKT, "pkt ", inst, __fmt, ##__VA_ARGS__)
#define i_vpr_b(inst, __fmt, ...) dprintk_inst(VIDC_BUS, "bus ", inst, __fmt, ##__VA_ARGS__)
#define dprintk(__level, sid, __fmt, ...) \
#define dprintk_core(__level, __level_str, __fmt, ...) \
do { \
if (msm_vidc_debug & __level) { \
pr_err(VIDC_DBG_TAG __fmt, \
level_str(__level), \
sid, \
pr_info(VIDC_DBG_TAG_CORE __fmt, \
__level_str, \
DEFAULT_SID, \
"codec", \
##__VA_ARGS__); \
} \
} while (0)
#define d_vpr_e(__fmt, ...) \
dprintk(VIDC_ERR, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_i(__fmt, ...) \
dprintk(VIDC_HIGH, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_h(__fmt, ...) \
dprintk(VIDC_HIGH, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_l(__fmt, ...) \
dprintk(VIDC_LOW, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_p(__fmt, ...) \
dprintk(VIDC_PERF, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_t(__fmt, ...) \
dprintk(VIDC_PKT, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_b(__fmt, ...) \
dprintk(VIDC_BUS, DEFAULT_SID, __fmt, ##__VA_ARGS__)
#define d_vpr_e(__fmt, ...) dprintk_core(VIDC_ERR, "err ", __fmt, ##__VA_ARGS__)
#define d_vpr_h(__fmt, ...) dprintk_core(VIDC_HIGH, "high", __fmt, ##__VA_ARGS__)
#define d_vpr_l(__fmt, ...) dprintk_core(VIDC_LOW, "low ", __fmt, ##__VA_ARGS__)
#define d_vpr_p(__fmt, ...) dprintk_core(VIDC_PERF, "perf", __fmt, ##__VA_ARGS__)
#define d_vpr_t(__fmt, ...) dprintk_core(VIDC_PKT, "pkt ", __fmt, ##__VA_ARGS__)
#define d_vpr_b(__fmt, ...) dprintk_core(VIDC_BUS, "bus ", __fmt, ##__VA_ARGS__)
#define dprintk_ratelimit(__level, __level_str, __fmt, ...) \
do { \
if (msm_vidc_check_ratelimit()) { \
dprintk_core(__level, __level_str, __fmt, ##__VA_ARGS__); \
} \
} while (0)
#define dprintk_firmware(__level, __fmt, ...) \
do { \
pr_err(FW_DBG_TAG __fmt, \
if (__level & FW_PRINTK) { \
pr_info(FW_DBG_TAG __fmt, \
"fw", \
##__VA_ARGS__); \
} while (0)
#define dprintk_ratelimit(__level, __fmt, ...) \
do { \
if (msm_vidc_check_ratelimit()) { \
dprintk(__level, DEFAULT_SID, __fmt, ##__VA_ARGS__); \
} \
} while (0)
@@ -122,10 +114,6 @@ enum vidc_msg_prio {
d_vpr_e("BugOn"); \
} while (0)
const char *level_str(u32 level);
const char *codec_str(void *instance);
u32 get_sid(void *instance);
enum msm_vidc_debugfs_event {
MSM_VIDC_DEBUGFS_EVENT_ETB,
MSM_VIDC_DEBUGFS_EVENT_EBD,

View File

@@ -183,7 +183,7 @@ static inline bool is_session_error(struct msm_vidc_inst* inst)
return inst->state == MSM_VIDC_ERROR;
}
void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_buffer *vbuf);
void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,
struct vb2_buffer *vb2);
@@ -307,5 +307,6 @@ int msm_vidc_init_core_caps(struct msm_vidc_core* core);
int msm_vidc_init_instance_caps(struct msm_vidc_core* core);
int msm_vidc_deinit_core_caps(struct msm_vidc_core* core);
int msm_vidc_deinit_instance_caps(struct msm_vidc_core* core);
int msm_vidc_update_debug_str(struct msm_vidc_inst *inst);
#endif // _MSM_VIDC_DRIVER_H_

View File

@@ -92,7 +92,7 @@ struct msm_vidc_inst {
void *core;
struct kref kref;
u32 session_id;
u32 sid;
u8 debug_str[24];
void *packet;
u32 packet_size;
struct v4l2_format fmts[MAX_PORT];

View File

@@ -167,7 +167,7 @@ u32 get_hfi_codec(struct msm_vidc_inst *inst)
case MSM_VIDC_VP9:
return HFI_CODEC_DECODE_VP9;
default:
d_vpr_e("invalid codec %d, domain %d\n",
i_vpr_e(inst, "invalid codec %d, domain %d\n",
inst->codec, inst->domain);
return 0;
}
@@ -614,11 +614,11 @@ int hfi_packet_session_command(struct msm_vidc_inst *inst,
if (rc)
goto err_cmd;
d_vpr_h("Command packet 0x%x created\n", pkt_type);
i_vpr_h(inst, "Command packet 0x%x created\n", pkt_type);
return rc;
err_cmd:
d_vpr_e("%s: create packet failed\n", __func__);
i_vpr_e(inst, "%s: create packet failed\n", __func__);
return rc;
}

View File

@@ -66,6 +66,10 @@ static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
__func__, inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat, v4l2_codec);
inst->codec = v4l2_codec_to_driver(v4l2_codec, __func__);
rc = msm_vidc_update_debug_str(inst);
if (rc)
goto exit;
rc = msm_vidc_get_inst_capability(inst);
if (rc)
goto exit;
@@ -1003,7 +1007,7 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
return -EINVAL;
}
core = inst->core;
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
payload[0] = HFI_MODE_PORT_SETTINGS_CHANGE;
if (inst->codec == MSM_VIDC_H264) {
@@ -1016,13 +1020,13 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_vp9);
psc = msm_vdec_subscribe_for_psc_vp9;
} else {
d_vpr_e("%s: unsupported codec: %d\n", __func__, inst->codec);
i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
psc = NULL;
return -EINVAL;
}
if (!psc || !subscribe_psc_size) {
d_vpr_e("%s: invalid params\n", __func__);
i_vpr_e(inst, "%s: invalid params\n", __func__);
return -EINVAL;
}
@@ -1070,7 +1074,7 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
rc = msm_vdec_set_tier(inst, port);
break;
default:
d_vpr_e("%s: unknown property %#x\n", __func__,
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
psc[i]);
rc = -EINVAL;
break;
@@ -1097,7 +1101,7 @@ static int msm_vdec_subscribe_property(struct msm_vidc_inst *inst,
return -EINVAL;
}
core = inst->core;
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
payload[0] = HFI_MODE_PROPERTY;
for (i = 0; i < ARRAY_SIZE(msm_vdec_subscribe_for_properties); i++)
@@ -1141,7 +1145,7 @@ static int msm_vdec_subscribe_metadata(struct msm_vidc_inst *inst,
return -EINVAL;
}
core = inst->core;
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
capability = inst->capabilities;
payload[0] = HFI_MODE_METADATA;
@@ -1183,7 +1187,7 @@ static int msm_vdec_set_delivery_mode_metadata(struct msm_vidc_inst *inst,
return -EINVAL;
}
core = inst->core;
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
capability = inst->capabilities;
payload[0] = HFI_MODE_METADATA;
@@ -1217,7 +1221,7 @@ static int msm_vdec_session_resume(struct msm_vidc_inst *inst,
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
rc = venus_hfi_session_command(inst,
HFI_CMD_RESUME,
@@ -1491,7 +1495,11 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
u32 subscribe_psc_size = 0;
u32 *psc = NULL;
d_vpr_h("%s()\n", __func__);
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n", __func__);
payload[0] = HFI_MODE_PORT_SETTINGS_CHANGE;
if (inst->codec == MSM_VIDC_H264) {
@@ -1504,13 +1512,13 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_vp9);
psc = msm_vdec_subscribe_for_psc_vp9;
} else {
d_vpr_e("%s: unsupported codec: %d\n", __func__, inst->codec);
i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
psc = NULL;
return -EINVAL;
}
if (!psc || !subscribe_psc_size) {
d_vpr_e("%s: invalid params\n", __func__);
i_vpr_e(inst, "%s: invalid params\n", __func__);
return -EINVAL;
}
@@ -1586,7 +1594,7 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
payload_type = HFI_PAYLOAD_U32;
break;
default:
d_vpr_e("%s: unknown property %#x\n", __func__,
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
prop_type);
prop_type = 0;
rc = -EINVAL;
@@ -1680,7 +1688,7 @@ static int msm_vdec_qbuf_batch(struct msm_vidc_inst *inst,
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
d_vpr_h("%s()\n", __func__);
i_vpr_h(inst, "%s()\n", __func__);
return rc;
}
@@ -1745,7 +1753,7 @@ int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
if (rc)
return rc;
} else {
d_vpr_e("%s: unknown cmd %d\n", __func__, cmd);
i_vpr_e(inst, "%s: unknown cmd %d\n", __func__, cmd);
return -EINVAL;
}

View File

@@ -52,6 +52,10 @@ static int msm_venc_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
__func__, inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, v4l2_codec);
inst->codec = v4l2_codec_to_driver(v4l2_codec, __func__);
rc = msm_vidc_update_debug_str(inst);
if (rc)
goto exit;
rc = msm_vidc_get_inst_capability(inst);
if (rc)
goto exit;
@@ -476,7 +480,7 @@ static int msm_venc_set_input_properties(struct msm_vidc_inst *inst)
rc = msm_venc_set_colorspace(inst, INPUT_PORT);
break;
default:
d_vpr_e("%s: unknown property %#x\n", __func__,
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_input_set_prop[i]);
rc = -EINVAL;
break;
@@ -517,7 +521,7 @@ static int msm_venc_set_output_properties(struct msm_vidc_inst *inst)
rc = msm_venc_set_csc(inst, OUTPUT_PORT);
break;
default:
d_vpr_e("%s: unknown property %#x\n", __func__,
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_output_set_prop[i]);
rc = -EINVAL;
break;
@@ -997,7 +1001,7 @@ int msm_venc_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
if (rc)
return rc;
} else {
d_vpr_e("%s: unknown cmd %d\n", __func__, cmd);
i_vpr_e(inst, "%s: unknown cmd %d\n", __func__, cmd);
return -EINVAL;
}
return 0;
@@ -1712,13 +1716,13 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
struct msm_vidc_core *core;
struct v4l2_format *f;
d_vpr_h("%s()\n", __func__);
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
core = inst->core;
i_vpr_h(inst, "%s()\n", __func__);
core = inst->core;
f = &inst->fmts[OUTPUT_PORT];
f->type = OUTPUT_MPLANE;
f->fmt.pix_mp.width = DEFAULT_WIDTH;

View File

@@ -3,6 +3,8 @@
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
*/
#include <linux/types.h>
#include <linux/hash.h>
#include "msm_vidc.h"
#include "msm_vidc_core.h"
#include "msm_vidc_inst.h"
@@ -710,14 +712,22 @@ void *msm_vidc_open(void *vidc_core, u32 session_type)
return NULL;
}
inst->core = core;
inst->domain = session_type;
inst->session_id = hash32_ptr(inst);
inst->state = MSM_VIDC_OPEN;
inst->active = true;
inst->request = false;
inst->ipsc_properties_set = false;
inst->opsc_properties_set = false;
kref_init(&inst->kref);
mutex_init(&inst->lock);
msm_vidc_update_debug_str(inst);
i_vpr_h(inst, "Opening video instance: %d\n", session_type);
inst->response_workq = create_singlethread_workqueue("response_workq");
if (!inst->response_workq) {
d_vpr_e("%s: create input_psc_workq failed\n", __func__);
i_vpr_e(inst, "%s: create input_psc_workq failed\n", __func__);
goto error;
}
@@ -767,12 +777,6 @@ void *msm_vidc_open(void *vidc_core, u32 session_type)
INIT_LIST_HEAD(&inst->mappings.vpss.list);
INIT_LIST_HEAD(&inst->children.list);
INIT_LIST_HEAD(&inst->firmware.list);
inst->domain = session_type;
inst->state = MSM_VIDC_OPEN;
inst->active = true;
inst->request = false;
inst->ipsc_properties_set = false;
inst->opsc_properties_set = false;
for (i = 0; i < MAX_SIGNAL; i++)
init_completion(&inst->completions[i]);
@@ -793,7 +797,7 @@ void *msm_vidc_open(void *vidc_core, u32 session_type)
rc = msm_vidc_add_session(inst);
if (rc) {
d_vpr_e("%s: failed to get session id\n", __func__);
i_vpr_e(inst, "%s: failed to get session id\n", __func__);
goto error;
}
msm_vidc_scale_power(inst, true);

View File

@@ -186,7 +186,7 @@ u32 msm_vidc_internal_buffer_count(struct msm_vidc_inst *inst,
else
count = 0;
} else {
d_vpr_e("%s: unsupported buffer type %#x\n",
i_vpr_e(inst, "%s: unsupported buffer type %#x\n",
__func__, buffer_type);
count = 0;
}

View File

@@ -1143,13 +1143,13 @@ int msm_vidc_adjust_v4l2_properties(struct msm_vidc_inst *inst)
struct msm_vidc_inst_cap_entry *curr_node = NULL, *tmp_node = NULL;
struct msm_vidc_inst_capability *capability;
d_vpr_h("%s()\n", __func__);
if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
capability = inst->capabilities;
i_vpr_h(inst, "%s()\n", __func__);
for (i = 0; i < INST_CAP_MAX; i++) {
if (capability->cap[i].flags & CAP_FLAG_ROOT) {
rc = msm_vidc_adjust_property(inst,
@@ -1719,11 +1719,11 @@ int msm_vidc_set_v4l2_properties(struct msm_vidc_inst *inst)
struct msm_vidc_inst_capability *capability;
struct msm_vidc_inst_cap_entry *curr_node = NULL, *tmp_node = NULL;
d_vpr_h("%s()\n", __func__);
if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n", __func__);
capability = inst->capabilities;
list_for_each_entry_safe(curr_node, tmp_node,

View File

@@ -25,61 +25,6 @@ EXPORT_SYMBOL(msm_vidc_syscache_disable);
int msm_vidc_clock_voting = !1;
const char *level_str(u32 level)
{
if (level & VIDC_ERR)
return "err ";
else if (level & VIDC_HIGH)
return "high";
else if (level & VIDC_LOW)
return "low ";
else if (level & VIDC_PERF)
return "perf";
else if (level & VIDC_PKT)
return "pkt ";
else if (level & VIDC_BUS)
return "bus ";
else
return "????";
}
const char *codec_str(void *instance)
{
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
goto err_invalid_inst;
}
if (inst->codec == MSM_VIDC_H264)
return "h264 ";
else if (inst->codec == MSM_VIDC_HEVC)
return "hevc ";
else if (inst->codec == MSM_VIDC_VP9)
return "vp9 ";
else
return "?????";
err_invalid_inst:
return "null ";
}
u32 get_sid(void *instance)
{
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
goto err_invalid_inst;
}
return inst->sid;
err_invalid_inst:
return 0;
}
#define MAX_DBG_BUF_SIZE 4096
struct core_inst_pair {
@@ -442,7 +387,7 @@ struct dentry *msm_vidc_debugfs_init_inst(void *instance, struct dentry *parent)
d_vpr_e("%s: invalid params\n", __func__);
goto exit;
}
snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%d", inst->sid);
snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%d", inst->session_id);
idata = kzalloc(sizeof(struct core_inst_pair), GFP_KERNEL);
if (!idata) {

View File

@@ -5,7 +5,6 @@
#include <linux/iommu.h>
#include <linux/workqueue.h>
#include <linux/hash.h>
#include <media/v4l2_vidc_extensions.h>
#include "msm_media_info.h"
@@ -34,14 +33,14 @@ struct msm_vidc_buf_details {
char *name;
};
void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_buffer *vbuf)
{
if (!(tag & msm_vidc_debug) || !inst || !vbuf)
if (!(tag & msm_vidc_debug) || !inst || !vbuf || !tag_str || !str)
return;
if (vbuf->type == MSM_VIDC_BUF_INPUT || vbuf->type == MSM_VIDC_BUF_OUTPUT) {
dprintk(tag, inst->sid,
dprintk_inst(tag, tag_str, inst,
"%s: %s: idx %2d fd %3d off %d daddr %#llx size %d filled %d flags %#x ts %lld attr %#x\n",
str, vbuf->type == MSM_VIDC_BUF_INPUT ? "INPUT" : "OUTPUT",
vbuf->index, vbuf->fd, vbuf->data_offset,
@@ -49,7 +48,7 @@ void print_vidc_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
vbuf->flags, vbuf->timestamp, vbuf->attr);
} else if (vbuf->type == MSM_VIDC_BUF_INPUT_META ||
vbuf->type == MSM_VIDC_BUF_OUTPUT_META) {
dprintk(tag, inst->sid,
dprintk_inst(tag, tag_str, inst,
"%s: %s: idx %2d fd %3d off %d daddr %#llx size %d filled %d flags %#x ts %lld attr %#x\n",
str, vbuf->type == MSM_VIDC_BUF_INPUT_META ? "INPUT_META" : "OUTPUT_META",
vbuf->index, vbuf->fd, vbuf->data_offset,
@@ -1205,13 +1204,13 @@ int msm_vidc_unmap_driver_buf(struct msm_vidc_inst *inst,
}
}
if (!found) {
print_vidc_buffer(VIDC_ERR, "no buf in mappings", inst, buf);
print_vidc_buffer(VIDC_ERR, "err ", "no buf in mappings", inst, buf);
return -EINVAL;
}
rc = msm_vidc_memory_unmap(inst->core, map);
if (rc) {
print_vidc_buffer(VIDC_ERR, "unmap failed", inst, buf);
print_vidc_buffer(VIDC_ERR, "err ", "unmap failed", inst, buf);
return -EINVAL;
}
@@ -1340,14 +1339,14 @@ struct msm_vidc_buffer *msm_vidc_get_driver_buf(struct msm_vidc_inst *inst,
/* only YUV buffers are allowed to repeat */
if ((is_decode_session(inst) && vb2->type != OUTPUT_MPLANE) ||
(is_encode_session(inst) && vb2->type != INPUT_MPLANE)) {
print_vidc_buffer(VIDC_ERR,
print_vidc_buffer(VIDC_ERR, "err ",
"existing buffer", inst, buf);
goto error;
}
/* for decoder, YUV with RO flag are allowed to repeat */
if (is_decode_session(inst) &&
!(buf->attr & MSM_VIDC_ATTR_READ_ONLY)) {
print_vidc_buffer(VIDC_ERR,
print_vidc_buffer(VIDC_ERR, "err ",
"existing buffer without RO flag", inst, buf);
goto error;
}
@@ -1455,7 +1454,8 @@ int msm_vidc_queue_buffer(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
if (buf->type == MSM_VIDC_BUF_INPUT_META ||
buf->type == MSM_VIDC_BUF_OUTPUT_META) {
buf->attr |= MSM_VIDC_ATTR_DEFERRED;
print_vidc_buffer(VIDC_HIGH, "qbuf deferred", inst, buf);
i_vpr_h(inst, "%s: %s_META qbuf deferred\n", __func__,
buf->type == MSM_VIDC_BUF_INPUT_META ? "INPUT" : "OUTPUT");
return 0;
}
@@ -1465,7 +1465,7 @@ int msm_vidc_queue_buffer(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
return -EINVAL;
if (!inst->vb2q[port].streaming) {
buf->attr |= MSM_VIDC_ATTR_DEFERRED;
print_vidc_buffer(VIDC_HIGH, "qbuf deferred", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "qbuf deferred", inst, buf);
return 0;
}
@@ -1480,15 +1480,16 @@ int msm_vidc_queue_buffer(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
msm_vidc_scale_power(inst, true);
}
print_vidc_buffer(VIDC_HIGH, "qbuf", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "qbuf", inst, buf);
meta = get_meta_buffer(inst, buf);
if (!meta) {
if (is_meta_enabled(inst, buf->type)) {
print_vidc_buffer(VIDC_ERR, "missing meta for",
inst, buf);
if (meta)
print_vidc_buffer(VIDC_HIGH, "high", "qbuf", inst, meta);
if (!meta && is_meta_enabled(inst, buf->type)) {
print_vidc_buffer(VIDC_ERR, "err ", "missing meta for", inst, buf);
return -EINVAL;
}
}
if (msm_vidc_is_super_buffer(inst) && is_input_buffer(buf->type))
rc = venus_hfi_queue_super_buffer(inst, buf, meta);
else
@@ -1898,7 +1899,7 @@ int msm_vidc_vb2_buffer_done(struct msm_vidc_inst *inst,
}
}
if (!found) {
print_vidc_buffer(VIDC_ERR, "vb2 not found for", inst, buf);
print_vidc_buffer(VIDC_ERR, "err ", "vb2 not found for", inst, buf);
return -EINVAL;
}
vbuf = to_vb2_v4l2_buffer(vb2);
@@ -2061,16 +2062,12 @@ int msm_vidc_add_session(struct msm_vidc_inst *inst)
if (count < 0xffffff /*TODO: MAX_SUPPORTED_INSTANCES*/) {
list_add_tail(&inst->list, &core->instances);
} else {
d_vpr_e("%s: total sessions %d exceeded max limit %d\n",
i_vpr_e(inst, "%s: total sessions %d exceeded max limit %d\n",
__func__, count, MAX_SUPPORTED_INSTANCES);
rc = -EINVAL;
}
core_unlock(core, __func__);
/* assign session_id */
inst->session_id = hash32_ptr(inst);
inst->sid = inst->session_id;
return rc;
}
@@ -2090,14 +2087,13 @@ int msm_vidc_remove_session(struct msm_vidc_inst *inst)
list_for_each_entry_safe(i, temp, &core->instances, list) {
if (i->session_id == inst->session_id) {
list_del_init(&i->list);
d_vpr_h("%s: removed session %#x\n",
i_vpr_h(inst, "%s: removed session %#x\n",
__func__, i->session_id);
inst->sid = 0;
}
}
list_for_each_entry(i, &core->instances, list)
count++;
d_vpr_h("%s: remaining sessions %d\n", __func__, count);
i_vpr_h(inst, "%s: remaining sessions %d\n", __func__, count);
core_unlock(core, __func__);
return 0;
@@ -2325,7 +2321,6 @@ int msm_vidc_get_inst_capability(struct msm_vidc_inst *inst)
int i;
struct msm_vidc_core *core;
d_vpr_h("%s()\n", __func__);
if (!inst || !inst->core || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
@@ -2556,7 +2551,7 @@ int msm_vidc_core_deinit(struct msm_vidc_core *core, bool force)
}
core_lock(core, __func__);
d_vpr_h("%s()\n", __func__);
d_vpr_h("%s(): force %u\n", __func__, force);
if (core->state == MSM_VIDC_CORE_DEINIT)
goto unlock;
@@ -2743,7 +2738,7 @@ int msm_vidc_smmu_fault_handler(struct iommu_domain *domain,
if (core->smmu_fault_handled) {
if (core->capabilities[NON_FATAL_FAULTS].value) {
dprintk_ratelimit(VIDC_ERR,
dprintk_ratelimit(VIDC_ERR, "err ",
"%s: non-fatal pagefault address: %lx\n",
__func__, iova);
return 0;
@@ -2837,7 +2832,7 @@ int msm_vidc_flush_buffers(struct msm_vidc_inst* inst,
list_for_each_entry_safe(buf, dummy, &buffers->list, list) {
if (buf->attr & MSM_VIDC_ATTR_QUEUED ||
buf->attr & MSM_VIDC_ATTR_DEFERRED) {
print_vidc_buffer(VIDC_ERR, "flushing buffer", inst, buf);
print_vidc_buffer(VIDC_ERR, "err ", "flushing buffer", inst, buf);
msm_vidc_vb2_buffer_done(inst, buf);
msm_vidc_put_driver_buf(inst, buf);
}
@@ -3063,3 +3058,43 @@ void msm_vidc_schedule_core_deinit(struct msm_vidc_core *core)
return;
}
static const char *get_codec_str(enum msm_vidc_codec_type type)
{
switch (type) {
case MSM_VIDC_H264: return "h264";
case MSM_VIDC_HEVC: return "h265";
case MSM_VIDC_VP9: return " vp9";
}
return "....";
}
static const char *get_domain_str(enum msm_vidc_domain_type type)
{
switch (type) {
case MSM_VIDC_ENCODER: return "e";
case MSM_VIDC_DECODER: return "d";
}
return ".";
}
int msm_vidc_update_debug_str(struct msm_vidc_inst *inst)
{
u32 sid;
const char *codec;
const char *domain;
if (!inst) {
d_vpr_e("%s: Invalid params\n", __func__);
return -EINVAL;
}
sid = inst->session_id;
codec = get_codec_str(inst->codec);
domain = get_domain_str(inst->domain);
snprintf(inst->debug_str, sizeof(inst->debug_str), "%08x: %s%s", sid, codec, domain);
d_vpr_h("%s: sid: %08x, codec: %s, domain: %s, final: %s\n",
__func__, sid, codec, domain, inst->debug_str);
return 0;
}

View File

@@ -221,7 +221,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
}
core = inst->core;
if (!core->dt) {
d_vpr_e("%s: invalid dt params\n", __func__);
i_vpr_e(inst, "%s: invalid dt params\n", __func__);
return -EINVAL;
}
vote_data = &inst->bus_data;
@@ -401,7 +401,7 @@ int msm_vidc_set_clocks(struct msm_vidc_inst* inst)
}
core->power.clk_freq = (u32)rate;
d_vpr_p("%s: clock rate %lu requested %lu increment %d decrement %d\n",
i_vpr_p(inst, "%s: clock rate %lu requested %lu increment %d decrement %d\n",
__func__, rate, freq, increment, decrement);
mutex_unlock(&core->lock);

View File

@@ -87,7 +87,7 @@ int msm_vidc_queue_setup(struct vb2_queue *q,
}
if (inst->state == MSM_VIDC_START) {
d_vpr_e("%s: invalid state %d\n", __func__, inst->state);
i_vpr_e(inst, "%s: invalid state %d\n", __func__, inst->state);
return -EINVAL;
}

View File

@@ -138,21 +138,39 @@ void __dump(struct dump dump[], int len)
}
}
static void __dump_packet(u8 *packet)
static void __dump_packet(u8 *packet, const char *function, void *qinfo)
{
u32 c = 0, packet_size = *(u32 *)packet;
u32 c = 0, session_id, packet_size = *(u32 *)packet;
const int row_size = 32;
struct msm_vidc_inst *inst = NULL;
bool matches = false;
/*
* row must contain enough for 0xdeadbaad * 8 to be converted into
* "de ad ba ab " * 8 + '\0'
*/
char row[3 * 32];
session_id = *((u32 *)packet + 1);
list_for_each_entry(inst, &g_core->instances, list) {
if (inst->session_id == session_id) {
matches = true;
break;
}
}
if (matches)
i_vpr_t(inst, "%s: %pK\n", function, qinfo);
else
d_vpr_t("%s: %pK\n", function, qinfo);
for (c = 0; c * row_size < packet_size; ++c) {
int bytes_to_read = ((c + 1) * row_size > packet_size) ?
packet_size % row_size : row_size;
hex_dump_to_buffer(packet + c * row_size, bytes_to_read,
row_size, 4, row, sizeof(row), false);
if (matches)
i_vpr_t(inst, "%s\n", row);
else
d_vpr_t("%s\n", row);
}
}
@@ -185,7 +203,7 @@ static bool __valdiate_session(struct msm_vidc_core *core,
bool valid = false;
struct msm_vidc_inst *temp;
if (!core)
if (!core || !inst)
return false;
__strict_check(core);
@@ -461,11 +479,11 @@ static int __vote_bandwidth(struct bus_info *bus,
{
int rc = 0;
d_vpr_p("Voting bus %s to ab %llu kbps\n", bus->name, bw_kbps);
d_vpr_p("Voting bus %s to ab %llu kbps\n", bus->name, kbps_to_icc(bw_kbps));
rc = icc_set_bw(bus->path, kbps_to_icc(bw_kbps), 0);
if (rc)
d_vpr_e("Failed voting bus %s to ab %llu, rc=%d\n",
bus->name, bw_kbps, rc);
bus->name, kbps_to_icc(bw_kbps), rc);
return rc;
}
@@ -560,6 +578,7 @@ static int __set_clk_rate(struct msm_vidc_core *core,
if (rate == cl->prev)
return 0;
d_vpr_p("Scaling clock %s to %llu, prev %llu\n", cl->name, rate, cl->prev);
rc = clk_set_rate(clk, rate);
if (rc) {
d_vpr_e("%s: Failed to set clock rate %llu %s: %d\n",
@@ -577,8 +596,6 @@ static int __set_clocks(struct msm_vidc_core *core, u32 freq)
venus_hfi_for_each_clock(core, cl) {
if (cl->has_scaling) {/* has_scaling */
d_vpr_h("Scaling clock %s to %u, prev %llu\n",
cl->name, freq, cl->prev);
rc = __set_clk_rate(core, cl, freq);
if (rc)
return rc;
@@ -629,10 +646,9 @@ static int __write_queue(struct msm_vidc_iface_q_info *qinfo, u8 *packet,
return -ENOENT;
}
if (msm_vidc_debug & VIDC_PKT) {
d_vpr_t("%s: %pK\n", __func__, qinfo);
__dump_packet(packet);
}
if (msm_vidc_debug & VIDC_PKT)
__dump_packet(packet, __func__, qinfo);
// TODO: handle writing packet
//d_vpr_e("skip writing packet\n");
@@ -706,7 +722,6 @@ static int __read_queue(struct msm_vidc_iface_q_info *qinfo, u8 *packet,
u32 receive_request = 0;
u32 read_idx, write_idx;
int rc = 0;
u32 sid;
if (!qinfo || !packet || !pb_tx_req_is_set) {
d_vpr_e("%s: invalid params %pK %pK %pK\n",
@@ -813,9 +828,7 @@ static int __read_queue(struct msm_vidc_iface_q_info *qinfo, u8 *packet,
if ((msm_vidc_debug & VIDC_PKT) &&
!(queue->qhdr_type & HFI_Q_ID_CTRL_TO_HOST_DEBUG_Q)) {
sid = *((u32 *)packet + 2);
d_vpr_t("%s: %pK\n", __func__, qinfo);
__dump_packet(packet);
__dump_packet(packet, __func__, qinfo);
}
return rc;
@@ -2530,8 +2543,6 @@ irqreturn_t venus_hfi_isr(int irq, void *data)
{
struct msm_vidc_core *core = data;
d_vpr_l("%s()\n", __func__);
disable_irq_nosync(irq);
queue_work(core->device_workq, &core->device_work);
@@ -2543,6 +2554,7 @@ void venus_hfi_work_handler(struct work_struct *work)
struct msm_vidc_core *core;
int num_responses = 0;
d_vpr_l("%s()\n", __func__);
core = container_of(work, struct msm_vidc_core, device_work);
if (!core) {
d_vpr_e("%s: invalid params\n", __func__);

View File

@@ -19,13 +19,13 @@ struct msm_vidc_hfi_range {
int (*handle)(struct msm_vidc_inst *inst, struct hfi_packet *pkt);
};
void print_psc_properties(u32 tag, const char *str, struct msm_vidc_inst *inst,
void print_psc_properties(const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_subscription_params subsc_params)
{
if (!(tag & msm_vidc_debug) || !inst)
if (!inst || !str)
return;
dprintk(tag, inst->sid,
i_vpr_h(inst,
"%s: resolution %#x, crop offsets[0] %#x, crop offsets[1] %#x, bit depth %d, coded frames %d "
"fw min count %d, poc %d, color info %d, profile %d, level %d, tier %d ",
str, subsc_params.bitstream_resolution,
@@ -483,7 +483,7 @@ static int handle_input_buffer(struct msm_vidc_inst *inst,
buf->flags = 0;
buf->flags = get_driver_buffer_flags(inst, buffer->flags);
print_vidc_buffer(VIDC_HIGH, "EBD", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "dqbuf", inst, buf);
msm_vidc_debugfs_update(inst, MSM_VIDC_DEBUGFS_EVENT_EBD);
return rc;
@@ -554,7 +554,7 @@ static int handle_output_buffer(struct msm_vidc_inst *inst,
buf->flags = 0;
buf->flags = get_driver_buffer_flags(inst, buffer->flags);
print_vidc_buffer(VIDC_HIGH, "FBD", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "dqbuf", inst, buf);
msm_vidc_debugfs_update(inst, MSM_VIDC_DEBUGFS_EVENT_FBD);
return rc;
@@ -607,7 +607,7 @@ static int handle_input_metadata_buffer(struct msm_vidc_inst *inst,
if (buffer->flags & HFI_BUF_FW_FLAG_LAST)
buf->flags |= MSM_VIDC_BUF_FLAG_LAST;
print_vidc_buffer(VIDC_HIGH, "EBD META", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "dqbuf", inst, buf);
return rc;
}
@@ -643,7 +643,7 @@ static int handle_output_metadata_buffer(struct msm_vidc_inst *inst,
if (buffer->flags & HFI_BUF_FW_FLAG_LAST)
buf->flags |= MSM_VIDC_BUF_FLAG_LAST;
print_vidc_buffer(VIDC_HIGH, "FBD META", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high", "dqbuf", inst, buf);
return rc;
}
@@ -675,7 +675,8 @@ static int handle_dequeue_buffers(struct msm_vidc_inst* inst)
*/
if ((buf->attr & MSM_VIDC_ATTR_BUFFER_DONE) &&
buf->attr & MSM_VIDC_ATTR_READ_ONLY){
print_vidc_buffer(VIDC_HIGH, "vb2 done already", inst, buf);
print_vidc_buffer(VIDC_HIGH, "high",
"vb2 done already", inst, buf);
} else {
buf->attr |= MSM_VIDC_ATTR_BUFFER_DONE;
msm_vidc_vb2_buffer_done(inst, buf);
@@ -1004,12 +1005,10 @@ static int handle_port_settings_change(struct msm_vidc_inst *inst,
__func__, pkt->port);
if (pkt->port == HFI_PORT_RAW) {
print_psc_properties(VIDC_HIGH, "OUTPUT_PSC", inst,
inst->subcr_params[OUTPUT_PORT]);
print_psc_properties("OUTPUT_PSC", inst, inst->subcr_params[OUTPUT_PORT]);
rc = msm_vdec_output_port_settings_change(inst);
} else if (pkt->port == HFI_PORT_BITSTREAM) {
print_psc_properties(VIDC_HIGH, "INPUT_PSC", inst,
inst->subcr_params[INPUT_PORT]);
print_psc_properties("INPUT_PSC", inst, inst->subcr_params[INPUT_PORT]);
rc = msm_vdec_input_port_settings_change(inst);
} else {
i_vpr_e(inst, "%s: invalid port type: %#x\n",
@@ -1283,7 +1282,7 @@ int handle_session_response_work(struct msm_vidc_inst *inst,
hdr = (struct hfi_header *)resp_work->data;
if (!hdr) {
d_vpr_e("%s: invalid params\n", __func__);
i_vpr_e(inst, "%s: invalid params\n", __func__);
return -EINVAL;
}
@@ -1392,7 +1391,7 @@ void handle_session_response_work_handler(struct work_struct *work)
}
break;
default:
d_vpr_e("%s: invalid response work type %d\n", __func__,
i_vpr_e(inst, "%s: invalid response work type %d\n", __func__,
resp_work->type);
break;
}