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

Commit a3854589 authored by Manu Gautam's avatar Manu Gautam
Browse files

usb: gadget: ci13xxx: Cancel pending suspend work before resuming h/w



Composite driver can try to disable pull-up (or disconnect) to carry
out composition switch after bus suspend. There is a possible race in
this scenario between OTG driver trying to suspend hardware and UDC
checking for this state before disabling/enabling pull-up.
Hence, flush OTG driver's suspend work before checking LPM state in UDC.

Change-Id: Id3e6dfda8a41b79678db3388d9d4685a547be9d4
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent c1c58cc4
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -206,6 +206,21 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
	}
}

static bool ci13xxx_cancel_pending_suspend(struct ci13xxx *udc)
{
	struct msm_otg *otg;

	if (udc == NULL)
		return false;

	if (udc->transceiver == NULL)
		return false;

	otg = container_of(udc->transceiver, struct msm_otg, phy);

	return cancel_delayed_work_sync(&otg->suspend_work);
}

static bool ci13xxx_msm_in_lpm(struct ci13xxx *udc)
{
	struct msm_otg *otg;
@@ -258,6 +273,7 @@ static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {
				  CI13XXX_IS_OTG,
	.nz_itc			= 0,
	.notify_event		= ci13xxx_msm_notify_event,
	.cancel_pending_suspend = ci13xxx_cancel_pending_suspend,
	.in_lpm                 = ci13xxx_msm_in_lpm,
	.set_fpr_flag           = ci13xxx_msm_set_fpr_flag,
};
+4 −0
Original line number Diff line number Diff line
@@ -3000,6 +3000,10 @@ static int ci13xxx_exit_lpm(struct ci13xxx *udc, bool allow_sleep)
	if (!udc)
		return -ENODEV;

	/* Make sure phy driver is done with its bus suspend handling */
	if (udc->udc_driver->cancel_pending_suspend && allow_sleep)
		udc->udc_driver->cancel_pending_suspend(udc);

	/* Check if the controller is in low power mode state */
	if (udc->udc_driver->in_lpm &&
	    udc->udc_driver->in_lpm(udc) &&
+1 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ struct ci13xxx_udc_driver {
#define CI13XXX_CONTROLLER_UDC_STARTED_EVENT		6

	void	(*notify_event) (struct ci13xxx *udc, unsigned event);
	bool (*cancel_pending_suspend)(struct ci13xxx *udc);
	bool    (*in_lpm) (struct ci13xxx *udc);
	void    (*set_fpr_flag) (struct ci13xxx *udc);
};