mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
Subsystems (3)
PATCH 1/1 mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
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.
--- drivers/mfd/omap-usb-tll.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/mfd/omap-usb-tll.c +6 -5
@@ -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 ; }
Signature · 1 line
1.8.3.2
Quoted 19 lines
pm_runtime_get/put_sync() can sleep so don't hold spinlock while calling them.
This patch prevents a
BUG()whenCONFIG_DEBUG_ATOMIC_SLEEPis enabled. Bug is present in Kernel versions v3.9 onwards.Reported-by Tomi Valkeinen <[email protected]>Signed-off-by Roger Quadros <[email protected]>Tested-by Tomi Valkeinen <[email protected]>Cc <[email protected]> # 3.9+--- drivers/mfd/omap-usb-tll.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/mfd/omap-usb-tll.c +0
-0
drivers/mfd/omap-usb-tll.c int omap_tll_init(struct usbhs_omap_platform_data *pdata) · line 351
Quoted 6 lines
drivers/mfd/omap-usb-tll.c +2
-0@@ -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>
drivers/mfd/omap-usb-tll.c int omap_tll_enable(struct usbhs_omap_platform_data *pdata) · line 426
Quoted 5 lines
drivers/mfd/omap-usb-tll.c +2
-0tll =dev_get_drvdata (tll_dev); +spin_unlock (&tll_lock);pm_runtime_get_sync (tll_dev); +spin_lock (&tll_lock);
Same here?
drivers/mfd/omap-usb-tll.c int omap_tll_enable(struct usbhs_omap_platform_data *pdata) · line 441
Quoted 7 lines
drivers/mfd/omap-usb-tll.c +0
-1for (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.
Quoted 14 lines
drivers/mfd/omap-usb-tll.c +1
-2return 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 ; }
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Hi,
Quoted 22 lines · Lee Jones
Quoted 22 lines
pm_runtime_get/put_sync() can sleep so don't hold spinlock while calling them.
This patch prevents a
BUG()whenCONFIG_DEBUG_ATOMIC_SLEEPis enabled. Bug is present in Kernel versions v3.9 onwards.Reported-by Tomi Valkeinen <[email protected]>Signed-off-by Roger Quadros <[email protected]>Tested-by Tomi Valkeinen <[email protected]>Cc <[email protected]> # 3.9+--- drivers/mfd/omap-usb-tll.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/mfd/omap-usb-tll.c +0
-0@@ -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]);
Quoted 5 lines
drivers/mfd/omap-usb-tll.c int omap_tll_init(struct usbhs_omap_platform_data *pdata) · line 351
Quoted 3 lines
drivers/mfd/omap-usb-tll.c +2
-0+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().
Quoted 10 lines
<snip>
drivers/mfd/omap-usb-tll.c int omap_tll_enable(struct usbhs_omap_platform_data *pdata) · line 426
Quoted 5 lines
drivers/mfd/omap-usb-tll.c +2
-0tll =dev_get_drvdata (tll_dev); +spin_unlock (&tll_lock);pm_runtime_get_sync (tll_dev); +spin_lock (&tll_lock);Same here?
Yes.
Quoted 11 lines
drivers/mfd/omap-usb-tll.c int omap_tll_enable(struct usbhs_omap_platform_data *pdata) · line 441
Quoted 8 lines
drivers/mfd/omap-usb-tll.c +0
-1for (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.
Quoted 8 lines
Quoted 8 lines
drivers/mfd/omap-usb-tll.c +0
-0return 0 ; }EXPORT_SYMBOL_GPL (omap_tll_enable);@@ -464,9 +466,8 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata) } }
Quoted 8 lines
drivers/mfd/omap-usb-tll.c int omap_tll_init(struct usbhs_omap_platform_data *pdata) · line 407
Quoted 7 lines
drivers/mfd/omap-usb-tll.c +1
-2-pm_runtime_put_sync (tll_dev); -spin_unlock (&tll_lock); +pm_runtime_put_sync (tll_dev);return 0 ; }
cheers,
-roger