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

Commit 0e321cd5 authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu : Disable npu clocks before unloading fw



NPU clocks need to be disabled before unloading fw via PIL.
And the clock rate needs to be set to 0 before disabling.

Change-Id: I08d910a0af8872ac26be7048e3bbd7c695ba538c
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent 33de79e1
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ static int npu_enable_clocks(struct npu_device *npu_dev, bool post_pil)

static void npu_disable_clocks(struct npu_device *npu_dev, bool post_pil)
{
	int i = 0;
	int i, rc = 0;
	struct npu_clk *core_clks = npu_dev->core_clks;

	for (i = npu_dev->core_clk_num - 1; i >= 0 ; i--) {
@@ -598,6 +598,18 @@ static void npu_disable_clocks(struct npu_device *npu_dev, bool post_pil)
				continue;
		}

		/* set clock rate to 0 before disabling it */
		if (!npu_is_exclude_rate_clock(core_clks[i].clk_name)) {
			pr_debug("setting rate of clock %s to 0\n",
				core_clks[i].clk_name);

			rc = clk_set_rate(core_clks[i].clk, 0);
			if (rc) {
				pr_err("clk_set_rate %s to 0 failed\n",
					core_clks[i].clk_name);
			}
		}

		pr_debug("disabling clock %s\n", core_clks[i].clk_name);
		clk_disable_unprepare(core_clks[i].clk);
	}
+6 −4
Original line number Diff line number Diff line
@@ -170,11 +170,12 @@ int fw_init(struct npu_device *npu_dev)
wait_fw_ready_fail:
	npu_disable_post_pil_clocks(npu_dev);
enable_post_clk_fail:
	subsystem_put_local(host_ctx->subsystem_handle);
subsystem_get_fail:
	npu_disable_sys_cache(npu_dev);
enable_sys_cache_fail:
	npu_disable_sys_cache(npu_dev);
	npu_disable_core_power(npu_dev);
	if (!IS_ERR(host_ctx->subsystem_handle))
		subsystem_put_local(host_ctx->subsystem_handle);
enable_pw_fail:
	host_ctx->fw_state = FW_DISABLED;
	mutex_unlock(&host_ctx->lock);
@@ -236,8 +237,6 @@ void fw_deinit(struct npu_device *npu_dev, bool ssr, bool fw_alive)

	npu_disable_post_pil_clocks(npu_dev);
	npu_disable_sys_cache(npu_dev);
	subsystem_put_local(host_ctx->subsystem_handle);
	host_ctx->fw_state = FW_DISABLED;

	/*
	 * if fw is still alive, notify dsp before power off
@@ -251,6 +250,9 @@ void fw_deinit(struct npu_device *npu_dev, bool ssr, bool fw_alive)

	npu_disable_core_power(npu_dev);

	subsystem_put_local(host_ctx->subsystem_handle);
	host_ctx->fw_state = FW_DISABLED;

	if (ssr) {
		/* mark all existing network to error state */
		for (i = 0; i < MAX_LOADED_NETWORK; i++) {