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

Commit 81671c6b authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: npu: Fix race condition issue during npu power contrl"

parents b40e13d5 60141e21
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -501,6 +501,7 @@ int npu_enable_core_power(struct npu_device *npu_dev)
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;
	int ret = 0;
	int ret = 0;


	mutex_lock(&npu_dev->dev_lock);
	if (!pwr->pwr_vote_num) {
	if (!pwr->pwr_vote_num) {
		ret = npu_enable_regulators(npu_dev);
		ret = npu_enable_regulators(npu_dev);
		if (ret)
		if (ret)
@@ -515,6 +516,7 @@ int npu_enable_core_power(struct npu_device *npu_dev)
		npu_resume_devbw(npu_dev);
		npu_resume_devbw(npu_dev);
	}
	}
	pwr->pwr_vote_num++;
	pwr->pwr_vote_num++;
	mutex_unlock(&npu_dev->dev_lock);


	return ret;
	return ret;
}
}
@@ -524,8 +526,12 @@ void npu_disable_core_power(struct npu_device *npu_dev)
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;
	struct npu_thermalctrl *thermalctrl = &npu_dev->thermalctrl;
	struct npu_thermalctrl *thermalctrl = &npu_dev->thermalctrl;


	if (!pwr->pwr_vote_num)
	mutex_lock(&npu_dev->dev_lock);
	if (!pwr->pwr_vote_num) {
		mutex_unlock(&npu_dev->dev_lock);
		return;
		return;
	}

	pwr->pwr_vote_num--;
	pwr->pwr_vote_num--;
	if (!pwr->pwr_vote_num) {
	if (!pwr->pwr_vote_num) {
		npu_suspend_devbw(npu_dev);
		npu_suspend_devbw(npu_dev);
@@ -537,6 +543,7 @@ void npu_disable_core_power(struct npu_device *npu_dev)
		pr_debug("setting back to power level=%d\n",
		pr_debug("setting back to power level=%d\n",
			pwr->active_pwrlevel);
			pwr->active_pwrlevel);
	}
	}
	mutex_unlock(&npu_dev->dev_lock);
}
}


static int npu_enable_core_clocks(struct npu_device *npu_dev)
static int npu_enable_core_clocks(struct npu_device *npu_dev)