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

Commit fb828043 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qpnp-qg: Fix the possible deadlock during suspend



There is a possible deadlock with two-threads (suspend callback
and sleep_work) are holding/waiting on the same mutex.

Fix this by cancelling the work before the mutex is held by
the suspend callback.

Change-Id: I65882067783100e7b9ecdc1e697b93948945b41b
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 91aa9b06
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4217,7 +4217,6 @@ static int process_suspend(struct qpnp_qg *chip)
		return 0;

	cancel_delayed_work_sync(&chip->ttf->ttf_work);
	cancel_delayed_work_sync(&chip->qg_sleep_exit_work);

	chip->suspend_data = false;

@@ -4384,6 +4383,9 @@ static int qpnp_qg_suspend_noirq(struct device *dev)
	int rc;
	struct qpnp_qg *chip = dev_get_drvdata(dev);

	/* cancel any pending sleep_exit work */
	cancel_delayed_work_sync(&chip->qg_sleep_exit_work);

	mutex_lock(&chip->data_lock);

	rc = process_suspend(chip);