MLK-22370: VPU Decoder: export firmware dbglog using raw data instead of
authorming_qian <ming.qian@nxp.com>
Fri, 2 Aug 2019 06:39:03 +0000 (14:39 +0800)
committerming_qian <ming.qian@nxp.com>
Fri, 2 Aug 2019 08:06:28 +0000 (16:06 +0800)
string

we can use the debug tool analyze the raw dbglog.

Signed-off-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
drivers/mxc/vpu_malone/vpu_b0.c
drivers/mxc/vpu_malone/vpu_b0.h

index c3f6071..e23ee99 100644 (file)
@@ -59,6 +59,7 @@ static int vpu_log_depth = DEFAULT_LOG_DEPTH;
 static int vpu_max_bufsize = MAX_BUFFER_SIZE;
 static int vpu_frmdbg_ena = DEFAULT_FRMDBG_ENABLE;
 static int vpu_frmdbg_level = DEFAULT_FRMDBG_LEVEL;
+static int vpu_frmdbg_raw = 1;
 static int vpu_dbe_num = 1;
 static int vpu_frmcrcdump_ena;
 static int stream_buffer_threshold = 0x10000;
@@ -4986,27 +4987,42 @@ static int vpu_firmware_download(struct vpu_dev *This)
 
 static int dbglog_show(struct seq_file *s, void *data)
 {
-#define DBG_UNIT_SIZE (7)
-
-       struct vpu_ctx *ctx = (struct vpu_ctx *)s->private;
+#define DBG_UNIT_SIZE          (7)
+       struct vpu_dev *dev = s->private;
        u_int32 *pbuf;
-       u_int32 i, line;
-#if 0
-       seq_printf(s, "dbg log buffer:\n");
-#endif
-       pbuf = (u_int32 *)ctx->dev->shared_mem.dbglog_mem_vir;
-       line = (DBGLOG_SIZE) / (DBG_UNIT_SIZE * 4);
-       for (i = 0; i < line; i++) {
-#if 0
-               seq_printf(s, "[%03d]:%08X %08X %08X %08X-%08X %08X %08X\n",
-                       i, pbuf[0], pbuf[1], pbuf[2], pbuf[3], pbuf[4], pbuf[5], pbuf[6]);
-#else
-               seq_printf(s, "%08x %08x %08x %08x %08x %08x %08x\n",
-                               pbuf[0], pbuf[1], pbuf[2], pbuf[3], pbuf[4], pbuf[5], pbuf[6]);
-#endif
-               pbuf += 7;
+       u_int32 line;
+       int length;
+
+       pbuf = (u_int32 *)dev->shared_mem.dbglog_mem_vir;
+       line = (DBGLOG_SIZE) / (DBG_UNIT_SIZE * sizeof(u_int32));
+       if (!line)
+               return 0;
+
+       if (!vpu_frmdbg_raw) {
+               u_int32 i;
+
+               length = 9 * DBG_UNIT_SIZE * line + 1;
+               if (s->count + length >= s->size) {
+                       s->count = s->size;
+                       return 0;
+               }
+               for (i = 0; i < line; i++) {
+                       seq_printf(s, "%08x %08x %08x %08x %08x %08x %08x\n",
+                               pbuf[0], pbuf[1], pbuf[2], pbuf[3],
+                               pbuf[4], pbuf[5], pbuf[6]);
+                       pbuf += DBG_UNIT_SIZE;
+               }
+
+               return 0;
        }
-       return 0;
+
+       length = DBG_UNIT_SIZE * sizeof(u_int32) * line;
+       if (s->count + length >= s->size) {
+               s->count = s->size;
+               return 0;
+       }
+
+       return seq_write(s, (void *)pbuf, length);
 }
 
 static int dbglog_open(struct inode *inode, struct file *filp)
@@ -5020,22 +5036,28 @@ static struct file_operations dbglog_fops = {
        .read = seq_read,
 };
 
-static int create_instance_dbglog_file(struct vpu_ctx *ctx)
+static int create_dbglog_file(struct vpu_dev *dev)
 {
-       if (ctx->dev->debugfs_root == NULL)
-               ctx->dev->debugfs_root = debugfs_create_dir("vpu", NULL);
+       if (dev->debugfs_root == NULL) {
+               dev->debugfs_root = debugfs_create_dir("vpu", NULL);
+               if (!dev->debugfs_root) {
+                       vpu_err("error: create debugfs_root fail\n");
+                       return -EINVAL;
+               }
+       }
 
-       scnprintf(ctx->dbglog_name, sizeof(ctx->dbglog_name) - 1,
-                       "instance%d",
-                       ctx->str_index);
+       if (dev->debugfs_dbglog)
+               return 0;
 
-       ctx->dbglog_dir = debugfs_create_dir(ctx->dbglog_name, ctx->dev->debugfs_root);
-       if (!ctx->dbglog_dir) {
-               vpu_err("error: %s() ctx->dbglog_dir == NULL\n", __func__);
+       dev->debugfs_dbglog = debugfs_create_file("dbglog",
+                       VERIFY_OCTAL_PERMISSIONS(0444),
+                       dev->debugfs_root,
+                       dev,
+                       &dbglog_fops);
+       if (!dev->debugfs_dbglog) {
+               vpu_err("error: create debugfs_dbglog fail\n");
                return -EINVAL;
        }
-       debugfs_create_file("dbglog", VERIFY_OCTAL_PERMISSIONS(0444),
-               ctx->dbglog_dir, ctx, &dbglog_fops);
 
        return 0;
 }
@@ -5511,7 +5533,6 @@ static int create_instance_file(struct vpu_ctx *ctx)
        create_instance_command_file(ctx);
        create_instance_event_file(ctx);
        create_instance_buffer_file(ctx);
-       create_instance_dbglog_file(ctx);
        create_instance_flow_file(ctx);
        atomic64_set(&ctx->statistic.total_dma_size, 0);
        atomic64_set(&ctx->statistic.total_alloc_size, 0);
@@ -5527,10 +5548,6 @@ static int remove_instance_file(struct vpu_ctx *ctx)
        device_remove_file(ctx->dev->generic_dev, &ctx->dev_attr_instance_command);
        device_remove_file(ctx->dev->generic_dev, &ctx->dev_attr_instance_event);
        device_remove_file(ctx->dev->generic_dev, &ctx->dev_attr_instance_buffer);
-       if (ctx->dbglog_dir != NULL) {
-               debugfs_remove_recursive(ctx->dbglog_dir);
-               ctx->dbglog_dir = NULL;
-       }
        device_remove_file(ctx->dev->generic_dev, &ctx->dev_attr_instance_flow);
 
        return 0;
@@ -5737,6 +5754,7 @@ static int v4l2_open(struct file *filp)
                }
                dev->fw_is_ready = true;
                create_fwlog_file(ctx->dev);
+               create_dbglog_file(ctx->dev);
        }
        mutex_unlock(&dev->dev_mutex);
        rpc_set_stream_cfg_value(dev->shared_mem.pSharedInterface, ctx->str_index, vpu_dbe_num);
