Commit 7b093f77 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Felipe Balbi

usb: dwc2: gadget: fix calls to phy control functions in suspend/resume code

This patch moves calls to phy enable/disable out of spinlock protected
blocks in device suspend/resume to fix incorrect caller context. Phy
related functions must not be called from atomic context. To protect
device internal state from a race during suspend, a call to
s3c_hsotg_core_disconnect() is added under a spinlock, what prevents any
further activity on the usb bus.
Acked-by: default avatarPaul Zimmerman <paulz@synopsys.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 5b9451f8
...@@ -3642,11 +3642,13 @@ static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -3642,11 +3642,13 @@ static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state)
hsotg->driver->driver.name); hsotg->driver->driver.name);
spin_lock_irqsave(&hsotg->lock, flags); spin_lock_irqsave(&hsotg->lock, flags);
s3c_hsotg_core_disconnect(hsotg);
s3c_hsotg_disconnect(hsotg); s3c_hsotg_disconnect(hsotg);
s3c_hsotg_phy_disable(hsotg);
hsotg->gadget.speed = USB_SPEED_UNKNOWN; hsotg->gadget.speed = USB_SPEED_UNKNOWN;
spin_unlock_irqrestore(&hsotg->lock, flags); spin_unlock_irqrestore(&hsotg->lock, flags);
s3c_hsotg_phy_disable(hsotg);
if (hsotg->driver) { if (hsotg->driver) {
int ep; int ep;
for (ep = 0; ep < hsotg->num_of_eps; ep++) for (ep = 0; ep < hsotg->num_of_eps; ep++)
...@@ -3675,8 +3677,9 @@ static int s3c_hsotg_resume(struct platform_device *pdev) ...@@ -3675,8 +3677,9 @@ static int s3c_hsotg_resume(struct platform_device *pdev)
hsotg->supplies); hsotg->supplies);
} }
spin_lock_irqsave(&hsotg->lock, flags);
s3c_hsotg_phy_enable(hsotg); s3c_hsotg_phy_enable(hsotg);
spin_lock_irqsave(&hsotg->lock, flags);
s3c_hsotg_core_init_disconnected(hsotg); s3c_hsotg_core_init_disconnected(hsotg);
s3c_hsotg_core_connect(hsotg); s3c_hsotg_core_connect(hsotg);
spin_unlock_irqrestore(&hsotg->lock, flags); spin_unlock_irqrestore(&hsotg->lock, flags);
......
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