From: Peter Chen Date: Tue, 14 Aug 2012 07:16:49 +0000 (+0800) Subject: ENGR00220341-1 usb: add spin_lock_irqsave protect for pdata->lowpower X-Git-Tag: v3.0.35-fsl~596 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5b8fcb41dfa16445584d2766331fc004a379dc90;p=karo-tx-linux.git 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: Peter Chen --- diff --git a/arch/arm/plat-mxc/usb_wakeup.c b/arch/arm/plat-mxc/usb_wakeup.c index e67c2219e52d..5d31d3621205 100755 --- a/arch/arm/plat-mxc/usb_wakeup.c +++ b/arch/arm/plat-mxc/usb_wakeup.c @@ -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; } }