diff mbox series

usb: chipidea: udc: assign interrupt number to USB gadget structure

Message ID 1620989984-7653-1-git-send-email-jun.li@nxp.com
State Superseded
Headers show
Series usb: chipidea: udc: assign interrupt number to USB gadget structure | expand

Commit Message

Jun Li May 14, 2021, 10:59 a.m. UTC
Chipidea also need sync interrupt before unbind the udc while
gadget remove driver, otherwise setup irq handling may happen
while unbind, see below dump generated from android function
switch stress test:

[ 4703.503056] android_work: sent uevent USB_STATE=CONNECTED
[ 4703.514642] android_work: sent uevent USB_STATE=DISCONNECTED
[ 4703.651339] android_work: sent uevent USB_STATE=CONNECTED
[ 4703.661806] init: Control message: Processed ctl.stop for 'adbd' from pid: 561 (system_server)
[ 4703.673469] init: processing action (init.svc.adbd=stopped) from (/system/etc/init/hw/init.usb.configfs.rc:14)
[ 4703.676451] Unable to handle kernel read from unreadable memory at virtual address 0000000000000090
[ 4703.676454] Mem abort info:
[ 4703.676458]   ESR = 0x96000004
[ 4703.676461]   EC = 0x25: DABT (current EL), IL = 32 bits
[ 4703.676464]   SET = 0, FnV = 0
[ 4703.676466]   EA = 0, S1PTW = 0
[ 4703.676468] Data abort info:
[ 4703.676471]   ISV = 0, ISS = 0x00000004
[ 4703.676473]   CM = 0, WnR = 0
[ 4703.676478] user pgtable: 4k pages, 48-bit VAs, pgdp=000000004a867000
[ 4703.676481] [0000000000000090] pgd=0000000000000000, p4d=0000000000000000
[ 4703.676503] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[ 4703.758297] Modules linked in: synaptics_dsx_i2c moal(O) mlan(O)
[ 4703.764327] CPU: 0 PID: 235 Comm: lmkd Tainted: G        W  O      5.10.9-00001-g3f5fd8487c38-dirty #63
[ 4703.773720] Hardware name: NXP i.MX8MNano EVK board (DT)
[ 4703.779033] pstate: 60400085 (nZCv daIf +PAN -UAO -TCO BTYPE=--)
[ 4703.785046] pc : _raw_write_unlock_bh+0xc0/0x2c8
[ 4703.789667] lr : android_setup+0x4c/0x168
[ 4703.793676] sp : ffff80001256bd80
[ 4703.796989] x29: ffff80001256bd80 x28: 00000000000000a8
[ 4703.802304] x27: ffff800012470000 x26: ffff80006d923000
[ 4703.807616] x25: ffff800012471000 x24: ffff00000b091140
[ 4703.812929] x23: ffff0000077dbd38 x22: ffff0000077da490
[ 4703.818242] x21: ffff80001256be30 x20: 0000000000000000
[ 4703.823554] x19: 0000000000000080 x18: ffff800012561048
[ 4703.828867] x17: 0000000000000000 x16: 0000000000000039
[ 4703.834180] x15: ffff8000106ad258 x14: ffff80001194c277
[ 4703.839493] x13: 0000000000003934 x12: 0000000000000000
[ 4703.844805] x11: 0000000000000000 x10: 0000000000000001
[ 4703.850117] x9 : 0000000000000000 x8 : 0000000000000090
[ 4703.855429] x7 : 6f72646e61203a70 x6 : ffff8000124f2450
[ 4703.860742] x5 : ffffffffffffffff x4 : 0000000000000009
[ 4703.866054] x3 : ffff8000108a290c x2 : ffff00007fb3a9c8
[ 4703.871367] x1 : 0000000000000000 x0 : 0000000000000090
[ 4703.876681] Call trace:
[ 4703.879129]  _raw_write_unlock_bh+0xc0/0x2c8
[ 4703.883397]  android_setup+0x4c/0x168
[ 4703.887059]  udc_irq+0x824/0xa9c
[ 4703.890287]  ci_irq+0x124/0x148
[ 4703.893429]  __handle_irq_event_percpu+0x84/0x268
[ 4703.898131]  handle_irq_event+0x64/0x14c
[ 4703.902054]  handle_fasteoi_irq+0x110/0x210
[ 4703.906236]  __handle_domain_irq+0x8c/0xd4
[ 4703.910332]  gic_handle_irq+0x6c/0x124
[ 4703.914081]  el1_irq+0xdc/0x1c0
[ 4703.917221]  _raw_spin_unlock_irq+0x20/0x54
[ 4703.921405]  finish_task_switch+0x84/0x224
[ 4703.925502]  __schedule+0x4a4/0x734
[ 4703.928990]  schedule+0xa0/0xe8
[ 4703.932132]  do_notify_resume+0x150/0x184
[ 4703.936140]  work_pending+0xc/0x40c
[ 4703.939633] Code: d5384613 521b0a69 d5184609 f9800111 (885ffd01)
[ 4703.945732] ---[ end trace ba5c1875ae49d53c ]---
[ 4703.950350] Kernel panic - not syncing: Oops: Fatal exception in interrupt
[ 4703.957223] SMP: stopping secondary CPUs
[ 4703.961151] Kernel Offset: disabled
[ 4703.964638] CPU features: 0x0240002,2000200c
[ 4703.968905] Memory Limit: none
[ 4703.971963] Rebooting in 5 seconds..

