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

Commit 2272f29a authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu: Retry to read IPC queue if network commands times out



It is possbile that there is content available in IPC queue while
network command times out. Read the IPC queue again to avoid this
case.

Change-Id: I2e5844ef93cdbc59c87c3124301f21f780be7163
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent 2c53b898
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -2237,7 +2237,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
			struct msm_npu_load_network_ioctl_v2 *load_ioctl,
			struct msm_npu_patch_info_v2 *patch_info)
{
	int ret = 0, i;
	int ret = 0, retry_cnt = 1, i;
	struct npu_device *npu_dev = client->npu_dev;
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;
	struct npu_network *network;
@@ -2330,6 +2330,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&load_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2346,6 +2347,14 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n",
			network->id, load_cmd->trans_id);
		if (retry_cnt > 0) {
			NPU_WARN("Retry IPC queue\n");
			retry_cnt--;
			mutex_unlock(&host_ctx->lock);
			host_session_msg_hdlr(npu_dev);
			goto retry;
		}

		ret = -ETIMEDOUT;
		goto free_load_cmd;
	}
@@ -2392,7 +2401,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
int32_t npu_host_unload_network(struct npu_client *client,
			struct msm_npu_unload_network_ioctl *unload)
{
	int ret = 0;
	int ret = 0, retry_cnt = 1;
	struct npu_device *npu_dev = client->npu_dev;
	struct ipc_cmd_unload_pkt unload_packet;
	struct npu_network *network;
@@ -2465,6 +2474,7 @@ int32_t npu_host_unload_network(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&unload_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2481,6 +2491,14 @@ int32_t npu_host_unload_network(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n",
			network->id, unload_cmd->trans_id);
		if (retry_cnt > 0) {
			NPU_WARN("Retry IPC queue\n");
			retry_cnt--;
			mutex_unlock(&host_ctx->lock);
			host_session_msg_hdlr(npu_dev);
			goto retry;
		}

		ret = -ETIMEDOUT;
		goto free_unload_cmd;
	}
@@ -2531,7 +2549,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
	uint32_t num_patch_params, pkt_size;
	bool async_ioctl = !!exec_ioctl->async;
	int i;
	int i, retry_cnt = 1;

	mutex_lock(&host_ctx->lock);
	network = get_network_by_hdl(host_ctx, client,
@@ -2631,6 +2649,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&exec_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2646,6 +2665,14 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n",
			network->id, exec_cmd->trans_id);
		if (retry_cnt > 0) {
			NPU_WARN("Retry IPC queue\n");
			retry_cnt--;
			mutex_unlock(&host_ctx->lock);
			host_session_msg_hdlr(npu_dev);
			goto retry;
		}

		ret = -ETIMEDOUT;
		goto free_exec_packet;
	}