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

Commit 3b2ac271 authored by Sahil Chandna's avatar Sahil Chandna
Browse files

power: qpnp-fg-gen4: cancel soc_scale_work conditionally



In FVSS, there is a possible path from which soc_scale_work
tries to cancel itself with cancel_work_sync and waits for itself
to complete. Fix this deadlock by cancelling soc_scale_work only when
it is not running.

Change-Id: Ie64d60643908cfab7812c3f0e23c7a7b78b6c44d
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent 75f385d8
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -3333,13 +3333,16 @@ static void fg_gen4_exit_soc_scale(struct fg_gen4_chip *chip)

	if (chip->soc_scale_mode) {
		alarm_cancel(&chip->soc_scale_alarm_timer);
		if (work_busy(&chip->soc_scale_work) != WORK_BUSY_RUNNING)
			cancel_work_sync(&chip->soc_scale_work);

		/* While exiting soc_scale_mode, Update MSOC register */
		fg_gen4_write_scale_msoc(chip);
	}

	chip->soc_scale_mode = false;
	fg_dbg(fg, FG_FVSS, "Exit FVSS mode\n");
	fg_dbg(fg, FG_FVSS, "Exit FVSS mode, work_status=%d\n",
				work_busy(&chip->soc_scale_work));
}

static int fg_gen4_validate_soc_scale_mode(struct fg_gen4_chip *chip)
@@ -4055,6 +4058,12 @@ static void soc_scale_work(struct work_struct *work)
	if (rc < 0)
		pr_err("Failed to validate SOC scale mode, rc=%d\n", rc);

	/* re-validate soc scale mode as we may have exited FVSS */
	if (!chip->soc_scale_mode) {
		fg_dbg(fg, FG_FVSS, "exit soc scale mode\n");
		return;
	}

	if (chip->vbatt_res <= 0)
		chip->vbatt_res = 0;