Tested-by: faqiang.zhu <faqiang.zhu@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/chipidea/udc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Greg Kroah-Hartman June 4, 2021, 10:51 a.m. UTC | #1
On Fri, May 14, 2021 at 06:59:44PM +0800, Li Jun wrote:
> Chipidea also need sync interrupt before unbind the udc while

> gadget remove driver, otherwise setup irq handling may happen

> while unbind, see below dump generated from android function

> switch stress test:

> 

> [ 4703.503056] android_work: sent uevent USB_STATE=CONNECTED

> [ 4703.514642] android_work: sent uevent USB_STATE=DISCONNECTED

> [ 4703.651339] android_work: sent uevent USB_STATE=CONNECTED

> [ 4703.661806] init: Control message: Processed ctl.stop for 'adbd' from pid: 561 (system_server)

> [ 4703.673469] init: processing action (init.svc.adbd=stopped) from (/system/etc/init/hw/init.usb.configfs.rc:14)

> [ 4703.676451] Unable to handle kernel read from unreadable memory at virtual address 0000000000000090

> [ 4703.676454] Mem abort info:

> [ 4703.676458]   ESR = 0x96000004

> [ 4703.676461]   EC = 0x25: DABT (current EL), IL = 32 bits

> [ 4703.676464]   SET = 0, FnV = 0

> [ 4703.676466]   EA = 0, S1PTW = 0

> [ 4703.676468] Data abort info:

> [ 4703.676471]   ISV = 0, ISS = 0x00000004

> [ 4703.676473]   CM = 0, WnR = 0

> [ 4703.676478] user pgtable: 4k pages, 48-bit VAs, pgdp=000000004a867000

> [ 4703.676481] [0000000000000090] pgd=0000000000000000, p4d=0000000000000000

