Skip to content

Commit

Permalink
mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
Browse files Browse the repository at this point in the history
pm_runtime_get/put_sync() can sleep so don't hold spinlock while
calling them.

This patch prevents a BUG() during system suspend when
CONFIG_DEBUG_ATOMIC_SLEEP is enabled.

Bug is present in Kernel versions v3.9 onwards.

Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Roger Quadros authored and Lee Jones committed Jan 21, 2014
1 parent 3b1ba0c commit 76a0775
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions drivers/mfd/omap-usb-tll.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,17 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata)
unsigned reg;
struct usbtll_omap *tll;

spin_lock(&tll_lock);

if (!tll_dev) {
spin_unlock(&tll_lock);
if (!tll_dev)
return -ENODEV;
}

tll = dev_get_drvdata(tll_dev);
pm_runtime_get_sync(tll_dev);

spin_lock(&tll_lock);
tll = dev_get_drvdata(tll_dev);
needs_tll = false;
for (i = 0; i < tll->nch; i++)
needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);

pm_runtime_get_sync(tll_dev);

if (needs_tll) {
void __iomem *base = tll->base;

Expand Down Expand Up @@ -398,9 +394,8 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata)
}
}

pm_runtime_put_sync(tll_dev);

spin_unlock(&tll_lock);
pm_runtime_put_sync(tll_dev);

return 0;
}
Expand All @@ -411,17 +406,14 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
int i;
struct usbtll_omap *tll;

spin_lock(&tll_lock);

if (!tll_dev) {
spin_unlock(&tll_lock);
if (!tll_dev)
return -ENODEV;
}

tll = dev_get_drvdata(tll_dev);

pm_runtime_get_sync(tll_dev);

spin_lock(&tll_lock);
tll = dev_get_drvdata(tll_dev);

for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
int r;
Expand All @@ -448,13 +440,10 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata)
int i;
struct usbtll_omap *tll;

spin_lock(&tll_lock);

if (!tll_dev) {
spin_unlock(&tll_lock);
if (!tll_dev)
return -ENODEV;
}

spin_lock(&tll_lock);
tll = dev_get_drvdata(tll_dev);

for (i = 0; i < tll->nch; i++) {
Expand All @@ -464,9 +453,8 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata)
}
}

pm_runtime_put_sync(tll_dev);

spin_unlock(&tll_lock);
pm_runtime_put_sync(tll_dev);

return 0;
}
Expand Down

0 comments on commit 76a0775

Please sign in to comment.