Files
kernel_common_drivers/drivers/usb
dian.shao d8080d215f usb: crg udc setup packet gadget callback fix [1/1]
PD#SWPL-185811

Problem:
1.
[ 7452.363304][ C0] Kernel panic - not syncing: CFI failure (target: 0x100)
[ 7452.363308][ C0] CPU: 0 PID: 27983 Comm: kworker/0:1
		Tainted: P W OE 5.15.137-android13-8-00022-g99538831203c-ab11798676 #1
[ 7452.377051][ C0] Hardware name: Amlogic (DT)
[ 7452.377055][ C0] Workqueue: events android_work.cfi_jt
[ 7452.390224][ C0] Call trace:
[ 7452.390225][ C0] dump_backtrace.cfi_jt+0x0/0x8
[ 7452.390233][ C0] dump_stack_lvl+0x80/0xb8
[ 7452.390240][ C0] panic+0x190/0x44c
[ 7452.390245][ C0] find_check_fn+0x0/0x218
[ 7452.478102][ C0] req_done+0x124/0x128 [amlogic_usb]
[ 7452.497429][ C0] handle_cmpl_code_success+0x94/0x164 [amlogic_usb]
[ 7452.502114][ T1] [usb]: crg_gadget_async_callbacks get state 1
[ 7452.511209][ C0] crg_handle_xfer_event+0x154/0x450 [amlogic_usb]
[ 7452.589903][ C0] crg_udc_handle_event+0x80/0x100 [amlogic_usb]
[ 7452.596056][ C0] process_event_ring+0xb4/0x13c [amlogic_usb]
[ 7452.602036][ C0] crg_gadget_handle_interrupt+0x70/0x254 [amlogic_usb]
[ 7452.608797][ C0] crg_udc_common_irq+0x18/0x2c [amlogic_usb]
[ 7452.609362][ C2] [RX]-rx_pll_clk_enable!
[ 7452.614690][ C0] __handle_irq_event_percpu+0xf4/0x390
[ 7452.614700][ C0] handle_irq_event+0x84/0x16c
[ 7452.628816][ C0] handle_fasteoi_irq+0x150/0x2f0
[ 7452.633669][ C0] handle_domain_irq+0x9c/0x120
[ 7452.638349][ C0] gic_handle_irq+0x60/0x12c
[ 7452.642769][ C0] do_interrupt_handler+0x64/0xa0
[ 7452.647622][ C0] el1_interrupt+0x34/0x64
[ 7452.651869][ C0] el1h_64_irq_handler+0x1c/0x2c
[ 7452.656636][ C0] el1h_64_irq+0x7c/0x80
[ 7452.660709][ C0] _stext+0x114/0x610
[ 7452.664522][ C0] __irq_exit_rcu+0x74/0x140
[ 7452.668942][ C0] handle_domain_irq+0xa0/0x120
[ 7452.673622][ C0] gic_handle_irq+0x60/0x12c
[ 7452.678042][ C0] call_on_irq_stack+0x3c/0x70
[ 7452.682636][ C0] do_interrupt_handler+0x44/0xa0
[ 7452.687489][ C0] el1_interrupt+0x34/0x64
[ 7452.691736][ C0] el1h_64_irq_handler+0x1c/0x2c
[ 7452.696502][ C0] el1h_64_irq+0x7c/0x80
[ 7452.700576][ C0] console_unlock+0x540/0xdf8
[ 7452.705082][ C0] vprintk_emit+0xc4/0x174
[ 7452.709329][ C0] vprintk+0x13c/0x1a0
[ 7452.713229][ C0] _printk+0x58/0x84
[ 7452.716956][ C0] android_work+0x19c/0x2a0
[ 7452.721289][ C0] process_one_work+0x248/0x55c
[ 7452.725969][ C0] worker_thread+0x3b0/0x740
[ 7452.730389][ C0] kthread+0x168/0x1dc
[ 7452.734289][ C0] ret_from_fork+0x10/0x20
[ 7452.738537][ C0] SMP: stopping secondary CPUs
[ 7452.743142][ C0] Kernel Offset: 0x1300000000 from 0xffffffc008000000

