public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized
@ 2015-02-05 17:47 Romain Perier
  2015-02-05 18:04 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: Romain Perier @ 2015-02-05 17:47 UTC (permalink / raw)
  To: johnyoun; +Cc: gregkh, linux-usb, linux-kernel, linux-rockchip

Don't register interrupt handler becore usb gadget is correctly initialized.
For some embedded platforms which don't have a usb-phy it crashes the driver
because an interrupt is emitted with non-initiliazed hardware.
According to devm_request_irq documentation, an interrupt can be emitted
at any time once the interrupt is registered, so we have to care about driver
and hardware initialization.

Signed-off-by: Romain Perier <romain.perier@gmail.com>
---
 drivers/usb/dwc2/platform.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index ae095f0..b26cf8c 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -196,14 +196,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
 		return irq;
 	}
 
-	dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
-		irq);
-	retval = devm_request_irq(hsotg->dev, irq,
-				  dwc2_handle_common_intr, IRQF_SHARED,
-				  dev_name(hsotg->dev), hsotg);
-	if (retval)
-		return retval;
-
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	hsotg->regs = devm_ioremap_resource(&dev->dev, res);
 	if (IS_ERR(hsotg->regs))
@@ -237,6 +229,15 @@ static int dwc2_driver_probe(struct platform_device *dev)
 	retval = dwc2_gadget_init(hsotg, irq);
 	if (retval)
 		return retval;
+
+        dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
+                irq);
+        retval = devm_request_irq(hsotg->dev, irq,
+                                dwc2_handle_common_intr, IRQF_SHARED,
+                                dev_name(hsotg->dev), hsotg);
+        if (retval)
+                return retval;
+
 	retval = dwc2_hcd_init(hsotg, irq, params);
 	if (retval)
 		return retval;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized
  2015-02-05 17:47 [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized Romain Perier
@ 2015-02-05 18:04 ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2015-02-05 18:04 UTC (permalink / raw)
  To: Romain Perier, johnyoun; +Cc: gregkh, linux-usb, linux-kernel, linux-rockchip

Hello.

On 02/05/2015 08:47 PM, Romain Perier wrote:

> Don't register interrupt handler becore usb gadget is correctly initialized.

    s/becore/before/?

> For some embedded platforms which don't have a usb-phy it crashes the driver
> because an interrupt is emitted with non-initiliazed hardware.

    s/non-initiliazed/non-initialized/.

> According to devm_request_irq documentation, an interrupt can be emitted
> at any time once the interrupt is registered, so we have to care about driver
> and hardware initialization.

> Signed-off-by: Romain Perier <romain.perier@gmail.com>

[...]

WBR, Sergei


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-05 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05 17:47 [PATCH] usb: dwc2: Register interrupt handler only once gadget is correctly initialized Romain Perier
2015-02-05 18:04 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox