All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08  9:31 ` Merlijn Wajer
  0 siblings, 0 replies; 10+ messages in thread
From: Merlijn Wajer @ 2018-03-08  9:31 UTC (permalink / raw)
  To: b-liu
  Cc: merlijn, ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman,
	linux-usb, linux-kernel

This fixes an oops on unbind / module unload. The fix is similar to the
one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb:
fix late external abort on suspend), which only fixes the issue for
musb_suspend.

musb_remove function now also flushes any work and also calls
musb_platform_exit before disabling runtime pm.

Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
---

If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly,
this patch should also be backported to 4.9 (and newer kernels).

I have verified that this works on the Nokia N900, RX-51. The problem did not
occur on the Motorola Droid 4, but I have yet to test if this patch causes
issues there.

 drivers/usb/musb/musb_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e2e95071328a..4fb0f345c04e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev)
 	musb_platform_disable(musb);
 	spin_lock_irqsave(&musb->lock, flags);
 	musb_disable_interrupts(musb);
+
+	musb->flush_irq_work = true;
+	while (flush_delayed_work(&musb->irq_work))
+		;
+	musb->flush_irq_work = false;
+
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+	musb_platform_exit(musb);
 	spin_unlock_irqrestore(&musb->lock, flags);
 
 	pm_runtime_dont_use_autosuspend(musb->controller);
 	pm_runtime_put_sync(musb->controller);
 	pm_runtime_disable(musb->controller);
-	musb_platform_exit(musb);
 	musb_phy_callback = NULL;
 	if (musb->dma_controller)
 		musb_dma_controller_destroy(musb->dma_controller);
-- 
2.16.2


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

* [RFC] usb: musb: Fix external abort in musb_remove
@ 2018-03-08  9:31 ` Merlijn Wajer
  0 siblings, 0 replies; 10+ messages in thread
From: Merlijn Wajer @ 2018-03-08  9:31 UTC (permalink / raw)
  To: b-liu
  Cc: merlijn, ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman,
	linux-usb, linux-kernel

This fixes an oops on unbind / module unload. The fix is similar to the
one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb:
fix late external abort on suspend), which only fixes the issue for
musb_suspend.

musb_remove function now also flushes any work and also calls
musb_platform_exit before disabling runtime pm.

Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
---

If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly,
this patch should also be backported to 4.9 (and newer kernels).

I have verified that this works on the Nokia N900, RX-51. The problem did not
occur on the Motorola Droid 4, but I have yet to test if this patch causes
issues there.

 drivers/usb/musb/musb_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e2e95071328a..4fb0f345c04e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev)
 	musb_platform_disable(musb);
 	spin_lock_irqsave(&musb->lock, flags);
 	musb_disable_interrupts(musb);
+
+	musb->flush_irq_work = true;
+	while (flush_delayed_work(&musb->irq_work))
+		;
+	musb->flush_irq_work = false;
+
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+	musb_platform_exit(musb);
 	spin_unlock_irqrestore(&musb->lock, flags);
 
 	pm_runtime_dont_use_autosuspend(musb->controller);
 	pm_runtime_put_sync(musb->controller);
 	pm_runtime_disable(musb->controller);
-	musb_platform_exit(musb);
 	musb_phy_callback = NULL;
 	if (musb->dma_controller)
 		musb_dma_controller_destroy(musb->dma_controller);

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

* Re: [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 16:46   ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 16:46 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

Hi,

On Thu, Mar 08, 2018 at 10:31:21AM +0100, Merlijn Wajer wrote:
> This fixes an oops on unbind / module unload. The fix is similar to the
> one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb:
> fix late external abort on suspend), which only fixes the issue for
> musb_suspend.
> 
> musb_remove function now also flushes any work and also calls
> musb_platform_exit before disabling runtime pm.
> 
> Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
> ---
> 
> If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly,
> this patch should also be backported to 4.9 (and newer kernels).
> 
> I have verified that this works on the Nokia N900, RX-51. The problem did not
> occur on the Motorola Droid 4, but I have yet to test if this patch causes
> issues there.
> 
>  drivers/usb/musb/musb_core.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index e2e95071328a..4fb0f345c04e 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev)
>  	musb_platform_disable(musb);
>  	spin_lock_irqsave(&musb->lock, flags);
>  	musb_disable_interrupts(musb);
> +
> +	musb->flush_irq_work = true;
> +	while (flush_delayed_work(&musb->irq_work))
> +		;
> +	musb->flush_irq_work = false;

No need to flush, the work is already cancelled at this point.

> +
>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> +	musb_platform_exit(musb);

This can be move down to out side of holding the spinlock,

>  	spin_unlock_irqrestore(&musb->lock, flags);

