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

Commit 944d1c17 authored by dpyun's avatar dpyun Committed by Jilai Wang
Browse files

msm: npu: Don't allow ioctl cmds to be interrupted



When the ioctl is interrupted, it is difficult to
predict and handle the firmware state properly from
the kernel. This change is to keep ioctl cmds from
being interrupted.

Change-Id: I1377122d23e4a63438cc7a844aec56f7e8a9b4cf
Signed-off-by: default avatardpyun <dpyun@codeaurora.org>
parent e4d3a647
Loading
Loading
Loading
Loading
+6 −24
Original line number Diff line number Diff line
@@ -1112,7 +1112,7 @@ int32_t npu_host_unmap_buf(struct npu_client *client,
	 * fw is disabled
	 */
	if (host_ctx->fw_error && (host_ctx->fw_state == FW_ENABLED) &&
		!wait_for_completion_interruptible_timeout(
		!wait_for_completion_timeout(
		&host_ctx->fw_deinit_done, NW_CMD_TIMEOUT))
		pr_warn("npu: wait for fw_deinit_done time out\n");

@@ -1483,7 +1483,7 @@ int32_t npu_host_load_network(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&network->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT : NW_CMD_TIMEOUT);
@@ -1493,9 +1493,6 @@ int32_t npu_host_load_network(struct npu_client *client,
		pr_err_ratelimited("NPU_IPC_CMD_LOAD time out\n");
		ret = -ETIMEDOUT;
		goto error_free_network;
	} else if (ret < 0) {
		pr_err("NPU_IPC_CMD_LOAD is interrupted by signal\n");
		goto error_free_network;
	}

	if (network->fw_error) {
@@ -1604,7 +1601,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&network->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT : NW_CMD_TIMEOUT);
@@ -1615,9 +1612,6 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
		pr_err_ratelimited("npu: NPU_IPC_CMD_LOAD time out\n");
		ret = -ETIMEDOUT;
		goto error_free_network;
	} else if (ret < 0) {
		pr_err("NPU_IPC_CMD_LOAD_V2 is interrupted by signal\n");
		goto error_free_network;
	}

	if (network->fw_error) {
@@ -1712,7 +1706,7 @@ int32_t npu_host_unload_network(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&network->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT : NW_CMD_TIMEOUT);
@@ -1724,10 +1718,6 @@ int32_t npu_host_unload_network(struct npu_client *client,
		network->cmd_pending = false;
		ret = -ETIMEDOUT;
		goto free_network;
	} else if (ret < 0) {
		pr_err("Wait for unload done interrupted by signal\n");
		network->cmd_pending = false;
		goto free_network;
	}

	if (network->fw_error) {
@@ -1850,7 +1840,7 @@ int32_t npu_host_exec_network(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&network->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT : NW_CMD_TIMEOUT);
@@ -1863,10 +1853,6 @@ int32_t npu_host_exec_network(struct npu_client *client,
		network->cmd_pending = false;
		ret = -ETIMEDOUT;
		goto exec_done;
	} else if (ret == -ERESTARTSYS) {
		pr_err("Wait for execution done interrupted by signal\n");
		network->cmd_pending = false;
		goto exec_done;
	}

	if (network->fw_error) {
@@ -1993,7 +1979,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

	ret = wait_for_completion_interruptible_timeout(
	ret = wait_for_completion_timeout(
		&network->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT : NW_CMD_TIMEOUT);
@@ -2006,10 +1992,6 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,
		network->cmd_pending = false;
		ret = -ETIMEDOUT;
		goto free_exec_packet;
	} else if (ret == -ERESTARTSYS) {
		pr_err("Wait for execution_v2 done interrupted by signal\n");
		network->cmd_pending = false;
		goto free_exec_packet;
	}

	if (network->fw_error) {