2.
[  781.124760][    C0] [usb]: udc_ep_ptr->queue not empty
[  781.131723][    C0] list_add double add: new=ffffffe40248b548,
			prev=ffffffe40248b548, next=ffffffe402489a80.
[  781.141545][    C0] ------------[ cut here ]------------
[  781.146800][    C0] kernel BUG at lib/list_debug.c:35!
[  781.151914][    C0] Internal error: Oops - BUG: 00000000f2000800
			[#1] PREEMPT SMP
...
[  781.391814][    C0] Call trace:
[  781.391817][    C0]  __list_add_valid+0x70/0xc0
[  781.391824][    C0]  build_ep0_status+0x100/0x12c [amlogic_usb]
[  781.400647][    C0]  crg_handle_setup_pkt+0x11c/0x2d4 [amlogic_usb]
[  781.522500][    C0]  crg_udc_handle_event+0xa0/0x100 [amlogic_usb]
[  781.528654][    C0]  process_event_ring+0xb4/0x13c [amlogic_usb]
[  781.534633][    C0]  crg_gadget_handle_interrupt+0x70/0x254 [amlogic_usb]
[  781.541394][    C0]  crg_udc_common_irq+0x18/0x2c [amlogic_usb]
[  781.547287][    C0]  __handle_irq_event_percpu+0xf4/0x390
[  781.552660][    C0]  handle_irq_event+0x84/0x16c
[  781.557254][    C0]  handle_fasteoi_irq+0x150/0x2f0
[  781.562106][    C0]  handle_domain_irq+0x9c/0x120
[  781.566786][    C0]  gic_handle_irq+0x60/0x12c
[  781.571206][    C0]  call_on_irq_stack+0x3c/0x70
[  781.575800][    C0]  do_interrupt_handler+0x44/0xa0
[  781.580653][    C0]  el1_interrupt+0x34/0x64
[  781.584900][    C0]  el1h_64_irq_handler+0x1c/0x2c
[  781.589666][    C0]  el1h_64_irq+0x7c/0x80
[  781.589670][    C0]  cpuidle_enter_state+0x3b4/0x87c
[  781.589676][    C0]  do_idle+0x300/0x598
[  781.589680][    C0]  cpu_startup_entry+0x84/0x90
[  781.589684][    C0]  kernel_init+0x0/0x37c
[  781.601539][    C0]  start_kernel+0x0/0x66c
[  781.601547][    C0]  start_kernel+0x51c/0x66c
[  781.601551][    C0]  __primary_switched+0xc8/0x7c60
[  781.601560][    C0] Code: f000a600 aa0803e2 91205000 97e0d8e9 (d4210000)
[  781.610381][    C0] ---[ end trace 4b8b98e6f16a95cb ]---
[  781.628820][    C0] Kernel panic - not syncing: Oops - BUG: Fatal exception
			in interrupt
[  781.671222][    C0] SMP: stopping secondary CPUs
[  781.675828][    C0] Kernel Offset: 0x2400000000 from 0xffffffc008000000
[  781.682400][    C0] PHYS_OFFSET: 0x0
[  781.685953][    C0] CPU features: 0x0,0000c9a1,00000846
[  781.691153][    C0] Memory Limit: none

Solution:
1.
The ep0 reqs can't be dequeued unless the controller is reinited.
Remove the ep0 dequeue codes or the hw cached irq may fetch
wrong reqs ptr from the ep0 req queue causing kernel panic.
2.
The locking sequence is unnecessary before the sync_cb_flag
check and is error-prone. Remove it.
Add ep0 req list empty check to prevent potential racing of
the setup_status.

Verify:
Customer projects.

Change-Id: I8433f3afe07cad6468593104460e21b56c63ffa5
Signed-off-by: dian.shao <dian.shao@amlogic.com>
2024-11-07 06:48:43 -08:00
..
2023-12-22 16:08:59 +08:00
2023-12-22 16:08:59 +08:00
2024-09-03 18:52:09 -07:00