to here.

>  
>  	pm_runtime_dont_use_autosuspend(musb->controller);
>  	pm_runtime_put_sync(musb->controller);
>  	pm_runtime_disable(musb->controller);
> -	musb_platform_exit(musb);
>  	musb_phy_callback = NULL;
>  	if (musb->dma_controller)
>  		musb_dma_controller_destroy(musb->dma_controller);
> -- 

Thanks for the patch.

Regards,
-Bin.

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

* [RFC] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 16:46   ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 16:46 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

Hi,

On Thu, Mar 08, 2018 at 10:31:21AM +0100, Merlijn Wajer wrote:
> This fixes an oops on unbind / module unload. The fix is similar to the
> one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb:
> fix late external abort on suspend), which only fixes the issue for
> musb_suspend.
> 
> musb_remove function now also flushes any work and also calls
> musb_platform_exit before disabling runtime pm.
> 
> Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
> ---
> 
> If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly,
> this patch should also be backported to 4.9 (and newer kernels).
> 
> I have verified that this works on the Nokia N900, RX-51. The problem did not
> occur on the Motorola Droid 4, but I have yet to test if this patch causes
> issues there.
> 
>  drivers/usb/musb/musb_core.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index e2e95071328a..4fb0f345c04e 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev)
>  	musb_platform_disable(musb);
>  	spin_lock_irqsave(&musb->lock, flags);
>  	musb_disable_interrupts(musb);
> +
> +	musb->flush_irq_work = true;
> +	while (flush_delayed_work(&musb->irq_work))
> +		;
> +	musb->flush_irq_work = false;

No need to flush, the work is already cancelled at this point.

> +
>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> +	musb_platform_exit(musb);

This can be move down to out side of holding the spinlock,

>  	spin_unlock_irqrestore(&musb->lock, flags);

to here.

>  
>  	pm_runtime_dont_use_autosuspend(musb->controller);
>  	pm_runtime_put_sync(musb->controller);
>  	pm_runtime_disable(musb->controller);
> -	musb_platform_exit(musb);
>  	musb_phy_callback = NULL;
>  	if (musb->dma_controller)
>  		musb_dma_controller_destroy(musb->dma_controller);
> -- 

Thanks for the patch.

Regards,
-Bin.
---
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

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