> [ 4703.676503] Internal error: Oops: 96000004 [#1] PREEMPT SMP

> [ 4703.758297] Modules linked in: synaptics_dsx_i2c moal(O) mlan(O)

> [ 4703.764327] CPU: 0 PID: 235 Comm: lmkd Tainted: G        W  O      5.10.9-00001-g3f5fd8487c38-dirty #63

> [ 4703.773720] Hardware name: NXP i.MX8MNano EVK board (DT)

> [ 4703.779033] pstate: 60400085 (nZCv daIf +PAN -UAO -TCO BTYPE=--)

> [ 4703.785046] pc : _raw_write_unlock_bh+0xc0/0x2c8

> [ 4703.789667] lr : android_setup+0x4c/0x168

> [ 4703.793676] sp : ffff80001256bd80

> [ 4703.796989] x29: ffff80001256bd80 x28: 00000000000000a8

> [ 4703.802304] x27: ffff800012470000 x26: ffff80006d923000

> [ 4703.807616] x25: ffff800012471000 x24: ffff00000b091140

> [ 4703.812929] x23: ffff0000077dbd38 x22: ffff0000077da490

> [ 4703.818242] x21: ffff80001256be30 x20: 0000000000000000

> [ 4703.823554] x19: 0000000000000080 x18: ffff800012561048

> [ 4703.828867] x17: 0000000000000000 x16: 0000000000000039

> [ 4703.834180] x15: ffff8000106ad258 x14: ffff80001194c277

> [ 4703.839493] x13: 0000000000003934 x12: 0000000000000000

> [ 4703.844805] x11: 0000000000000000 x10: 0000000000000001

> [ 4703.850117] x9 : 0000000000000000 x8 : 0000000000000090

> [ 4703.855429] x7 : 6f72646e61203a70 x6 : ffff8000124f2450

> [ 4703.860742] x5 : ffffffffffffffff x4 : 0000000000000009

> [ 4703.866054] x3 : ffff8000108a290c x2 : ffff00007fb3a9c8

> [ 4703.871367] x1 : 0000000000000000 x0 : 0000000000000090

> [ 4703.876681] Call trace:

> [ 4703.879129]  _raw_write_unlock_bh+0xc0/0x2c8

> [ 4703.883397]  android_setup+0x4c/0x168

> [ 4703.887059]  udc_irq+0x824/0xa9c

> [ 4703.890287]  ci_irq+0x124/0x148

> [ 4703.893429]  __handle_irq_event_percpu+0x84/0x268

> [ 4703.898131]  handle_irq_event+0x64/0x14c

> [ 4703.902054]  handle_fasteoi_irq+0x110/0x210

> [ 4703.906236]  __handle_domain_irq+0x8c/0xd4

> [ 4703.910332]  gic_handle_irq+0x6c/0x124

> [ 4703.914081]  el1_irq+0xdc/0x1c0

> [ 4703.917221]  _raw_spin_unlock_irq+0x20/0x54

> [ 4703.921405]  finish_task_switch+0x84/0x224

> [ 4703.925502]  __schedule+0x4a4/0x734

> [ 4703.928990]  schedule+0xa0/0xe8

> [ 4703.932132]  do_notify_resume+0x150/0x184

> [ 4703.936140]  work_pending+0xc/0x40c

> [ 4703.939633] Code: d5384613 521b0a69 d5184609 f9800111 (885ffd01)

> [ 4703.945732] ---[ end trace ba5c1875ae49d53c ]---

> [ 4703.950350] Kernel panic - not syncing: Oops: Fatal exception in interrupt

> [ 4703.957223] SMP: stopping secondary CPUs

> [ 4703.961151] Kernel Offset: disabled

> [ 4703.964638] CPU features: 0x0240002,2000200c

> [ 4703.968905] Memory Limit: none

> [ 4703.971963] Rebooting in 5 seconds..

> 

> Tested-by: faqiang.zhu <faqiang.zhu@nxp.com>

> Signed-off-by: Li Jun <jun.li@nxp.com>

> ---

>  drivers/usb/chipidea/udc.c | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c

> index c16d900cdaee..393f216b9161 100644

> --- a/drivers/usb/chipidea/udc.c

> +++ b/drivers/usb/chipidea/udc.c

> @@ -2061,6 +2061,7 @@ static int udc_start(struct ci_hdrc *ci)

>  	ci->gadget.name         = ci->platdata->name;

>  	ci->gadget.otg_caps	= otg_caps;

>  	ci->gadget.sg_supported = 1;

> +	ci->gadget.irq		= ci->irq;

>  

>  	if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA)

>  		ci->gadget.quirk_avoids_skb_reserve = 1;

> -- 

> 2.25.1

> 


What commit does this fix?  Should it go to stable kernels, and if so,
how far back?

thanks,

greg k-h
Jun Li June 4, 2021, 11:10 a.m. UTC | #2
> -----Original Message-----

> From: Greg KH <gregkh@linuxfoundation.org>

> Sent: Friday, June 4, 2021 6:52 PM

> To: Jun Li <jun.li@nxp.com>

> Cc: peter.chen@kernel.org; linux-usb@vger.kernel.org; dl-linux-imx

> <linux-imx@nxp.com>; Faqiang Zhu <faqiang.zhu@nxp.com>

> Subject: Re: [PATCH] usb: chipidea: udc: assign interrupt number to USB gadget

> structure

> 

> On Fri, May 14, 2021 at 06:59:44PM +0800, Li Jun wrote:

> > Chipidea also need sync interrupt before unbind the udc while gadget

> > remove driver, otherwise setup irq handling may happen while unbind,

> > see below dump generated from android function switch stress test:

> >

...
> >

> 

> What commit does this fix?  Should it go to stable kernels, and if so,

> how far back?


I will resend the patch with fix tag added.

Li Jun
> 

> thanks,

> 

> greg k-h
Jun Li June 4, 2021, 11:34 a.m. UTC | #3
> -----Original Message-----

> From: Jun Li

> Sent: Friday, June 4, 2021 7:10 PM

> To: Greg KH <gregkh@linuxfoundation.org>

