]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00220341-1 usb: add spin_lock_irqsave protect for pdata->lowpower
authorPeter Chen <peter.chen@freescale.com>
Tue, 14 Aug 2012 07:16:49 +0000 (15:16 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:14 +0000 (08:35 +0200)
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 <peter.chen@freescale.com>
arch/arm/plat-mxc/usb_wakeup.c

index e67c2219e52d4236d8540a914fd9833238f9c3fe..5d31d3621205273d43411de67ae72fb5a6d0017d 100755 (executable)
@@ -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;
                }
        }