* Re: [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 16:46   ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 16:46 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

Hi,

On Thu, Mar 08, 2018 at 10:31:21AM +0100, Merlijn Wajer wrote:
> This fixes an oops on unbind / module unload. The fix is similar to the
> one in this commit: 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 (USB: musb:
> fix late external abort on suspend), which only fixes the issue for
> musb_suspend.
> 
> musb_remove function now also flushes any work and also calls
> musb_platform_exit before disabling runtime pm.
> 
> Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
> ---
> 
> If I understand commit 0c3aae9bd59978fb8c3557d7883380bef0f2cfa1 correctly,
> this patch should also be backported to 4.9 (and newer kernels).
> 
> I have verified that this works on the Nokia N900, RX-51. The problem did not
> occur on the Motorola Droid 4, but I have yet to test if this patch causes
> issues there.
> 
>  drivers/usb/musb/musb_core.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index e2e95071328a..4fb0f345c04e 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2472,13 +2472,19 @@ static int musb_remove(struct platform_device *pdev)
>  	musb_platform_disable(musb);
>  	spin_lock_irqsave(&musb->lock, flags);
>  	musb_disable_interrupts(musb);
> +
> +	musb->flush_irq_work = true;
> +	while (flush_delayed_work(&musb->irq_work))
> +		;
> +	musb->flush_irq_work = false;

No need to flush, the work is already cancelled at this point.

> +
>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> +	musb_platform_exit(musb);

This can be move down to out side of holding the spinlock,

>  	spin_unlock_irqrestore(&musb->lock, flags);

to here.

>  
>  	pm_runtime_dont_use_autosuspend(musb->controller);
>  	pm_runtime_put_sync(musb->controller);
>  	pm_runtime_disable(musb->controller);
> -	musb_platform_exit(musb);
>  	musb_phy_callback = NULL;
>  	if (musb->dma_controller)
>  		musb_dma_controller_destroy(musb->dma_controller);
> -- 

Thanks for the patch.

Regards,
-Bin.

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

* Re: [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 18:00     ` Merlijn Wajer
  0 siblings, 0 replies; 10+ messages in thread
From: Merlijn Wajer @ 2018-03-08 18:00 UTC (permalink / raw)
  To: Bin Liu, ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman,
	linux-usb, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 575 bytes --]

Hi,

On 08/03/18 17:46, Bin Liu wrote:


> No need to flush, the work is already cancelled at this point.
> 
>> +
>>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
>> +	musb_platform_exit(musb);
> 
> This can be move down to out side of holding the spinlock,
> 
>>  	spin_unlock_irqrestore(&musb->lock, flags);
> 
> to here.

Thank you - with I've verified that it works with these changes. I'm
surprised, because I believe that I had tried this already. I must have
missed a step in my testing-routine.

I will send a patch shortly.

Cheers,
Merlijn


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* [RFC] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 18:00     ` Merlijn Wajer
  0 siblings, 0 replies; 10+ messages in thread
From: Merlijn Wajer @ 2018-03-08 18:00 UTC (permalink / raw)
  To: Bin Liu, ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman,
	linux-usb, linux-kernel

Hi,

On 08/03/18 17:46, Bin Liu wrote:


> No need to flush, the work is already cancelled at this point.
> 
>> +
>>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
>> +	musb_platform_exit(musb);
> 
> This can be move down to out side of holding the spinlock,
> 
>>  	spin_unlock_irqrestore(&musb->lock, flags);
> 
> to here.

Thank you - with I've verified that it works with these changes. I'm
surprised, because I believe that I had tried this already. I must have
missed a step in my testing-routine.

I will send a patch shortly.

Cheers,
Merlijn

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

* Re: [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 18:22       ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 18:22 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

On Thu, Mar 08, 2018 at 07:00:16PM +0100, Merlijn Wajer wrote:
> Hi,
> 
> On 08/03/18 17:46, Bin Liu wrote:
> 
> 
> > No need to flush, the work is already cancelled at this point.
> > 
> >> +
> >>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> >> +	musb_platform_exit(musb);
> > 
> > This can be move down to out side of holding the spinlock,
> > 
> >>  	spin_unlock_irqrestore(&musb->lock, flags);
> > 
> > to here.
> 
> Thank you - with I've verified that it works with these changes. I'm
> surprised, because I believe that I had tried this already. I must have
> missed a step in my testing-routine.
> 
> I will send a patch shortly.

Thank you for fixing this up.

Regards,
-Bin.

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

* [RFC] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 18:22       ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 18:22 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

On Thu, Mar 08, 2018 at 07:00:16PM +0100, Merlijn Wajer wrote:
> Hi,
> 
> On 08/03/18 17:46, Bin Liu wrote:
> 
> 
> > No need to flush, the work is already cancelled at this point.
> > 
> >> +
> >>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> >> +	musb_platform_exit(musb);
> > 
> > This can be move down to out side of holding the spinlock,
> > 
> >>  	spin_unlock_irqrestore(&musb->lock, flags);
> > 
> > to here.
> 
> Thank you - with I've verified that it works with these changes. I'm
> surprised, because I believe that I had tried this already. I must have
> missed a step in my testing-routine.
> 
> I will send a patch shortly.

Thank you for fixing this up.

Regards,
-Bin.
---
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

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

* Re: [RFC PATCH] usb: musb: Fix external abort in musb_remove
@ 2018-03-08 18:22       ` Bin Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Liu @ 2018-03-08 18:22 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: ivo.g.dimitrov.75, linux-omap, Greg Kroah-Hartman, linux-usb,
	linux-kernel

On Thu, Mar 08, 2018 at 07:00:16PM +0100, Merlijn Wajer wrote:
> Hi,
> 
> On 08/03/18 17:46, Bin Liu wrote:
> 
> 
> > No need to flush, the work is already cancelled at this point.
> > 
> >> +
> >>  	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> >> +	musb_platform_exit(musb);
> > 
> > This can be move down to out side of holding the spinlock,
> > 
> >>  	spin_unlock_irqrestore(&musb->lock, flags);
> > 
> > to here.
> 
> Thank you - with I've verified that it works with these changes. I'm
> surprised, because I believe that I had tried this already. I must have
> missed a step in my testing-routine.
> 
> I will send a patch shortly.

Thank you for fixing this up.

Regards,
-Bin.

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

end of thread, other threads:[~2018-03-08 18:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08  9:31 [RFC PATCH] usb: musb: Fix external abort in musb_remove Merlijn Wajer
2018-03-08  9:31 ` [RFC] " Merlijn Wajer
2018-03-08 16:46 ` [RFC PATCH] " Bin Liu
2018-03-08 16:46   ` Bin Liu
2018-03-08 16:46   ` [RFC] " Bin Liu
2018-03-08 18:00   ` [RFC PATCH] " Merlijn Wajer
2018-03-08 18:00     ` [RFC] " Merlijn Wajer
2018-03-08 18:22     ` [RFC PATCH] " Bin Liu
2018-03-08 18:22       ` Bin Liu
2018-03-08 18:22       ` [RFC] " Bin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.