aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2016-12-12 14:37:52 -0500
committerFelipe Balbi <felipe.balbi@linux.intel.com>2017-01-02 03:55:28 -0500
commit12a7f17fac5b370bec87259e4c718faf563ce900 (patch)
tree9e934f0f717a56749d70766a005ac6118afa7366
parent890e6c236dcda6d45c5f0bdd23665636376f6831 (diff)
usb: dwc3: omap: fix race of pm runtime with irq handler in probe
Now races can happen between interrupt handler execution and PM runtime in error handling code path in probe and in dwc3_omap_remove() which will lead to system crash: in probe: ... err1: pm_runtime_put_sync(dev); ^^ PM runtime can race with IRQ handler when deferred probing happening due to extcon pm_runtime_disable(dev); return ret; in dwc3_omap_remove: ... dwc3_omap_disable_irqs(omap); ^^ IRQs are disabled in HW, but handler may still run of_platform_depopulate(omap->dev); pm_runtime_put_sync(&pdev->dev); ^^ PM runtime can race with IRQ handler pm_runtime_disable(&pdev->dev); return 0; So, OMAP DWC3 IRQ need to be disabled before calling pm_runtime_put() in probe and in dwc3_omap_remove(). Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 29e80cc9b634..eb1b9cb3f9d1 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/irq.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/platform_data/dwc3-omap.h> 25#include <linux/platform_data/dwc3-omap.h>
@@ -510,7 +511,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
510 511
511 /* check the DMA Status */ 512 /* check the DMA Status */
512 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); 513 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
513 514 irq_set_status_flags(omap->irq, IRQ_NOAUTOEN);
514 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, 515 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt,
515 dwc3_omap_interrupt_thread, IRQF_SHARED, 516 dwc3_omap_interrupt_thread, IRQF_SHARED,
516 "dwc3-omap", omap); 517 "dwc3-omap", omap);
@@ -531,7 +532,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
531 } 532 }
532 533
533 dwc3_omap_enable_irqs(omap); 534 dwc3_omap_enable_irqs(omap);
534 535 enable_irq(omap->irq);
535 return 0; 536 return 0;
536 537
537err2: 538err2:
@@ -552,6 +553,7 @@ static int dwc3_omap_remove(struct platform_device *pdev)
552 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb); 553 extcon_unregister_notifier(omap->edev, EXTCON_USB, &omap->vbus_nb);
553 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb); 554 extcon_unregister_notifier(omap->edev, EXTCON_USB_HOST, &omap->id_nb);
554 dwc3_omap_disable_irqs(omap); 555 dwc3_omap_disable_irqs(omap);
556 disable_irq(omap->irq);
555 of_platform_depopulate(omap->dev); 557 of_platform_depopulate(omap->dev);
556 pm_runtime_put_sync(&pdev->dev); 558 pm_runtime_put_sync(&pdev->dev);
557 pm_runtime_disable(&pdev->dev); 559 pm_runtime_disable(&pdev->dev);