* [PATCH] mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
@ 2013-12-18 10:01 Roger Quadros
2013-12-18 10:36 ` Lee Jones
0 siblings, 1 reply; 3+ messages in thread
From: Roger Quadros @ 2013-12-18 10:01 UTC (permalink / raw)
To: lee.jones, sameo
Cc: balbi, linux-kernel, linux-usb, linux-omap, Roger Quadros, stable
pm_runtime_get/put_sync() can sleep so don't hold spinlock while
calling them.
This patch prevents a BUG() 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>
Cc: <stable@vger.kernel.org> # 3.9+
---
drivers/mfd/omap-usb-tll.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0d946ae1..248004c 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -346,7 +346,9 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata)
for (i = 0; i < tll->nch; i++)
needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);
+ spin_unlock(&tll_lock);
pm_runtime_get_sync(tll_dev);
+ spin_lock(&tll_lock);
if (needs_tll) {
void __iomem *base = tll->base;
@@ -398,9 +400,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;
}
@@ -420,7 +421,9 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
tll = dev_get_drvdata(tll_dev);
+ spin_unlock(&tll_lock);
pm_runtime_get_sync(tll_dev);
+ spin_lock(&tll_lock);
for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
@@ -438,7 +441,6 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
}
spin_unlock(&tll_lock);
-
return 0;
}
EXPORT_SYMBOL_GPL(omap_tll_enable);
@@ -464,9 +466,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;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
2013-12-18 10:01 [PATCH] mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync() Roger Quadros
@ 2013-12-18 10:36 ` Lee Jones
2014-01-08 6:28 ` Roger Quadros
0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2013-12-18 10:36 UTC (permalink / raw)
To: Roger Quadros; +Cc: sameo, balbi, linux-kernel, linux-usb, linux-omap, stable
> pm_runtime_get/put_sync() can sleep so don't hold spinlock while
> calling them.
>
> This patch prevents a BUG() 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>
> Cc: <stable@vger.kernel.org> # 3.9+
> ---
> drivers/mfd/omap-usb-tll.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
> index 0d946ae1..248004c 100644
> --- a/drivers/mfd/omap-usb-tll.c
> +++ b/drivers/mfd/omap-usb-tll.c
> @@ -346,7 +346,9 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata)
> for (i = 0; i < tll->nch; i++)
> needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);
>
> + spin_unlock(&tll_lock);
> pm_runtime_get_sync(tll_dev);
> + spin_lock(&tll_lock);
This is pretty ugly. Can't you move it above the spin_lock() instead?
<snip>
> tll = dev_get_drvdata(tll_dev);
>
> + spin_unlock(&tll_lock);
> pm_runtime_get_sync(tll_dev);
> + spin_lock(&tll_lock);
Same here?
> for (i = 0; i < tll->nch; i++) {
> if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
> @@ -438,7 +441,6 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
> }
>
> spin_unlock(&tll_lock);
> -
This doesn't belong in this patch and is now inconsistent with the
other functions in the driver.
> return 0;
> }
> EXPORT_SYMBOL_GPL(omap_tll_enable);
> @@ -464,9 +466,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;
> }
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
2013-12-18 10:36 ` Lee Jones
@ 2014-01-08 6:28 ` Roger Quadros
0 siblings, 0 replies; 3+ messages in thread
From: Roger Quadros @ 2014-01-08 6:28 UTC (permalink / raw)
To: Lee Jones; +Cc: sameo, balbi, linux-kernel, linux-usb, linux-omap, stable
Hi,
On 12/18/2013 04:06 PM, Lee Jones wrote:
>> pm_runtime_get/put_sync() can sleep so don't hold spinlock while
>> calling them.
>>
>> This patch prevents a BUG() 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>
>> Cc: <stable@vger.kernel.org> # 3.9+
>> ---
>> drivers/mfd/omap-usb-tll.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
>> index 0d946ae1..248004c 100644
>> --- a/drivers/mfd/omap-usb-tll.c
>> +++ b/drivers/mfd/omap-usb-tll.c
>> @@ -346,7 +346,9 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata)
>> for (i = 0; i < tll->nch; i++)
>> needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);
>>
>> + spin_unlock(&tll_lock);
>> pm_runtime_get_sync(tll_dev);
>> + spin_lock(&tll_lock);
>
> This is pretty ugly. Can't you move it above the spin_lock() instead?
OK. I'll also remove NULL check for tll_dev outside the spin_lock().
>
> <snip>
>
>> tll = dev_get_drvdata(tll_dev);
>>
>> + spin_unlock(&tll_lock);
>> pm_runtime_get_sync(tll_dev);
>> + spin_lock(&tll_lock);
>
> Same here?
Yes.
>
>> for (i = 0; i < tll->nch; i++) {
>> if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
>> @@ -438,7 +441,6 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata)
>> }
>>
>> spin_unlock(&tll_lock);
>> -
>
> This doesn't belong in this patch and is now inconsistent with the
> other functions in the driver.
OK.
>
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(omap_tll_enable);
>> @@ -464,9 +466,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;
>> }
>
cheers,
-roger
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-08 6:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 10:01 [PATCH] mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync() Roger Quadros
2013-12-18 10:36 ` Lee Jones
2014-01-08 6:28 ` Roger Quadros
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).