Loading drivers/media/platform/msm/vidc/msm_v4l2_vidc.c +0 −2 Original line number Diff line number Diff line Loading @@ -816,7 +816,6 @@ static int __init msm_vidc_init(void) if (rc) { dprintk(VIDC_ERR, "Failed to register platform driver\n"); msm_vidc_debugfs_deinit_drv(); debugfs_remove_recursive(vidc_driver->debugfs_root); kfree(vidc_driver); vidc_driver = NULL; Loading @@ -828,7 +827,6 @@ static int __init msm_vidc_init(void) static void __exit msm_vidc_exit(void) { platform_driver_unregister(&msm_vidc_driver); msm_vidc_debugfs_deinit_drv(); debugfs_remove_recursive(vidc_driver->debugfs_root); mutex_destroy(&vidc_driver->lock); kfree(vidc_driver); Loading drivers/media/platform/msm/vidc/msm_vidc.c +2 −2 Original line number Diff line number Diff line Loading @@ -1731,8 +1731,6 @@ static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst) if (inst->extradata_handle) msm_comm_smem_free(inst, inst->extradata_handle); debugfs_remove_recursive(inst->debugfs_root); mutex_lock(&inst->pending_getpropq.lock); WARN_ON(!list_empty(&inst->pending_getpropq.list)); mutex_unlock(&inst->pending_getpropq.lock); Loading Loading @@ -1777,6 +1775,8 @@ int msm_vidc_destroy(struct msm_vidc_inst *inst) mutex_destroy(&inst->bufq[OUTPUT_PORT].lock); mutex_destroy(&inst->lock); msm_vidc_debugfs_deinit_inst(inst); pr_info(VIDC_DBG_TAG "Closed video instance: %pK\n", VIDC_MSG_PRIO2STRING(VIDC_INFO), inst); kfree(inst); Loading drivers/media/platform/msm/vidc/msm_vidc_debug.c +178 −87 Original line number Diff line number Diff line Loading @@ -33,44 +33,31 @@ bool msm_vidc_syscache_disable = !true; #define MAX_DBG_BUF_SIZE 4096 struct debug_buffer { struct mutex lock; char ptr[MAX_DBG_BUF_SIZE]; char *curr; u32 filled_size; }; static struct debug_buffer dbg_buf; #define INIT_DBG_BUF(__buf) ({ \ __buf.curr = __buf.ptr;\ __buf.filled_size = 0; \ }) #define DYNAMIC_BUF_OWNER(__binfo) ({ \ atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\ }) struct core_inst_pair { struct msm_vidc_core *core; struct msm_vidc_inst *inst; }; static int core_info_open(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } static u32 write_str(struct debug_buffer *buffer, const char *fmt, ...) static u32 write_str(char *buffer, size_t size, const char *fmt, ...) { va_list args; u32 size; char *curr = buffer->curr; char *end = buffer->ptr + MAX_DBG_BUF_SIZE; u32 len; va_start(args, fmt); size = vscnprintf(curr, end - curr, fmt, args); len = vscnprintf(buffer, size, fmt, args); va_end(args); buffer->curr += size; buffer->filled_size += size; return size; return len; } static ssize_t core_info_read(struct file *file, char __user *buf, Loading @@ -79,6 +66,7 @@ static ssize_t core_info_read(struct file *file, char __user *buf, struct msm_vidc_core *core = file->private_data; struct hfi_device *hdev; struct hal_fw_info fw_info = { {0} }; char *dbuf, *cur, *end; int i = 0, rc = 0; ssize_t len = 0; Loading @@ -86,36 +74,46 @@ static ssize_t core_info_read(struct file *file, char __user *buf, dprintk(VIDC_ERR, "Invalid params, core: %pK\n", core); return 0; } dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL); if (!dbuf) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); return -ENOMEM; } cur = dbuf; end = cur + MAX_DBG_BUF_SIZE; hdev = core->device; mutex_lock(&dbg_buf.lock); INIT_DBG_BUF(dbg_buf); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "CORE %d: %pK\n", core->id, core); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "Core state: %d\n", core->state); cur += write_str(cur, end - cur, "===============================\n"); cur += write_str(cur, end - cur, "CORE %d: %pK\n", core->id, core); cur += write_str(cur, end - cur, "===============================\n"); cur += write_str(cur, end - cur, "Core state: %d\n", core->state); rc = call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data, &fw_info); if (rc) { dprintk(VIDC_WARN, "Failed to read FW info\n"); goto err_fw_info; } write_str(&dbg_buf, "FW version : %s\n", &fw_info.version); write_str(&dbg_buf, "base addr: 0x%x\n", fw_info.base_addr); write_str(&dbg_buf, "register_base: 0x%x\n", fw_info.register_base); write_str(&dbg_buf, "register_size: %u\n", fw_info.register_size); write_str(&dbg_buf, "irq: %u\n", fw_info.irq); cur += write_str(cur, end - cur, "FW version : %s\n", &fw_info.version); cur += write_str(cur, end - cur, "base addr: 0x%x\n", fw_info.base_addr); cur += write_str(cur, end - cur, "register_base: 0x%x\n", fw_info.register_base); cur += write_str(cur, end - cur, "register_size: %u\n", fw_info.register_size); cur += write_str(cur, end - cur, "irq: %u\n", fw_info.irq); err_fw_info: for (i = SYS_MSG_START; i < SYS_MSG_END; i++) { write_str(&dbg_buf, "completions[%d]: %s\n", i, cur += write_str(cur, end - cur, "completions[%d]: %s\n", i, completion_done(&core->completions[SYS_MSG_INDEX(i)]) ? "pending" : "done"); } len = simple_read_from_buffer(buf, count, ppos, dbg_buf.ptr, dbg_buf.filled_size); dbuf, cur - dbuf); mutex_unlock(&dbg_buf.lock); kfree(dbuf); return len; } Loading Loading @@ -175,7 +173,6 @@ struct dentry *msm_vidc_debugfs_init_drv(void) bool ok = false; struct dentry *dir = NULL; mutex_init(&dbg_buf.lock); dir = debugfs_create_dir("msm_vidc", NULL); if (IS_ERR_OR_NULL(dir)) { dir = NULL; Loading Loading @@ -256,13 +253,16 @@ struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core, static int inst_info_open(struct inode *inode, struct file *file) { dprintk(VIDC_INFO, "Open inode ptr: %pK\n", inode->i_private); file->private_data = inode->i_private; return 0; } static int publish_unreleased_reference(struct msm_vidc_inst *inst) static int publish_unreleased_reference(struct msm_vidc_inst *inst, char **dbuf, char *end) { struct msm_vidc_buffer *temp = NULL; char *cur = *dbuf; if (!inst) { dprintk(VIDC_ERR, "%s: invalid param\n", __func__); Loading @@ -270,14 +270,14 @@ static int publish_unreleased_reference(struct msm_vidc_inst *inst) } if (inst->buffer_mode_set[CAPTURE_PORT] == HAL_BUFFER_MODE_DYNAMIC) { write_str(&dbg_buf, "Pending buffer references:\n"); cur += write_str(cur, end - cur, "Pending buffer references\n"); mutex_lock(&inst->registeredbufs.lock); list_for_each_entry(temp, &inst->registeredbufs.list, list) { struct vb2_buffer *vb2 = &temp->vvb.vb2_buf; if (vb2->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { write_str(&dbg_buf, cur += write_str(cur, end - cur, "\tbuffer: %#x fd[0] = %d size %d refcount = %d\n", temp->smem[0].device_addr, vb2->planes[0].m.fd, Loading @@ -287,112 +287,208 @@ static int publish_unreleased_reference(struct msm_vidc_inst *inst) } mutex_unlock(&inst->registeredbufs.lock); } *dbuf = cur; return 0; } static void put_inst_helper(struct kref *kref) { struct msm_vidc_inst *inst = container_of(kref, struct msm_vidc_inst, kref); msm_vidc_destroy(inst); } static ssize_t inst_info_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct msm_vidc_inst *inst = file->private_data; struct core_inst_pair *idata = file->private_data; struct msm_vidc_core *core; struct msm_vidc_inst *inst, *temp = NULL; char *dbuf, *cur, *end; int i, j; ssize_t len = 0; if (!idata || !idata->core || !idata->inst) { dprintk(VIDC_ERR, "%s: Invalid params\n", __func__); return 0; } core = idata->core; inst = idata->inst; mutex_lock(&core->lock); list_for_each_entry(temp, &core->instances, list) { if (temp == inst) break; } inst = ((temp == inst) && kref_get_unless_zero(&inst->kref)) ? inst : NULL; mutex_unlock(&core->lock); if (!inst) { dprintk(VIDC_ERR, "Invalid params, inst %pK\n", inst); dprintk(VIDC_ERR, "%s: Instance has become obsolete", __func__); return 0; } mutex_lock(&dbg_buf.lock); INIT_DBG_BUF(dbg_buf); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "INSTANCE: %pK (%s)\n", inst, dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL); if (!dbuf) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); len = -ENOMEM; goto failed_alloc; } cur = dbuf; end = cur + MAX_DBG_BUF_SIZE; cur += write_str(cur, end - cur, "==============================\n"); cur += write_str(cur, end - cur, "INSTANCE: %pK (%s)\n", inst, inst->session_type == MSM_VIDC_ENCODER ? "Encoder" : "Decoder"); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "core: %pK\n", inst->core); write_str(&dbg_buf, "height: %d\n", inst->prop.height[CAPTURE_PORT]); write_str(&dbg_buf, "width: %d\n", inst->prop.width[CAPTURE_PORT]); write_str(&dbg_buf, "fps: %d\n", inst->prop.fps); write_str(&dbg_buf, "state: %d\n", inst->state); write_str(&dbg_buf, "secure: %d\n", !!(inst->flags & VIDC_SECURE)); write_str(&dbg_buf, "-----------Formats-------------\n"); cur += write_str(cur, end - cur, "==============================\n"); cur += write_str(cur, end - cur, "core: %pK\n", inst->core); cur += write_str(cur, end - cur, "height: %d\n", inst->prop.height[CAPTURE_PORT]); cur += write_str(cur, end - cur, "width: %d\n", inst->prop.width[CAPTURE_PORT]); cur += write_str(cur, end - cur, "fps: %d\n", inst->prop.fps); cur += write_str(cur, end - cur, "state: %d\n", inst->state); cur += write_str(cur, end - cur, "secure: %d\n", !!(inst->flags & VIDC_SECURE)); cur += write_str(cur, end - cur, "-----------Formats-------------\n"); for (i = 0; i < MAX_PORT_NUM; i++) { write_str(&dbg_buf, "capability: %s\n", i == OUTPUT_PORT ? "Output" : "Capture"); write_str(&dbg_buf, "name : %s\n", inst->fmts[i].name); write_str(&dbg_buf, "planes : %d\n", inst->bufq[i].num_planes); write_str( &dbg_buf, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ? cur += write_str(cur, end - cur, "capability: %s\n", i == OUTPUT_PORT ? "Output" : "Capture"); cur += write_str(cur, end - cur, "name : %s\n", inst->fmts[i].name); cur += write_str(cur, end - cur, "planes : %d\n", inst->bufq[i].num_planes); cur += write_str(cur, end - cur, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ? "Output" : "Capture"); switch (inst->buffer_mode_set[i]) { case HAL_BUFFER_MODE_STATIC: write_str(&dbg_buf, "buffer mode : %s\n", "static"); cur += write_str(cur, end - cur, "buffer mode : %s\n", "static"); break; case HAL_BUFFER_MODE_DYNAMIC: write_str(&dbg_buf, "buffer mode : %s\n", "dynamic"); cur += write_str(cur, end - cur, "buffer mode : %s\n", "dynamic"); break; default: write_str(&dbg_buf, "buffer mode : unsupported\n"); cur += write_str(cur, end - cur, "buffer mode : unsupported\n"); } write_str(&dbg_buf, "count: %u\n", cur += write_str(cur, end - cur, "count: %u\n", inst->bufq[i].vb2_bufq.num_buffers); for (j = 0; j < inst->bufq[i].num_planes; j++) write_str(&dbg_buf, "size for plane %d: %u\n", j, inst->bufq[i].plane_sizes[j]); cur += write_str(cur, end - cur, "size for plane %d: %u\n", j, inst->bufq[i].plane_sizes[j]); if (i < MAX_PORT_NUM - 1) write_str(&dbg_buf, "\n"); cur += write_str(cur, end - cur, "\n"); } write_str(&dbg_buf, "-------------------------------\n"); cur += write_str(cur, end - cur, "-------------------------------\n"); for (i = SESSION_MSG_START; i < SESSION_MSG_END; i++) { write_str(&dbg_buf, "completions[%d]: %s\n", i, cur += write_str(cur, end - cur, "completions[%d]: %s\n", i, completion_done(&inst->completions[SESSION_MSG_INDEX(i)]) ? "pending" : "done"); } write_str(&dbg_buf, "ETB Count: %d\n", inst->count.etb); write_str(&dbg_buf, "EBD Count: %d\n", inst->count.ebd); write_str(&dbg_buf, "FTB Count: %d\n", inst->count.ftb); write_str(&dbg_buf, "FBD Count: %d\n", inst->count.fbd); publish_unreleased_reference(inst); cur += write_str(cur, end - cur, "ETB Count: %d\n", inst->count.etb); cur += write_str(cur, end - cur, "EBD Count: %d\n", inst->count.ebd); cur += write_str(cur, end - cur, "FTB Count: %d\n", inst->count.ftb); cur += write_str(cur, end - cur, "FBD Count: %d\n", inst->count.fbd); publish_unreleased_reference(inst, &cur, end); len = simple_read_from_buffer(buf, count, ppos, dbg_buf.ptr, dbg_buf.filled_size); mutex_unlock(&dbg_buf.lock); dbuf, cur - dbuf); kfree(dbuf); failed_alloc: kref_put(&inst->kref, put_inst_helper); return len; } static int inst_info_release(struct inode *inode, struct file *file) { dprintk(VIDC_INFO, "Release inode ptr: %pK\n", inode->i_private); file->private_data = NULL; return 0; } static const struct file_operations inst_info_fops = { .open = inst_info_open, .read = inst_info_read, .release = inst_info_release, }; struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst, struct dentry *parent) { struct dentry *dir = NULL; struct dentry *dir = NULL, *info = NULL; char debugfs_name[MAX_DEBUGFS_NAME]; struct core_inst_pair *idata = NULL; if (!inst) { dprintk(VIDC_ERR, "Invalid params, inst: %pK\n", inst); goto failed_create_dir; goto exit; } snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%p", inst); idata = kzalloc(sizeof(struct core_inst_pair), GFP_KERNEL); if (!idata) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); goto exit; } idata->core = inst->core; idata->inst = inst; dir = debugfs_create_dir(debugfs_name, parent); if (!dir) { dprintk(VIDC_ERR, "Failed to create debugfs for msm_vidc\n"); goto failed_create_dir; } if (!debugfs_create_file("info", 0444, dir, inst, &inst_info_fops)) { info = debugfs_create_file("info", 0444, dir, idata, &inst_info_fops); if (!info) { dprintk(VIDC_ERR, "debugfs_create_file: fail\n"); goto failed_create_dir; goto failed_create_file; } dir->d_inode->i_private = info->d_inode->i_private; inst->debug.pdata[FRAME_PROCESSING].sampling = true; return dir; failed_create_file: debugfs_remove_recursive(dir); dir = NULL; failed_create_dir: kfree(idata); exit: return dir; } void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst) { struct dentry *dentry = NULL; if (!inst || !inst->debugfs_root) return; dentry = inst->debugfs_root; if (dentry->d_inode) { dprintk(VIDC_INFO, "Destroy %pK\n", dentry->d_inode->i_private); kfree(dentry->d_inode->i_private); dentry->d_inode->i_private = NULL; } debugfs_remove_recursive(dentry); inst->debugfs_root = NULL; } void msm_vidc_debugfs_update(struct msm_vidc_inst *inst, enum msm_vidc_debugfs_event e) { Loading Loading @@ -441,8 +537,3 @@ void msm_vidc_debugfs_update(struct msm_vidc_inst *inst, } } void msm_vidc_debugfs_deinit_drv(void) { mutex_destroy(&dbg_buf.lock); } drivers/media/platform/msm/vidc/msm_vidc_debug.h +1 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core, struct dentry *parent); struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst, struct dentry *parent); 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); void msm_vidc_debugfs_deinit_drv(void); static inline void tic(struct msm_vidc_inst *i, enum profiling_points p, char *b) Loading Loading
drivers/media/platform/msm/vidc/msm_v4l2_vidc.c +0 −2 Original line number Diff line number Diff line Loading @@ -816,7 +816,6 @@ static int __init msm_vidc_init(void) if (rc) { dprintk(VIDC_ERR, "Failed to register platform driver\n"); msm_vidc_debugfs_deinit_drv(); debugfs_remove_recursive(vidc_driver->debugfs_root); kfree(vidc_driver); vidc_driver = NULL; Loading @@ -828,7 +827,6 @@ static int __init msm_vidc_init(void) static void __exit msm_vidc_exit(void) { platform_driver_unregister(&msm_vidc_driver); msm_vidc_debugfs_deinit_drv(); debugfs_remove_recursive(vidc_driver->debugfs_root); mutex_destroy(&vidc_driver->lock); kfree(vidc_driver); Loading
drivers/media/platform/msm/vidc/msm_vidc.c +2 −2 Original line number Diff line number Diff line Loading @@ -1731,8 +1731,6 @@ static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst) if (inst->extradata_handle) msm_comm_smem_free(inst, inst->extradata_handle); debugfs_remove_recursive(inst->debugfs_root); mutex_lock(&inst->pending_getpropq.lock); WARN_ON(!list_empty(&inst->pending_getpropq.list)); mutex_unlock(&inst->pending_getpropq.lock); Loading Loading @@ -1777,6 +1775,8 @@ int msm_vidc_destroy(struct msm_vidc_inst *inst) mutex_destroy(&inst->bufq[OUTPUT_PORT].lock); mutex_destroy(&inst->lock); msm_vidc_debugfs_deinit_inst(inst); pr_info(VIDC_DBG_TAG "Closed video instance: %pK\n", VIDC_MSG_PRIO2STRING(VIDC_INFO), inst); kfree(inst); Loading
drivers/media/platform/msm/vidc/msm_vidc_debug.c +178 −87 Original line number Diff line number Diff line Loading @@ -33,44 +33,31 @@ bool msm_vidc_syscache_disable = !true; #define MAX_DBG_BUF_SIZE 4096 struct debug_buffer { struct mutex lock; char ptr[MAX_DBG_BUF_SIZE]; char *curr; u32 filled_size; }; static struct debug_buffer dbg_buf; #define INIT_DBG_BUF(__buf) ({ \ __buf.curr = __buf.ptr;\ __buf.filled_size = 0; \ }) #define DYNAMIC_BUF_OWNER(__binfo) ({ \ atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\ }) struct core_inst_pair { struct msm_vidc_core *core; struct msm_vidc_inst *inst; }; static int core_info_open(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } static u32 write_str(struct debug_buffer *buffer, const char *fmt, ...) static u32 write_str(char *buffer, size_t size, const char *fmt, ...) { va_list args; u32 size; char *curr = buffer->curr; char *end = buffer->ptr + MAX_DBG_BUF_SIZE; u32 len; va_start(args, fmt); size = vscnprintf(curr, end - curr, fmt, args); len = vscnprintf(buffer, size, fmt, args); va_end(args); buffer->curr += size; buffer->filled_size += size; return size; return len; } static ssize_t core_info_read(struct file *file, char __user *buf, Loading @@ -79,6 +66,7 @@ static ssize_t core_info_read(struct file *file, char __user *buf, struct msm_vidc_core *core = file->private_data; struct hfi_device *hdev; struct hal_fw_info fw_info = { {0} }; char *dbuf, *cur, *end; int i = 0, rc = 0; ssize_t len = 0; Loading @@ -86,36 +74,46 @@ static ssize_t core_info_read(struct file *file, char __user *buf, dprintk(VIDC_ERR, "Invalid params, core: %pK\n", core); return 0; } dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL); if (!dbuf) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); return -ENOMEM; } cur = dbuf; end = cur + MAX_DBG_BUF_SIZE; hdev = core->device; mutex_lock(&dbg_buf.lock); INIT_DBG_BUF(dbg_buf); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "CORE %d: %pK\n", core->id, core); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "Core state: %d\n", core->state); cur += write_str(cur, end - cur, "===============================\n"); cur += write_str(cur, end - cur, "CORE %d: %pK\n", core->id, core); cur += write_str(cur, end - cur, "===============================\n"); cur += write_str(cur, end - cur, "Core state: %d\n", core->state); rc = call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data, &fw_info); if (rc) { dprintk(VIDC_WARN, "Failed to read FW info\n"); goto err_fw_info; } write_str(&dbg_buf, "FW version : %s\n", &fw_info.version); write_str(&dbg_buf, "base addr: 0x%x\n", fw_info.base_addr); write_str(&dbg_buf, "register_base: 0x%x\n", fw_info.register_base); write_str(&dbg_buf, "register_size: %u\n", fw_info.register_size); write_str(&dbg_buf, "irq: %u\n", fw_info.irq); cur += write_str(cur, end - cur, "FW version : %s\n", &fw_info.version); cur += write_str(cur, end - cur, "base addr: 0x%x\n", fw_info.base_addr); cur += write_str(cur, end - cur, "register_base: 0x%x\n", fw_info.register_base); cur += write_str(cur, end - cur, "register_size: %u\n", fw_info.register_size); cur += write_str(cur, end - cur, "irq: %u\n", fw_info.irq); err_fw_info: for (i = SYS_MSG_START; i < SYS_MSG_END; i++) { write_str(&dbg_buf, "completions[%d]: %s\n", i, cur += write_str(cur, end - cur, "completions[%d]: %s\n", i, completion_done(&core->completions[SYS_MSG_INDEX(i)]) ? "pending" : "done"); } len = simple_read_from_buffer(buf, count, ppos, dbg_buf.ptr, dbg_buf.filled_size); dbuf, cur - dbuf); mutex_unlock(&dbg_buf.lock); kfree(dbuf); return len; } Loading Loading @@ -175,7 +173,6 @@ struct dentry *msm_vidc_debugfs_init_drv(void) bool ok = false; struct dentry *dir = NULL; mutex_init(&dbg_buf.lock); dir = debugfs_create_dir("msm_vidc", NULL); if (IS_ERR_OR_NULL(dir)) { dir = NULL; Loading Loading @@ -256,13 +253,16 @@ struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core, static int inst_info_open(struct inode *inode, struct file *file) { dprintk(VIDC_INFO, "Open inode ptr: %pK\n", inode->i_private); file->private_data = inode->i_private; return 0; } static int publish_unreleased_reference(struct msm_vidc_inst *inst) static int publish_unreleased_reference(struct msm_vidc_inst *inst, char **dbuf, char *end) { struct msm_vidc_buffer *temp = NULL; char *cur = *dbuf; if (!inst) { dprintk(VIDC_ERR, "%s: invalid param\n", __func__); Loading @@ -270,14 +270,14 @@ static int publish_unreleased_reference(struct msm_vidc_inst *inst) } if (inst->buffer_mode_set[CAPTURE_PORT] == HAL_BUFFER_MODE_DYNAMIC) { write_str(&dbg_buf, "Pending buffer references:\n"); cur += write_str(cur, end - cur, "Pending buffer references\n"); mutex_lock(&inst->registeredbufs.lock); list_for_each_entry(temp, &inst->registeredbufs.list, list) { struct vb2_buffer *vb2 = &temp->vvb.vb2_buf; if (vb2->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { write_str(&dbg_buf, cur += write_str(cur, end - cur, "\tbuffer: %#x fd[0] = %d size %d refcount = %d\n", temp->smem[0].device_addr, vb2->planes[0].m.fd, Loading @@ -287,112 +287,208 @@ static int publish_unreleased_reference(struct msm_vidc_inst *inst) } mutex_unlock(&inst->registeredbufs.lock); } *dbuf = cur; return 0; } static void put_inst_helper(struct kref *kref) { struct msm_vidc_inst *inst = container_of(kref, struct msm_vidc_inst, kref); msm_vidc_destroy(inst); } static ssize_t inst_info_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct msm_vidc_inst *inst = file->private_data; struct core_inst_pair *idata = file->private_data; struct msm_vidc_core *core; struct msm_vidc_inst *inst, *temp = NULL; char *dbuf, *cur, *end; int i, j; ssize_t len = 0; if (!idata || !idata->core || !idata->inst) { dprintk(VIDC_ERR, "%s: Invalid params\n", __func__); return 0; } core = idata->core; inst = idata->inst; mutex_lock(&core->lock); list_for_each_entry(temp, &core->instances, list) { if (temp == inst) break; } inst = ((temp == inst) && kref_get_unless_zero(&inst->kref)) ? inst : NULL; mutex_unlock(&core->lock); if (!inst) { dprintk(VIDC_ERR, "Invalid params, inst %pK\n", inst); dprintk(VIDC_ERR, "%s: Instance has become obsolete", __func__); return 0; } mutex_lock(&dbg_buf.lock); INIT_DBG_BUF(dbg_buf); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "INSTANCE: %pK (%s)\n", inst, dbuf = kzalloc(MAX_DBG_BUF_SIZE, GFP_KERNEL); if (!dbuf) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); len = -ENOMEM; goto failed_alloc; } cur = dbuf; end = cur + MAX_DBG_BUF_SIZE; cur += write_str(cur, end - cur, "==============================\n"); cur += write_str(cur, end - cur, "INSTANCE: %pK (%s)\n", inst, inst->session_type == MSM_VIDC_ENCODER ? "Encoder" : "Decoder"); write_str(&dbg_buf, "===============================\n"); write_str(&dbg_buf, "core: %pK\n", inst->core); write_str(&dbg_buf, "height: %d\n", inst->prop.height[CAPTURE_PORT]); write_str(&dbg_buf, "width: %d\n", inst->prop.width[CAPTURE_PORT]); write_str(&dbg_buf, "fps: %d\n", inst->prop.fps); write_str(&dbg_buf, "state: %d\n", inst->state); write_str(&dbg_buf, "secure: %d\n", !!(inst->flags & VIDC_SECURE)); write_str(&dbg_buf, "-----------Formats-------------\n"); cur += write_str(cur, end - cur, "==============================\n"); cur += write_str(cur, end - cur, "core: %pK\n", inst->core); cur += write_str(cur, end - cur, "height: %d\n", inst->prop.height[CAPTURE_PORT]); cur += write_str(cur, end - cur, "width: %d\n", inst->prop.width[CAPTURE_PORT]); cur += write_str(cur, end - cur, "fps: %d\n", inst->prop.fps); cur += write_str(cur, end - cur, "state: %d\n", inst->state); cur += write_str(cur, end - cur, "secure: %d\n", !!(inst->flags & VIDC_SECURE)); cur += write_str(cur, end - cur, "-----------Formats-------------\n"); for (i = 0; i < MAX_PORT_NUM; i++) { write_str(&dbg_buf, "capability: %s\n", i == OUTPUT_PORT ? "Output" : "Capture"); write_str(&dbg_buf, "name : %s\n", inst->fmts[i].name); write_str(&dbg_buf, "planes : %d\n", inst->bufq[i].num_planes); write_str( &dbg_buf, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ? cur += write_str(cur, end - cur, "capability: %s\n", i == OUTPUT_PORT ? "Output" : "Capture"); cur += write_str(cur, end - cur, "name : %s\n", inst->fmts[i].name); cur += write_str(cur, end - cur, "planes : %d\n", inst->bufq[i].num_planes); cur += write_str(cur, end - cur, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ? "Output" : "Capture"); switch (inst->buffer_mode_set[i]) { case HAL_BUFFER_MODE_STATIC: write_str(&dbg_buf, "buffer mode : %s\n", "static"); cur += write_str(cur, end - cur, "buffer mode : %s\n", "static"); break; case HAL_BUFFER_MODE_DYNAMIC: write_str(&dbg_buf, "buffer mode : %s\n", "dynamic"); cur += write_str(cur, end - cur, "buffer mode : %s\n", "dynamic"); break; default: write_str(&dbg_buf, "buffer mode : unsupported\n"); cur += write_str(cur, end - cur, "buffer mode : unsupported\n"); } write_str(&dbg_buf, "count: %u\n", cur += write_str(cur, end - cur, "count: %u\n", inst->bufq[i].vb2_bufq.num_buffers); for (j = 0; j < inst->bufq[i].num_planes; j++) write_str(&dbg_buf, "size for plane %d: %u\n", j, inst->bufq[i].plane_sizes[j]); cur += write_str(cur, end - cur, "size for plane %d: %u\n", j, inst->bufq[i].plane_sizes[j]); if (i < MAX_PORT_NUM - 1) write_str(&dbg_buf, "\n"); cur += write_str(cur, end - cur, "\n"); } write_str(&dbg_buf, "-------------------------------\n"); cur += write_str(cur, end - cur, "-------------------------------\n"); for (i = SESSION_MSG_START; i < SESSION_MSG_END; i++) { write_str(&dbg_buf, "completions[%d]: %s\n", i, cur += write_str(cur, end - cur, "completions[%d]: %s\n", i, completion_done(&inst->completions[SESSION_MSG_INDEX(i)]) ? "pending" : "done"); } write_str(&dbg_buf, "ETB Count: %d\n", inst->count.etb); write_str(&dbg_buf, "EBD Count: %d\n", inst->count.ebd); write_str(&dbg_buf, "FTB Count: %d\n", inst->count.ftb); write_str(&dbg_buf, "FBD Count: %d\n", inst->count.fbd); publish_unreleased_reference(inst); cur += write_str(cur, end - cur, "ETB Count: %d\n", inst->count.etb); cur += write_str(cur, end - cur, "EBD Count: %d\n", inst->count.ebd); cur += write_str(cur, end - cur, "FTB Count: %d\n", inst->count.ftb); cur += write_str(cur, end - cur, "FBD Count: %d\n", inst->count.fbd); publish_unreleased_reference(inst, &cur, end); len = simple_read_from_buffer(buf, count, ppos, dbg_buf.ptr, dbg_buf.filled_size); mutex_unlock(&dbg_buf.lock); dbuf, cur - dbuf); kfree(dbuf); failed_alloc: kref_put(&inst->kref, put_inst_helper); return len; } static int inst_info_release(struct inode *inode, struct file *file) { dprintk(VIDC_INFO, "Release inode ptr: %pK\n", inode->i_private); file->private_data = NULL; return 0; } static const struct file_operations inst_info_fops = { .open = inst_info_open, .read = inst_info_read, .release = inst_info_release, }; struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst, struct dentry *parent) { struct dentry *dir = NULL; struct dentry *dir = NULL, *info = NULL; char debugfs_name[MAX_DEBUGFS_NAME]; struct core_inst_pair *idata = NULL; if (!inst) { dprintk(VIDC_ERR, "Invalid params, inst: %pK\n", inst); goto failed_create_dir; goto exit; } snprintf(debugfs_name, MAX_DEBUGFS_NAME, "inst_%p", inst); idata = kzalloc(sizeof(struct core_inst_pair), GFP_KERNEL); if (!idata) { dprintk(VIDC_ERR, "%s: Allocation failed!\n", __func__); goto exit; } idata->core = inst->core; idata->inst = inst; dir = debugfs_create_dir(debugfs_name, parent); if (!dir) { dprintk(VIDC_ERR, "Failed to create debugfs for msm_vidc\n"); goto failed_create_dir; } if (!debugfs_create_file("info", 0444, dir, inst, &inst_info_fops)) { info = debugfs_create_file("info", 0444, dir, idata, &inst_info_fops); if (!info) { dprintk(VIDC_ERR, "debugfs_create_file: fail\n"); goto failed_create_dir; goto failed_create_file; } dir->d_inode->i_private = info->d_inode->i_private; inst->debug.pdata[FRAME_PROCESSING].sampling = true; return dir; failed_create_file: debugfs_remove_recursive(dir); dir = NULL; failed_create_dir: kfree(idata); exit: return dir; } void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst) { struct dentry *dentry = NULL; if (!inst || !inst->debugfs_root) return; dentry = inst->debugfs_root; if (dentry->d_inode) { dprintk(VIDC_INFO, "Destroy %pK\n", dentry->d_inode->i_private); kfree(dentry->d_inode->i_private); dentry->d_inode->i_private = NULL; } debugfs_remove_recursive(dentry); inst->debugfs_root = NULL; } void msm_vidc_debugfs_update(struct msm_vidc_inst *inst, enum msm_vidc_debugfs_event e) { Loading Loading @@ -441,8 +537,3 @@ void msm_vidc_debugfs_update(struct msm_vidc_inst *inst, } } void msm_vidc_debugfs_deinit_drv(void) { mutex_destroy(&dbg_buf.lock); }
drivers/media/platform/msm/vidc/msm_vidc_debug.h +1 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core, struct dentry *parent); struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst, struct dentry *parent); 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); void msm_vidc_debugfs_deinit_drv(void); static inline void tic(struct msm_vidc_inst *i, enum profiling_points p, char *b) Loading