@@ -6218,6 +6236,8 @@ static int vpu_remove(struct platform_device *pdev)
        device_remove_file(&pdev->dev, &dev_attr_precheck_pattern);
        debugfs_remove_recursive(dev->debugfs_root);
        dev->debugfs_root = NULL;
+       dev->debugfs_dbglog = NULL;
+       dev->debugfs_fwlog = NULL;
        destroy_workqueue(dev->workqueue);
        if (dev->m0_p_fw_space_vir)
                iounmap(dev->m0_p_fw_space_vir);
@@ -6468,6 +6488,8 @@ module_param(vpu_frmdbg_ena, int, 0644);
 MODULE_PARM_DESC(vpu_frmdbg_ena, "enable firmware mask instance dbg log (bit N to mask instance N)");
 module_param(vpu_frmdbg_level, int, 0644);
 MODULE_PARM_DESC(vpu_frmdbg_level, "firmware debug level (0-2)");
+module_param(vpu_frmdbg_raw, int, 0644);
+MODULE_PARM_DESC(vpu_frmdbg_raw, "dump dbglog with raw data or not");
 module_param(vpu_max_bufsize, int, 0644);
 MODULE_PARM_DESC(vpu_max_bufsize, "maximun stream buffer size");
 module_param(vpu_dbe_num, int, 0644);
index 8f5f072..c75ba6b 100644 (file)
@@ -281,6 +281,7 @@ struct vpu_dev {
        struct shared_addr shared_mem;
        struct vpu_ctx *ctx[VPU_MAX_NUM_STREAMS];
        struct dentry *debugfs_root;
+       struct dentry *debugfs_dbglog;
        struct dentry *debugfs_fwlog;
 
        struct print_buf_desc *print_buf;
@@ -331,8 +332,6 @@ struct vpu_ctx {
        char buffer_name[64];
        struct device_attribute dev_attr_instance_flow;
        char flow_name[64];
-       struct dentry *dbglog_dir;
-       char dbglog_name[64];
        struct v4l2_ctrl *ctrls[V4L2_MAX_CTRLS];
        struct v4l2_ctrl_handler ctrl_handler;
        bool ctrl_inited;