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

Commit 60141e21 authored by Jilai Wang's avatar Jilai Wang Committed by Gerrit - the friendly Code Review server
Browse files

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



This chaneg is to fix race condition issue when enable/disable
npu power.

Change-Id: Ic24d81e448beee236bcd3a1fc5c93705925a6731
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent 7be9a22c
Loading
Loading
Loading
Loading
+9 −2
Original line number 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
 * 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;
	int ret = 0;

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

	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_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;
	}

	pwr->pwr_vote_num--;
	if (!pwr->pwr_vote_num) {
		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",
			pwr->active_pwrlevel);
	}
	mutex_unlock(&npu_dev->dev_lock);
}

static int npu_enable_core_clocks(struct npu_device *npu_dev)