Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01e8472e authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu: Support multiple execution_network commands per network



This change is to allow application to submit multiple
execution_network commands for the same network concurrently to
NPU fw in order to fully utilize NPU's processing power.

Change-Id: Ide5293d8a779ff17038169db2a3b1c862c453296
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent 3d59a859
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -336,5 +336,6 @@ 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 */
+5 −23
Original line number Diff line number Diff line
@@ -1319,28 +1319,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)
{
@@ -1356,7 +1334,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) {
@@ -1483,6 +1461,10 @@ static int npu_get_property(struct npu_client *client,

		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) {
+342 −111

File changed.

Preview size limit exceeded, changes collapsed.

+19 −8
Original line number Diff line number Diff line
@@ -36,6 +36,21 @@
 * 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_network {
	uint64_t id;
	int buf_hdl;
@@ -47,19 +62,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 {
@@ -92,6 +101,8 @@ struct npu_host_ctx {
	void *prop_buf;
	int32_t network_num;
	struct npu_network networks[MAX_LOADED_NETWORK];
	struct kmem_cache *network_cmd_cache;
	struct kmem_cache *stats_buf_cache;
	bool sys_cache_disable;
	bool auto_pil_disable;
	uint32_t fw_dbg_mode;
+4 −0

File changed.

Preview size limit exceeded, changes collapsed.