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

Commit 81ca96c8 authored by Saket Saurabh's avatar Saket Saurabh
Browse files

phy_msm_usb: Fix crash when switching from peripheral to host mode



When system boots up, USB driver waits using wait_for_completion()
event for the initial VBUS state notification from PMIC.
Once VBUS initial state is reported to USB after PMIC driver
initialization, USB sets the completion variable pmic_vbus_done
to value 1. Later wait_for_completion() event sets the variable
pmic_vbus_done to value 0.

For USB cable disconnect/connect events, PMIC notifies to USB
through msm_otg_set_vbus_state() and USB queues msm_otg_sm_work()
to process the disconnect/connect events. For the crash scenario,
as the variable pmic_vbus_done value is set to zero, hence USB
returns from msm_otg_set_vbus_state() without queuing the
msm_otg_sm_work() due to which USB disconnect event is not processed
and crash happens when USB switching from peripheral to host mode.

Fixing the issue using a static flag init which will be initialized
to false. Once VBUS initial state is reported to USB after PMIC
driver initialization, set the static flag init to true.

CRs-Fixed: 607067
Change-Id: Id229537f9223a031f68b793725021225e13376a7
Signed-off-by: default avatarSaket Saurabh <ssaurabh@codeaurora.org>
parent ddc46d3a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3447,6 +3447,7 @@ static irqreturn_t msm_otg_irq(int irq, void *data)
static void msm_otg_set_vbus_state(int online)
{
	struct msm_otg *motg = the_msm_otg;
	static bool init;

	if (online) {
		pr_debug("PMIC: BSV set\n");
@@ -3463,11 +3464,12 @@ static void msm_otg_set_vbus_state(int online)
		 * completion in UNDEFINED state.  Process
		 * the initial VBUS event in ID_GND state.
		 */
		if (pmic_vbus_init.done)
		if (init)
			return;
	}

	if (!pmic_vbus_init.done) {
	if (!init) {
		init = true;
		complete(&pmic_vbus_init);
		pr_debug("PMIC: BSV init complete\n");
		return;