[RESEND,v3,09/12] usb: dwc2/gadget: delay enabling irq once hardware is configured properly

Message ID 1409857474-4497-10-git-send-email-paulz@synopsys.com
State New
Headers show

Commit Message

Paul Zimmerman Sept. 4, 2014, 7:04 p.m.
From: Marek Szyprowski <m.szyprowski@samsung.com>

This patch fixes kernel panic/interrupt storm/etc issues if bootloader
left s3c-hsotg module in enabled state. Now interrupt handler is enabled
only after proper configuration of hardware registers.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
---
 drivers/usb/dwc2/gadget.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Felipe Balbi Sept. 4, 2014, 7:21 p.m. | #1
On Thu, Sep 04, 2014 at 12:04:31PM -0700, Paul Zimmerman wrote:
> From: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> This patch fixes kernel panic/interrupt storm/etc issues if bootloader
> left s3c-hsotg module in enabled state. Now interrupt handler is enabled
> only after proper configuration of hardware registers.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> Signed-off-by: Paul Zimmerman <paulz@synopsys.com>

Makes sense, Cc stable ?

Reviewed-by: Felipe Balbi <balbi@ti.com>

> ---
>  drivers/usb/dwc2/gadget.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 55238b0..2c9f0f5 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3456,13 +3456,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>  
>  	hsotg->irq = ret;
>  
> -	ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
> -				dev_name(dev), hsotg);
> -	if (ret < 0) {
> -		dev_err(dev, "cannot claim IRQ\n");
> -		goto err_clk;
> -	}
> -
>  	dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
>  
>  	hsotg->gadget.max_speed = USB_SPEED_HIGH;
> @@ -3500,6 +3493,17 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
>  	s3c_hsotg_hw_cfg(hsotg);
>  	s3c_hsotg_init(hsotg);
>  
> +	ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
> +				dev_name(dev), hsotg);
> +	if (ret < 0) {
> +		s3c_hsotg_phy_disable(hsotg);
> +		clk_disable_unprepare(hsotg->clk);
> +		regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
> +				       hsotg->supplies);
> +		dev_err(dev, "cannot claim IRQ\n");
> +		goto err_clk;
> +	}
> +
>  	/* hsotg->num_of_eps holds number of EPs other than ep0 */
>  
>  	if (hsotg->num_of_eps == 0) {
> -- 
> 2.1.0.24.g4109c28
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 55238b0..2c9f0f5 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3456,13 +3456,6 @@  static int s3c_hsotg_probe(struct platform_device *pdev)
 
 	hsotg->irq = ret;
 
-	ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
-				dev_name(dev), hsotg);
-	if (ret < 0) {
-		dev_err(dev, "cannot claim IRQ\n");
-		goto err_clk;
-	}
-
 	dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
 
 	hsotg->gadget.max_speed = USB_SPEED_HIGH;
@@ -3500,6 +3493,17 @@  static int s3c_hsotg_probe(struct platform_device *pdev)
 	s3c_hsotg_hw_cfg(hsotg);
 	s3c_hsotg_init(hsotg);
 
+	ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
+				dev_name(dev), hsotg);
+	if (ret < 0) {
+		s3c_hsotg_phy_disable(hsotg);
+		clk_disable_unprepare(hsotg->clk);
+		regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
+				       hsotg->supplies);
+		dev_err(dev, "cannot claim IRQ\n");
+		goto err_clk;
+	}
+
 	/* hsotg->num_of_eps holds number of EPs other than ep0 */
 
 	if (hsotg->num_of_eps == 0) {