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

Commit 18b8f133 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3_otg: Increment dwc3 PM usage count unconditionally



Commit b402fb7d9721f ("usb: dwc3-msm: Ignore multiple VBUS
notifications") increments dwc3 PM usage count only if usage
count is zero on receiving DWC3_EVENT_PHY_RESUME event.
dwc3_gadget_start() also increments and decrements PM usage
count which happens only when android gadget is binded with
UDC driver (happens only once at bootup time). With USB cable
connect case, sometime race condition is happening where
dwc3_gadget_start() has incremented usage count and notification
for DWC3_EVENT_PHY_RESUME is being received due to vbus event
before dwc3_gaget_start() has decremented usage count. Due to
this condition USB controller is going into Low Power mode which
results into no USB enumeration with connected host. Fix this
issue by incrementing dwc3 PM usage count unconditionally.

Change-Id: I07f1aadc117651e14c9a894ddcb3fd6dc9aeae40
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 28bbe02e
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
/**
 * dwc3_otg.c - DesignWare USB3 DRD Controller OTG
 *
 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2015, 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
@@ -364,8 +364,8 @@ static void dwc3_ext_event_notify(struct usb_otg *otg,
		flush_delayed_work(&dotg->sm_work);

	if (event == DWC3_EVENT_PHY_RESUME) {
		if (pm_runtime_status_suspended(phy->dev) ||
			atomic_read(&phy->dev->power.usage_count) == 0) {
		if (!pm_runtime_status_suspended(phy->dev))
			dev_warn(phy->dev, "PHY_RESUME event out of LPM!!!!\n");

		dev_dbg(phy->dev, "ext PHY_RESUME event received\n");
		/* ext_xceiver would have taken h/w out of LPM by now */
@@ -380,9 +380,6 @@ static void dwc3_ext_event_notify(struct usb_otg *otg,
		} else if (ret < 0) {
			dev_warn(phy->dev, "pm_runtime_get failed!\n");
		}
		} else {
			dev_warn(phy->dev, "PHY_RESUME event out of LPM!!!!\n");
		}
	} else if (event == DWC3_EVENT_XCEIV_STATE) {
		if (pm_runtime_status_suspended(phy->dev) ||
			atomic_read(&phy->dev->power.usage_count) == 0) {