> Cc: peter.chen@kernel.org; linux-usb@vger.kernel.org; dl-linux-imx

> <linux-imx@nxp.com>; Faqiang Zhu <faqiang.zhu@nxp.com>

> Subject: RE: [PATCH] usb: chipidea: udc: assign interrupt number to USB gadget

> structure

> 

> > -----Original Message-----

> > From: Greg KH <gregkh@linuxfoundation.org>

> > Sent: Friday, June 4, 2021 6:52 PM

> > To: Jun Li <jun.li@nxp.com>

> > Cc: peter.chen@kernel.org; linux-usb@vger.kernel.org; dl-linux-imx

> > <linux-imx@nxp.com>; Faqiang Zhu <faqiang.zhu@nxp.com>

> > Subject: Re: [PATCH] usb: chipidea: udc: assign interrupt number to

> > USB gadget structure

> >

> > On Fri, May 14, 2021 at 06:59:44PM +0800, Li Jun wrote:

> > > Chipidea also need sync interrupt before unbind the udc while gadget

> > > remove driver, otherwise setup irq handling may happen while unbind,

> > > see below dump generated from android function switch stress test:

> > >

> ...

> > >

> >

> > What commit does this fix?  Should it go to stable kernels, and if so,

> > how far back?

> 

> I will resend the patch with fix tag added.


Hi Greg,

I assume this problem may exist all along or very far, but this patch
need base one commit[1] to fix this problem, so I think that commit is
the point to know how far this patch can apply back for stable kernels,
in this case, please let me know if adding fix tag pointing to that commit
still the right way for this.

[1] 3c73bc52195d ("usb: gadget: core: sync interrupt before unbind the udc")

thanks
Li Jun

> 

> Li Jun

> >

> > thanks,

> >

> > greg k-h
Greg Kroah-Hartman June 9, 2021, 8:26 a.m. UTC | #4
On Fri, Jun 04, 2021 at 11:34:53AM +0000, Jun Li wrote:
> 

> 

> > -----Original Message-----

> > From: Jun Li

> > Sent: Friday, June 4, 2021 7:10 PM

> > To: Greg KH <gregkh@linuxfoundation.org>

> > Cc: peter.chen@kernel.org; linux-usb@vger.kernel.org; dl-linux-imx

> > <linux-imx@nxp.com>; Faqiang Zhu <faqiang.zhu@nxp.com>

> > Subject: RE: [PATCH] usb: chipidea: udc: assign interrupt number to USB gadget

> > structure

> > 

> > > -----Original Message-----

> > > From: Greg KH <gregkh@linuxfoundation.org>

> > > Sent: Friday, June 4, 2021 6:52 PM

> > > To: Jun Li <jun.li@nxp.com>

> > > Cc: peter.chen@kernel.org; linux-usb@vger.kernel.org; dl-linux-imx

> > > <linux-imx@nxp.com>; Faqiang Zhu <faqiang.zhu@nxp.com>

> > > Subject: Re: [PATCH] usb: chipidea: udc: assign interrupt number to

> > > USB gadget structure

> > >

> > > On Fri, May 14, 2021 at 06:59:44PM +0800, Li Jun wrote:

> > > > Chipidea also need sync interrupt before unbind the udc while gadget

> > > > remove driver, otherwise setup irq handling may happen while unbind,

> > > > see below dump generated from android function switch stress test:

> > > >

> > ...

> > > >

> > >

> > > What commit does this fix?  Should it go to stable kernels, and if so,

> > > how far back?

> > 

> > I will resend the patch with fix tag added.

> 

> Hi Greg,

> 

> I assume this problem may exist all along or very far, but this patch

> need base one commit[1] to fix this problem, so I think that commit is

> the point to know how far this patch can apply back for stable kernels,

> in this case, please let me know if adding fix tag pointing to that commit

> still the right way for this.

> 

> [1] 3c73bc52195d ("usb: gadget: core: sync interrupt before unbind the udc")


Yes, that's fine and the correct way to do it.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c16d900cdaee..393f216b9161 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -2061,6 +2061,7 @@  static int udc_start(struct ci_hdrc *ci)
 	ci->gadget.name         = ci->platdata->name;
 	ci->gadget.otg_caps	= otg_caps;
 	ci->gadget.sg_supported = 1;
+	ci->gadget.irq		= ci->irq;
 
 	if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA)
 		ci->gadget.quirk_avoids_skb_reserve = 1;