msm: npu: Support multiple commands concurrently

This change is to allow multiple commands to be sent to fw
concurrently. It will get ipc queue info via get_property api
and utilize NPU fully allowing application to execute multiple
commands per network.

Change-Id: Ice8e5d00b1adb434193486cf01a649a7e6904988
Signed-off-by: Da Hoon Pyun <dpyun@codeaurora.org>
This commit is contained in:
Da Hoon Pyun 2019-11-28 15:13:39 -05:00 committed by Gerrit - the friendly Code Review server
parent 2ba5ea332f
commit 239568f997
6 changed files with 607 additions and 211 deletions

View File

@ -343,5 +343,5 @@ void disable_fw(struct npu_device *npu_dev);
int load_fw(struct npu_device *npu_dev);
int unload_fw(struct npu_device *npu_dev);
int npu_set_bw(struct npu_device *npu_dev, int new_ib, int new_ab);
int npu_process_kevent(struct npu_client *client, struct npu_kevent *kevt);
#endif /* _NPU_COMMON_H */

View File

@ -1327,28 +1327,6 @@ static int npu_exec_network_v2(struct npu_client *client,
return ret;
}
static int npu_process_kevent(struct npu_kevent *kevt)
{
int ret = 0;
switch (kevt->evt.type) {
case MSM_NPU_EVENT_TYPE_EXEC_V2_DONE:
ret = copy_to_user((void __user *)kevt->reserved[1],
(void *)&kevt->reserved[0],
kevt->evt.u.exec_v2_done.stats_buf_size);
if (ret) {
NPU_ERR("fail to copy to user\n");
kevt->evt.u.exec_v2_done.stats_buf_size = 0;
ret = -EFAULT;
}
break;
default:
break;
}
return ret;
}
static int npu_receive_event(struct npu_client *client,
unsigned long arg)
{
@ -1364,7 +1342,7 @@ static int npu_receive_event(struct npu_client *client,
kevt = list_first_entry(&client->evt_list,
struct npu_kevent, list);
list_del(&kevt->list);
npu_process_kevent(kevt);
npu_process_kevent(client, kevt);
ret = copy_to_user(argp, &kevt->evt,
sizeof(struct msm_npu_event));
if (ret) {
@ -1480,6 +1458,21 @@ static int npu_get_property(struct npu_client *client,
case MSM_NPU_PROP_ID_HARDWARE_VERSION:
prop.prop_param[0] = npu_dev->hw_version;
break;
case MSM_NPU_PROP_ID_IPC_QUEUE_INFO:
ret = npu_host_get_ipc_queue_size(npu_dev,
prop.prop_param[0]);
if (ret < 0) {
NPU_ERR("Can't get ipc queue %d size\n",
prop.prop_param[0]);
return ret;
}
prop.prop_param[1] = ret;
break;
case MSM_NPU_PROP_ID_DRV_FEATURE:
prop.prop_param[0] = MSM_NPU_FEATURE_MULTI_EXECUTE |
MSM_NPU_FEATURE_ASYNC_EXECUTE;
break;
default:
ret = npu_host_get_fw_property(client->npu_dev, &prop);
if (ret) {

View File

@ -418,3 +418,13 @@ int npu_host_ipc_post_init(struct npu_device *npu_dev)
{
return 0;
}
int npu_host_get_ipc_queue_size(struct npu_device *npu_dev, uint32_t q_idx)
{
if (q_idx >= ARRAY_SIZE(npu_q_setup)) {
NPU_ERR("Invalid ipc queue index %d\n", q_idx);
return -EINVAL;
}
return npu_q_setup[q_idx].size;
}

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,33 @@
* Data Structures
* -------------------------------------------------------------------------
*/
struct npu_network_cmd {
struct list_head list;
uint32_t cmd_type;
uint32_t cmd_id;
uint32_t trans_id;
bool async;
struct completion cmd_done;
/* stats buf info */
uint32_t stats_buf_size;
void __user *stats_buf_u;
void *stats_buf;
int ret_status;
};
struct npu_misc_cmd {
struct list_head list;
uint32_t cmd_type;
uint32_t trans_id;
union {
struct msm_npu_property prop;
uint32_t data[32];
} u;
struct completion cmd_done;
int ret_status;
};
struct npu_network {
uint64_t id;
int buf_hdl;
@ -54,19 +81,13 @@ struct npu_network {
uint32_t cur_perf_mode;
uint32_t init_perf_mode;
uint32_t num_layers;
void *stats_buf;
void __user *stats_buf_u;
uint32_t stats_buf_size;
uint32_t trans_id;
atomic_t ref_cnt;
bool is_valid;
bool is_active;
bool fw_error;
bool cmd_pending;
bool cmd_async;
int cmd_ret_status;
struct completion cmd_done;
bool is_async;
struct npu_client *client;
struct list_head cmd_list;
};
enum fw_state {
@ -91,14 +112,15 @@ struct npu_host_ctx {
struct delayed_work disable_fw_work;
struct workqueue_struct *wq;
struct workqueue_struct *wq_pri;
struct completion misc_cmd_done;
struct completion fw_deinit_done;
struct completion fw_bringup_done;
struct completion fw_shutdown_done;
struct completion npu_power_up_done;
void *prop_buf;
int32_t network_num;
struct npu_network networks[MAX_LOADED_NETWORK];
struct kmem_cache *network_cmd_cache;
struct kmem_cache *misc_cmd_cache;
struct kmem_cache *stats_buf_cache;
bool sys_cache_disable;
bool auto_pil_disable;
uint32_t fw_dbg_mode;
@ -110,13 +132,12 @@ struct npu_host_ctx {
uint32_t wdg_irq_sts;
bool fw_error;
bool cancel_work;
bool misc_cmd_pending;
uint32_t misc_cmd_result;
struct notifier_block nb;
void *notif_hdle;
spinlock_t bridge_mbox_lock;
bool bridge_mbox_pwr_on;
void *ipc_msg_buf;
struct list_head misc_cmd_list;
};
struct npu_device;
@ -136,6 +157,7 @@ int npu_host_ipc_send_cmd(struct npu_device *npu_dev, uint32_t queueIndex,
void *pCmd);
int npu_host_ipc_read_msg(struct npu_device *npu_dev, uint32_t queueIndex,
uint32_t *pMsg);
int npu_host_get_ipc_queue_size(struct npu_device *npu_dev, uint32_t q_idx);
int32_t npu_host_get_info(struct npu_device *npu_dev,
struct msm_npu_get_info_ioctl *get_info_ioctl);

View File

@ -73,6 +73,8 @@
#define MSM_NPU_PROP_ID_PERF_MODE_MAX (MSM_NPU_PROP_ID_START + 2)
#define MSM_NPU_PROP_ID_DRV_VERSION (MSM_NPU_PROP_ID_START + 3)
#define MSM_NPU_PROP_ID_HARDWARE_VERSION (MSM_NPU_PROP_ID_START + 4)
#define MSM_NPU_PROP_ID_IPC_QUEUE_INFO (MSM_NPU_PROP_ID_START + 5)
#define MSM_NPU_PROP_ID_DRV_FEATURE (MSM_NPU_PROP_ID_START + 6)
#define MSM_NPU_FW_PROP_ID_START 0x1000
#define MSM_NPU_PROP_ID_DCVS_MODE (MSM_NPU_FW_PROP_ID_START + 0)
@ -81,6 +83,9 @@
#define MSM_NPU_PROP_ID_HW_VERSION (MSM_NPU_FW_PROP_ID_START + 3)
#define MSM_NPU_PROP_ID_FW_VERSION (MSM_NPU_FW_PROP_ID_START + 4)
/* features supported by driver */
#define MSM_NPU_FEATURE_MULTI_EXECUTE 0x1
#define MSM_NPU_FEATURE_ASYNC_EXECUTE 0x2
#define PROP_PARAM_MAX_SIZE 8