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

Commit a7d0abbf authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu: Adjust timing to send notification to DSP



Notification to dsp that NPU powers off needs to be done when NPU
is alive no matter npu is in ssr state or not. And all dsp
notifications need to be protected to avoid to be sent after NPU
powers off.

Change-Id: I7cd22fa947f2a5c4798f8c31a6961273f00132ec
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent fd8dc2dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ int npu_set_uc_power_level(struct npu_device *npu_dev,
	uint32_t pwr_level);

int fw_init(struct npu_device *npu_dev);
void fw_deinit(struct npu_device *npu_dev, bool ssr);
void fw_deinit(struct npu_device *npu_dev, bool ssr, bool fw_alive);
int npu_notify_cdsprm_cxlimit_activity(struct npu_device *npu_dev, bool enable);

#endif /* _NPU_COMMON_H */
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ static ssize_t npu_debug_ctrl_write(struct file *file,
			pr_info("error in fw_init\n");
	} else if (strcmp(buf, "off") == 0) {
		pr_info("triggering fw_deinit\n");
		fw_deinit(npu_dev, false);
		fw_deinit(npu_dev, false, true);
	} else if (strcmp(buf, "ssr") == 0) {
		pr_info("trigger error irq\n");
		if (npu_enable_core_power(npu_dev))
+11 −11
Original line number Diff line number Diff line
@@ -156,15 +156,15 @@ int fw_init(struct npu_device *npu_dev)
		goto wait_fw_ready_fail;
	}

	npu_notify_dsp(npu_dev, true);
	host_ctx->fw_state = FW_ENABLED;
	host_ctx->fw_error = false;
	host_ctx->fw_ref_cnt++;
	reinit_completion(&host_ctx->fw_deinit_done);

	mutex_unlock(&host_ctx->lock);
	pr_debug("firmware init complete\n");

	npu_notify_dsp(npu_dev, true);

	/* Set logging state */
	if (!npu_hw_log_enabled()) {
		pr_debug("fw logging disabled\n");
@@ -187,7 +187,7 @@ int fw_init(struct npu_device *npu_dev)
	return ret;
}

void fw_deinit(struct npu_device *npu_dev, bool ssr)
void fw_deinit(struct npu_device *npu_dev, bool ssr, bool fw_alive)
{
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
	struct ipc_cmd_shutdown_pkt cmd_shutdown_pkt;
@@ -213,7 +213,7 @@ void fw_deinit(struct npu_device *npu_dev, bool ssr)

	npu_disable_irq(npu_dev);

	if (!ssr) {
	if (fw_alive) {
		/* Command header */
		cmd_shutdown_pkt.header.cmd_type = NPU_IPC_CMD_SHUTDOWN;
		cmd_shutdown_pkt.header.size =
@@ -246,11 +246,11 @@ void fw_deinit(struct npu_device *npu_dev, bool ssr)
	host_ctx->fw_state = FW_DISABLED;

	/*
	 * if it's not in ssr mode, notify dsp before power off
	 * if fw is still alive, notify dsp before power off
	 * otherwise delay 500 ms to make sure dsp has finished
	 * its own ssr handling.
	 */
	if (!ssr)
	if (fw_alive)
		npu_notify_dsp(npu_dev, false);
	else
		msleep(500);
@@ -339,7 +339,7 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force)
	if (host_ctx->wdg_irq_sts)
		pr_info("watchdog irq triggered\n");

	fw_deinit(npu_dev, true);
	fw_deinit(npu_dev, true, force);
	host_ctx->wdg_irq_sts = 0;
	host_ctx->err_irq_sts = 0;

@@ -1169,7 +1169,7 @@ int32_t npu_host_load_network(struct npu_client *client,
	free_network(host_ctx, client, network->id);
err_deinit_fw:
	mutex_unlock(&host_ctx->lock);
	fw_deinit(npu_dev, false);
	fw_deinit(npu_dev, false, true);
	return ret;
}

@@ -1296,7 +1296,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
	free_network(host_ctx, client, network->id);
err_deinit_fw:
	mutex_unlock(&host_ctx->lock);
	fw_deinit(npu_dev, false);
	fw_deinit(npu_dev, false, true);
	return ret;
}

@@ -1400,7 +1400,7 @@ int32_t npu_host_unload_network(struct npu_client *client,
	if (ret)
		pr_err("network unload failed to set power level\n");
	mutex_unlock(&host_ctx->lock);
	fw_deinit(npu_dev, false);
	fw_deinit(npu_dev, false, true);
	return ret;
}

@@ -1733,7 +1733,7 @@ int32_t npu_host_loopback_test(struct npu_device *npu_dev)
	}

loopback_exit:
	fw_deinit(npu_dev, false);
	fw_deinit(npu_dev, false, true);

	return ret;
}