From 67b488c0ae982ca83072f2c89bb17c7cefd331b6 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 20 Jan 2013 14:59:07 +1100 Subject: musb: fix context save over suspend. It is possible that the musb device will be runtime-active (not suspended) when system suspend happens. In particular, usb_suspend() will have called choose_wakeup() which might have called pm_runtime_resume(). In that case, after system-resume, the state of the device will be 'active', but the state of the registers will have been lost (if off_mode is enabled). So we need to save_context in musb_suspend (if runtime state is active), and restore_context on resume. This effectively reverts 5d193ce8 (usb: musb: PM: fix context save/restore in suspend/resume path) and adds a rest to avoid saving/restoring context if device is already runtime suspended. Tested-by: Kevin Hilman Cc: "Bilovol, Ruslan" Cc: Igor Grinberg Signed-off-by: NeilBrown --- drivers/usb/musb/musb_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 37a261a..c14f8c6 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2217,6 +2217,8 @@ static int musb_suspend(struct device *dev) } spin_unlock_irqrestore(&musb->lock, flags); + if (!pm_runtime_status_suspended(dev)) + musb_save_context(musb); return 0; } @@ -2226,6 +2228,10 @@ static int musb_resume_noirq(struct device *dev) * unless for some reason the whole soc powered down or the USB * module got reset through the PSC (vs just being disabled). */ + struct musb *musb = dev_to_musb(dev); + + if (!pm_runtime_status_suspended(dev)) + musb_restore_context(musb); return 0; } -- cgit v1.1