static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
                             size_t count, loff_t *ppos)
 {
-       struct hns3_dbg_data *dbg_data = filp->private_data;
+       char *buf = filp->private_data;
+
+       return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+}
+
+static int hns3_dbg_open(struct inode *inode, struct file *filp)
+{
+       struct hns3_dbg_data *dbg_data = inode->i_private;
        struct hnae3_handle *handle = dbg_data->handle;
        struct hns3_nic_priv *priv = handle->priv;
-       ssize_t size = 0;
-       char **save_buf;
-       char *read_buf;
        u32 index;
+       char *buf;
        int ret;
 
+       if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
+           test_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
+               return -EBUSY;
+
        ret = hns3_dbg_get_cmd_index(dbg_data, &index);
        if (ret)
                return ret;
 
-       mutex_lock(&handle->dbgfs_lock);
-       save_buf = &handle->dbgfs_buf[index];
-
-       if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) ||
-           test_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) {
-               ret = -EBUSY;
-               goto out;
-       }
-
-       if (*save_buf) {
-               read_buf = *save_buf;
-       } else {
-               read_buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL);
-               if (!read_buf) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-
-               /* save the buffer addr until the last read operation */
-               *save_buf = read_buf;
-
-               /* get data ready for the first time to read */
-               ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
-                                       read_buf, hns3_dbg_cmd[index].buf_len);
-               if (ret)
-                       goto out;
-       }
+       buf = kvzalloc(hns3_dbg_cmd[index].buf_len, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
 
-       size = simple_read_from_buffer(buffer, count, ppos, read_buf,
-                                      strlen(read_buf));
-       if (size > 0) {
-               mutex_unlock(&handle->dbgfs_lock);
-               return size;
+       ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
+                               buf, hns3_dbg_cmd[index].buf_len);
+       if (ret) {
+               kvfree(buf);
+               return ret;
        }
 
-out:
-       /* free the buffer for the last read operation */
-       if (*save_buf) {
-               kvfree(*save_buf);
-               *save_buf = NULL;
-       }
+       filp->private_data = buf;
+       return 0;
+}
 
-       mutex_unlock(&handle->dbgfs_lock);
-       return ret;
+static int hns3_dbg_release(struct inode *inode, struct file *filp)
+{
+       kvfree(filp->private_data);
+       filp->private_data = NULL;
+       return 0;
 }
 
 static const struct file_operations hns3_dbg_fops = {
        .owner = THIS_MODULE,
-       .open  = simple_open,
+       .open  = hns3_dbg_open,
        .read  = hns3_dbg_read,
+       .release = hns3_dbg_release,
 };
 
 static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd)
        int ret;
        u32 i;
 
-       handle->dbgfs_buf = devm_kcalloc(&handle->pdev->dev,
-                                        ARRAY_SIZE(hns3_dbg_cmd),
-                                        sizeof(*handle->dbgfs_buf),
-                                        GFP_KERNEL);
-       if (!handle->dbgfs_buf)
-               return -ENOMEM;
-
        hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry =
                                debugfs_create_dir(name, hns3_dbgfs_root);
        handle->hnae3_dbgfs = hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON].dentry;
                        debugfs_create_dir(hns3_dbg_dentry[i].name,
                                           handle->hnae3_dbgfs);
 
-       mutex_init(&handle->dbgfs_lock);
-
        for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++) {
                if ((hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_TM_NODES &&
                     ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2) ||
 out:
        debugfs_remove_recursive(handle->hnae3_dbgfs);
        handle->hnae3_dbgfs = NULL;
-       mutex_destroy(&handle->dbgfs_lock);
        return ret;
 }
 
 void hns3_dbg_uninit(struct hnae3_handle *handle)
 {
-       u32 i;
-
        debugfs_remove_recursive(handle->hnae3_dbgfs);
        handle->hnae3_dbgfs = NULL;
-
-       for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
-               if (handle->dbgfs_buf[i]) {
-                       kvfree(handle->dbgfs_buf[i]);
-                       handle->dbgfs_buf[i] = NULL;
-               }
-
-       mutex_destroy(&handle->dbgfs_lock);
 }
 
 void hns3_dbg_register_debugfs(const char *debugfs_dir_name)