Commit 3b509358 authored by Peter Chen's avatar Peter Chen

ENGR00220341-1 usb: add spin_lock_irqsave protect for pdata->lowpower

pdata->lowpower may be accessed at two drivers together, assumed
the situation that host/device set phy to low power mode but
still not set the flag lowpower, at this time the wakeup occurs, as
the flag lowpower is still not set, the interrupt will be infinite loop
as no one will serve it.

This commit is for MSL code and add protect at wakeup interrupt.
Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
parent dabdd170
......@@ -47,6 +47,20 @@ static void wakeup_clk_gate(struct fsl_usb2_wakeup_platform_data *pdata, bool on
if (pdata->usb_clock_for_pm)
pdata->usb_clock_for_pm(on);
}
static bool phy_in_lowpower_mode(struct fsl_usb2_platform_data *pdata)
{
unsigned long flags;
bool ret = true;
spin_lock_irqsave(&pdata->lock, flags);
if (!pdata->lowpower)
ret = false;
spin_unlock_irqrestore(&pdata->lock, flags);
return ret;
}
static bool usb2_is_in_lowpower(struct wakeup_ctrl *ctrl)
{
......@@ -54,8 +68,8 @@ static bool usb2_is_in_lowpower(struct wakeup_ctrl *ctrl)
struct fsl_usb2_wakeup_platform_data *pdata = ctrl->pdata;
/* all the usb module related the wakeup is in lowpower mode */
for (i = 0; i < 3; i++) {
if (pdata->usb_pdata[i]) {
if (pdata->usb_pdata[i]->phy_lowpower_suspend && !pdata->usb_pdata[i]->lowpower)
if (pdata->usb_pdata[i] && pdata->usb_pdata[i]->phy_lowpower_suspend) {
if (!phy_in_lowpower_mode(pdata->usb_pdata[i]))
return false;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment