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

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

msm: npu: Set npu bandwidth during power on/off



Minimum bandwidth needs to be requested before turning on npu
clocks. And it needs to be cleared when turning off npu clocks.
This change is to move the bandwidth setting to power on/off
functions.

Change-Id: Ifa98587cde6423955c0a907169e24da8a17a774e
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent fe96ce17
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -347,8 +347,15 @@ int npu_enable_core_power(struct npu_device *npu_dev)
		if (ret)
		if (ret)
			return ret;
			return ret;


		ret = npu_set_bw(npu_dev, 100, 100);
		if (ret) {
			npu_disable_regulators(npu_dev);
			return ret;
		}

		ret = npu_enable_core_clocks(npu_dev);
		ret = npu_enable_core_clocks(npu_dev);
		if (ret) {
		if (ret) {
			npu_set_bw(npu_dev, 0, 0);
			npu_disable_regulators(npu_dev);
			npu_disable_regulators(npu_dev);
			pwr->pwr_vote_num = 0;
			pwr->pwr_vote_num = 0;
			return ret;
			return ret;
@@ -368,6 +375,7 @@ void npu_disable_core_power(struct npu_device *npu_dev)
	pwr->pwr_vote_num--;
	pwr->pwr_vote_num--;
	if (!pwr->pwr_vote_num) {
	if (!pwr->pwr_vote_num) {
		npu_disable_core_clocks(npu_dev);
		npu_disable_core_clocks(npu_dev);
		npu_set_bw(npu_dev, 0, 0);
		npu_disable_regulators(npu_dev);
		npu_disable_regulators(npu_dev);
		pwr->active_pwrlevel = pwr->default_pwrlevel;
		pwr->active_pwrlevel = pwr->default_pwrlevel;
		pwr->uc_pwrlevel = pwr->max_pwrlevel;
		pwr->uc_pwrlevel = pwr->max_pwrlevel;
@@ -2079,7 +2087,6 @@ static int npu_hw_info_init(struct npu_device *npu_dev)
{
{
	int rc = 0;
	int rc = 0;


	npu_set_bw(npu_dev, 100, 100);
	rc = npu_enable_core_power(npu_dev);
	rc = npu_enable_core_power(npu_dev);
	if (rc) {
	if (rc) {
		NPU_ERR("Failed to enable power\n");
		NPU_ERR("Failed to enable power\n");
@@ -2089,7 +2096,6 @@ static int npu_hw_info_init(struct npu_device *npu_dev)
	npu_dev->hw_version = REGR(npu_dev, NPU_HW_VERSION);
	npu_dev->hw_version = REGR(npu_dev, NPU_HW_VERSION);
	NPU_DBG("NPU_HW_VERSION 0x%x\n", npu_dev->hw_version);
	NPU_DBG("NPU_HW_VERSION 0x%x\n", npu_dev->hw_version);
	npu_disable_core_power(npu_dev);
	npu_disable_core_power(npu_dev);
	npu_set_bw(npu_dev, 0, 0);


	return rc;
	return rc;
}
}
+2 −11
Original line number Original line Diff line number Diff line
@@ -79,12 +79,6 @@ static int load_fw_nolock(struct npu_device *npu_dev, bool enable)
		return 0;
		return 0;
	}
	}


	ret = npu_set_bw(npu_dev, 100, 100);
	if (ret) {
		NPU_ERR("Vote bandwidth failed\n");
		return ret;
	}

	/* Boot the NPU subsystem */
	/* Boot the NPU subsystem */
	reinit_completion(&host_ctx->npu_power_up_done);
	reinit_completion(&host_ctx->npu_power_up_done);
	host_ctx->subsystem_handle = subsystem_get_local("npu");
	host_ctx->subsystem_handle = subsystem_get_local("npu");
@@ -155,10 +149,9 @@ static int load_fw_nolock(struct npu_device *npu_dev, bool enable)
	if (!ret) {
	if (!ret) {
		host_ctx->fw_state = FW_LOADED;
		host_ctx->fw_state = FW_LOADED;
	} else {
	} else {
		if (!IS_ERR_OR_NULL(host_ctx->subsystem_handle)) {
		if (!IS_ERR_OR_NULL(host_ctx->subsystem_handle))
			subsystem_put_local(host_ctx->subsystem_handle);
			subsystem_put_local(host_ctx->subsystem_handle);
			npu_set_bw(npu_dev, 0, 0);

		}
		host_ctx->fw_state = FW_UNLOADED;
		host_ctx->fw_state = FW_UNLOADED;
	}
	}


@@ -218,7 +211,6 @@ int unload_fw(struct npu_device *npu_dev)
	}
	}


	subsystem_put_local(host_ctx->subsystem_handle);
	subsystem_put_local(host_ctx->subsystem_handle);
	npu_set_bw(npu_dev, 0, 0);
	host_ctx->fw_state = FW_UNLOADED;
	host_ctx->fw_state = FW_UNLOADED;
	NPU_DBG("fw is unloaded\n");
	NPU_DBG("fw is unloaded\n");
	mutex_unlock(&host_ctx->lock);
	mutex_unlock(&host_ctx->lock);
@@ -384,7 +376,6 @@ static void disable_fw_nolock(struct npu_device *npu_dev)
		subsystem_put_local(host_ctx->subsystem_handle);
		subsystem_put_local(host_ctx->subsystem_handle);
		host_ctx->fw_state = FW_UNLOADED;
		host_ctx->fw_state = FW_UNLOADED;
		NPU_DBG("fw is unloaded\n");
		NPU_DBG("fw is unloaded\n");
		npu_set_bw(npu_dev, 0, 0);
	}
	}
}
}