Commit 12a19b5f authored by NeilBrown's avatar NeilBrown Committed by Felipe Balbi

usb: musb: omap2430: don't loop indefinitely in interrupt.

When called during resume_irqs, omap2430_musb_set_vbus() is run with
interrupts disabled,  In that case 'jiffies' never changes so the loop
can loop forever.

So impose a maximum loop count and add an 'mdelay' to ensure we wait
a reasonable amount of time for bit to be cleared.

This fixes a hang on resume.
Signed-of-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 07a67bbb
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/delay.h>
#include <linux/usb/musb-omap.h> #include <linux/usb/musb-omap.h>
#include "musb_core.h" #include "musb_core.h"
...@@ -150,6 +151,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -150,6 +151,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) { if (is_on) {
if (musb->xceiv->state == OTG_STATE_A_IDLE) { if (musb->xceiv->state == OTG_STATE_A_IDLE) {
int loops = 100;
/* start the session */ /* start the session */
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
...@@ -159,9 +161,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -159,9 +161,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/ */
while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) {
mdelay(5);
cpu_relax(); cpu_relax();
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)
|| loops-- <= 0) {
dev_err(musb->controller, dev_err(musb->controller,
"configured as A device timeout"); "configured as A device timeout");
ret = -EINVAL; ret = -EINVAL;
......
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