mirror of
https://github.com/revyos/thead-kernel.git
synced 2026-09-18 21:32:16 +02:00
sync: npu: ax3386 sdk 1.3.3
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
This commit is contained in:
committed by
Han Gao/Revy/Rabenda
parent
3eee2bf4d2
commit
bcb9ecc2c3
@@ -89,14 +89,14 @@ static ssize_t vha_read(struct file *file, char __user *buf,
|
|||||||
mutex_unlock(&vha->lock);
|
mutex_unlock(&vha->lock);
|
||||||
|
|
||||||
if (file->f_flags & O_NONBLOCK) {
|
if (file->f_flags & O_NONBLOCK) {
|
||||||
dev_dbg(miscdev->this_device,
|
dev_err(miscdev->this_device,
|
||||||
"%s: returning, no block!\n", __func__);
|
"%s: returning, no block!\n", __func__);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
dev_dbg(miscdev->this_device, "%s: going to sleep\n", __func__);
|
dev_dbg(miscdev->this_device, "%s: going to sleep\n", __func__);
|
||||||
if (wait_event_interruptible(session->wq,
|
if (wait_event_interruptible(session->wq,
|
||||||
!list_empty(&session->rsps))) {
|
!list_empty(&session->rsps))) {
|
||||||
dev_dbg(miscdev->this_device, "%s: signal\n", __func__);
|
dev_err(miscdev->this_device, "%s: signal\n", __func__);
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +109,7 @@ static ssize_t vha_read(struct file *file, char __user *buf,
|
|||||||
|
|
||||||
if (list_empty(&session->rsps)) {
|
if (list_empty(&session->rsps)) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
dev_err(miscdev->this_device, "%s: empty rsps!\n", __func__);
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,10 +126,15 @@ static ssize_t vha_read(struct file *file, char __user *buf,
|
|||||||
ret = copy_to_user(buf, &rsp->user_rsp, rsp->size);
|
ret = copy_to_user(buf, &rsp->user_rsp, rsp->size);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
|
dev_err(miscdev->this_device, "%s: copy to user failed!\n", __func__);
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_del(&rsp->list);
|
list_del(&rsp->list);
|
||||||
|
|
||||||
|
vha->stats.cnn_responsed++;
|
||||||
|
session->responsed++;
|
||||||
|
|
||||||
mutex_unlock(&vha->lock);
|
mutex_unlock(&vha->lock);
|
||||||
ret = rsp->size;
|
ret = rsp->size;
|
||||||
|
|
||||||
@@ -200,6 +206,9 @@ static unsigned int vha_poll(struct file *file, poll_table *wait)
|
|||||||
/* if no response item available just return 0 */
|
/* if no response item available just return 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vha->stats.cnn_polled++;
|
||||||
|
session->polled++;
|
||||||
|
|
||||||
mutex_unlock(&vha->lock);
|
mutex_unlock(&vha->lock);
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
@@ -250,8 +259,10 @@ static ssize_t vha_write(struct file *file, const char __user *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd = kzalloc(sizeof(*cmd) - sizeof(cmd->user_cmd) + size, GFP_KERNEL);
|
cmd = kzalloc(sizeof(*cmd) - sizeof(cmd->user_cmd) + size, GFP_KERNEL);
|
||||||
if (!cmd)
|
if (!cmd) {
|
||||||
|
dev_err(miscdev->this_device, "%s: kzalloc failed!\n", __func__);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
cmd->size = size;
|
cmd->size = size;
|
||||||
cmd->session = session;
|
cmd->session = session;
|
||||||
@@ -266,9 +277,14 @@ static ssize_t vha_write(struct file *file, const char __user *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = mutex_lock_interruptible(&vha->lock);
|
ret = mutex_lock_interruptible(&vha->lock);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
dev_err(miscdev->this_device, "%s: mutex lock failed <0x%x>!\n",
|
||||||
|
__func__, ret);
|
||||||
goto out_free_item;
|
goto out_free_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
vha->stats.cnn_add_cmds++;
|
||||||
|
session->kicks++;
|
||||||
ret = vha_add_cmd(session, cmd);
|
ret = vha_add_cmd(session, cmd);
|
||||||
mutex_unlock(&vha->lock);
|
mutex_unlock(&vha->lock);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|||||||
@@ -361,17 +361,23 @@ struct vha_stats {
|
|||||||
/* Latest processing time of the core (CNN) */
|
/* Latest processing time of the core (CNN) */
|
||||||
uint64_t last_proc_us;
|
uint64_t last_proc_us;
|
||||||
/* Total number of hw kicks for which a failure has been detected */
|
/* Total number of hw kicks for which a failure has been detected */
|
||||||
uint32_t total_failures;
|
uint64_t total_failures;
|
||||||
|
/* Total cnn add cmds */
|
||||||
|
uint64_t cnn_add_cmds;
|
||||||
|
/* Total cnn polled cmds */
|
||||||
|
uint64_t cnn_polled;
|
||||||
|
/* Total cnn responsed cmds */
|
||||||
|
uint64_t cnn_responsed;
|
||||||
/* Total cnn kicks */
|
/* Total cnn kicks */
|
||||||
uint32_t cnn_kicks;
|
uint64_t cnn_kicks;
|
||||||
/* Total cnn kicks that were queued */
|
/* Total cnn kicks that were queued */
|
||||||
uint32_t cnn_kicks_queued;
|
uint64_t cnn_kicks_queued;
|
||||||
/* Total cnn kicks that were completed */
|
/* Total cnn kicks that were completed */
|
||||||
uint32_t cnn_kicks_completed;
|
uint64_t cnn_kicks_completed;
|
||||||
/* Total cnn kicks that were cancelled */
|
/* Total cnn kicks that were cancelled */
|
||||||
uint32_t cnn_kicks_cancelled;
|
uint64_t cnn_kicks_cancelled;
|
||||||
/* Total cnn kicks that were interrupted during processing */
|
/* Total cnn kicks that were interrupted during processing */
|
||||||
uint32_t cnn_kicks_aborted;
|
uint64_t cnn_kicks_aborted;
|
||||||
/* CNN total processing time */
|
/* CNN total processing time */
|
||||||
uint64_t cnn_total_proc_us;
|
uint64_t cnn_total_proc_us;
|
||||||
/* CNN last processing time */
|
/* CNN last processing time */
|
||||||
@@ -750,6 +756,9 @@ struct vha_session {
|
|||||||
for device buffers allocated in the kernel */
|
for device buffers allocated in the kernel */
|
||||||
struct dentry *dbgfs; /* file in debugfs */
|
struct dentry *dbgfs; /* file in debugfs */
|
||||||
struct cnn_dbg cnn_dbg;
|
struct cnn_dbg cnn_dbg;
|
||||||
|
uint64_t kicks;
|
||||||
|
uint64_t polled;
|
||||||
|
uint64_t responsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pdump cache info structure used for LDB commands */
|
/* pdump cache info structure used for LDB commands */
|
||||||
|
|||||||
@@ -740,6 +740,10 @@ int vha_dbg_create_hwbufs(struct vha_session *session)
|
|||||||
dev_warn(vha->dev,
|
dev_warn(vha->dev,
|
||||||
"%s: failed to create buffer_dump!\n",
|
"%s: failed to create buffer_dump!\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
||||||
|
debugfs_create_u64("sess_kicks", S_IRUGO, session->dbgfs, &session->kicks);
|
||||||
|
debugfs_create_u64("sess_polled", S_IRUGO, session->dbgfs, &session->polled);
|
||||||
|
debugfs_create_u64("sess_responsed", S_IRUGO, session->dbgfs, &session->responsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1778,11 +1782,14 @@ void vha_dbg_init(struct vha_dev *vha)
|
|||||||
#ifndef CONFIG_HW_MULTICORE
|
#ifndef CONFIG_HW_MULTICORE
|
||||||
VHA_DBGFS_CREATE_RO(u64, "core_last_proc_us", stats.last_proc_us, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "core_last_proc_us", stats.last_proc_us, debugfs_dir);
|
||||||
#endif
|
#endif
|
||||||
VHA_DBGFS_CREATE_RO(u32, "cnn_kicks", stats.cnn_kicks, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_add_cmds", stats.cnn_add_cmds, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "cnn_kicks_queued", stats.cnn_kicks_queued, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_kicks", stats.cnn_kicks, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "cnn_kicks_completed", stats.cnn_kicks_completed, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_polled", stats.cnn_polled, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "cnn_kicks_cancelled", stats.cnn_kicks_cancelled, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_responsed", stats.cnn_responsed, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "cnn_kicks_aborted", stats.cnn_kicks_aborted, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_kicks_queued", stats.cnn_kicks_queued, debugfs_dir);
|
||||||
|
VHA_DBGFS_CREATE_RO(u64, "cnn_kicks_completed", stats.cnn_kicks_completed, debugfs_dir);
|
||||||
|
VHA_DBGFS_CREATE_RO(u64, "cnn_kicks_cancelled", stats.cnn_kicks_cancelled, debugfs_dir);
|
||||||
|
VHA_DBGFS_CREATE_RO(u64, "cnn_kicks_aborted", stats.cnn_kicks_aborted, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u64, "cnn_total_proc_us", stats.cnn_total_proc_us, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_total_proc_us", stats.cnn_total_proc_us, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u64, "cnn_last_proc_us", stats.cnn_last_proc_us, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_last_proc_us", stats.cnn_last_proc_us, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u64, "cnn_avg_proc_us", stats.cnn_avg_proc_us, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "cnn_avg_proc_us", stats.cnn_avg_proc_us, debugfs_dir);
|
||||||
@@ -1797,7 +1804,7 @@ void vha_dbg_init(struct vha_dev *vha)
|
|||||||
|
|
||||||
VHA_DBGFS_CREATE_RO(u32, "mem_usage_last", stats.mem_usage_last, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u32, "mem_usage_last", stats.mem_usage_last, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "mmu_usage_last", stats.mmu_usage_last, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u32, "mmu_usage_last", stats.mmu_usage_last, debugfs_dir);
|
||||||
VHA_DBGFS_CREATE_RO(u32, "total_failures", stats.total_failures, debugfs_dir);
|
VHA_DBGFS_CREATE_RO(u64, "total_failures", stats.total_failures, debugfs_dir);
|
||||||
|
|
||||||
if (vha->hw_props.supported.rtm) {
|
if (vha->hw_props.supported.rtm) {
|
||||||
CTX_DBGFS_CREATE_RW(u64, "rtm_ctrl", rtm_ctrl, debugfs_dir);
|
CTX_DBGFS_CREATE_RW(u64, "rtm_ctrl", rtm_ctrl, debugfs_dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user