]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
usb: dwc2: host: Protect PCGCTL with lock in dwc2_port_resume()
authorDouglas Anderson <dianders@chromium.org>
Wed, 14 Oct 2015 22:58:27 +0000 (15:58 -0700)
committerFelipe Balbi <balbi@ti.com>
Fri, 16 Oct 2015 19:44:15 +0000 (14:44 -0500)
From code inspection, it appears to be unsafe to do a read-modify-write
of PCGCTL in dwc2_port_resume().  Let's make sure the spinlock is held
around this operation.

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/hcd.c

index af4e4a27126f97ae87b74b06172db282bacafecb..e79baf73c234f58bf3162bb9d52d5efce9bca1ca 100644 (file)
@@ -1500,6 +1500,8 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
        u32 hprt0;
        u32 pcgctl;
 
+       spin_lock_irqsave(&hsotg->lock, flags);
+
        /*
         * If hibernation is supported, Phy clock is already resumed
         * after registers restore.
@@ -1508,10 +1510,11 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
                pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
                pcgctl &= ~PCGCTL_STOPPCLK;
                dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+               spin_unlock_irqrestore(&hsotg->lock, flags);
                usleep_range(20000, 40000);
+               spin_lock_irqsave(&hsotg->lock, flags);
        }
 
-       spin_lock_irqsave(&hsotg->lock, flags);
        hprt0 = dwc2_read_hprt0(hsotg);
        hprt0 |= HPRT0_RES;
        hprt0 &= ~HPRT0_SUSP;