From 39d9d287b3570b7c986a2a141872b7d0543e6745 Mon Sep 17 00:00:00 2001 From: Dragan Cecavac Date: Thu, 23 Feb 2017 17:39:16 +0100 Subject: [PATCH] MIPS: ci20: fix multiple endpoints handling for dwc2 gadget Before this patch, using multiple active endpoints would not be possible and would actually be canceling each other out. The issue was discovered on Android when combining adb, mtp and ptp configurations together. This patch introduces proper behaviour for these cases. Also, during the boot-up the following warning is no longer shown: [ 2.879328] ------------[ cut here ]------------ [ 2.883983] WARNING: CPU: 0 PID: 1 at drivers/usb/dwc2/gadget.c:212 s3c_hsotg_init_fifo+0x168/0x1d0() [ 2.893204] insufficient fifo memory [ 2.896602] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 3.18.3+ #10 [ 2.904004] Stack : 00000000 800919a0 00000000 00000004 00000006 800913f4 00000000 00000000 00000000 00000000 80f75a12 00000042 80f75a12 00000042 00000006 00000000 80e42767 80d7c2e0 00000001 00000000 80f73574 8bc90418 80ea0000 01000d00 80f06704 80b24c00 00000000 80035388 00000006 00000000 80d834a4 8bc99b04 8bc99b04 80e40000 00000000 00000000 00000000 00000000 00000000 00000000 ... [ 2.939709] Call Trace: [ 2.942174] [<8001bab0>] show_stack+0xd4/0xf0 [ 2.946528] [<80b26c40>] dump_stack+0x70/0xbc [ 2.950880] [<800356bc>] warn_slowpath_common+0x90/0xe8 [ 2.956116] [<80035808>] warn_slowpath_fmt+0x3c/0x48 [ 2.961075] [<8069b824>] s3c_hsotg_init_fifo+0x168/0x1d0 [ 2.966398] [<8069d8fc>] s3c_hsotg_init+0x50/0x9c [ 2.971095] [<806a0388>] dwc2_gadget_init+0x430/0x8c0 [ 2.976158] [<806a0df0>] dwc2_driver_probe+0x218/0x2a8 [ 2.981291] [<805b935c>] platform_drv_probe+0x64/0x120 [ 2.986440] [<805b783c>] really_probe+0xa0/0x278 [ 2.991050] [<805b7c78>] driver_probe_device+0x48/0x78 [ 2.996197] [<805b7d74>] __driver_attach+0xcc/0xd4 [ 3.000980] [<805b5b7c>] bus_for_each_dev+0x7c/0xc4 [ 3.005874] [<805b64f8>] bus_add_driver+0x180/0x240 [ 3.010743] [<805b8428>] driver_register+0xac/0x154 [ 3.015633] [<80ea9e04>] do_one_initcall+0x150/0x1f4 [ 3.020589] [<80eaa080>] kernel_init_freeable+0x1d8/0x298 [ 3.025998] [<80b23c5c>] kernel_init+0x28/0x158 [ 3.030522] [<800153ec>] ret_from_kernel_thread+0x14/0x1c [ 3.035926] [ 3.037412] ---[ end trace cb88537fdc8fa201 ]--- And during configuration transitions (e.g. adb -> mtp,adb) the following warning is no longer shown: [ 311.726159] -----------[ cut here ]----------- [ 311.730817] WARNING: CPU: 0 PID: 0 at drivers/usb/dwc2/gadget.c:1475 s3c_hsotg_rx_data+0x130/0x13c() [ 311.739931] Modules linked in: [ 311.742993] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 3.18.3+ #45 [ 311.750199] Stack : 00000000 80080370 00000000 00000004 00000006 00000000 00000000 00000000 00000000 00000000 80f05b02 00000042 80d61010 80e18e20 80d60000 8b408010 80e18927 80d0df6c 00000000 00000000 80f03614 80e18e20 80d60000 8b408010 00250182 80a54f54 80e20cc4 80e20cc8 00000000 00000000 80d14ab8 80dfbacc 80dfbacc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ... [ 311.785841] Call Trace: [ 311.788292] [<8001ac28>] show_stack+0xc4/0xe0 [ 311.792650] [<80a56e58>] dump_stack+0x70/0xbc [ 311.797008] [<80033c14>] warn_slowpath_common+0x88/0xb8 [ 311.802224] [<80033cc8>] warn_slowpath_null+0x18/0x24 [ 311.807266] [<80606a3c>] s3c_hsotg_rx_data+0x130/0x13c [ 311.812397] [<8060afa4>] s3c_hsotg_irq+0x3b4/0x5e8 [ 311.817183] [<80082ab8>] handle_irq_event_percpu+0x90/0x2d0 [ 311.822745] [<80082d4c>] handle_irq_event+0x54/0x98 [ 311.827617] [<80086390>] handle_level_irq+0xe0/0x1c0 [ 311.832572] [<800820bc>] generic_handle_irq+0x3c/0x54 [ 311.837622] [<804bb680>] jz4740_cascade+0x78/0xac [ 311.842317] [<80082ab8>] handle_irq_event_percpu+0x90/0x2d0 [ 311.847881] [<80086d18>] handle_percpu_irq+0x8c/0xbc [ 311.852835] [<800820bc>] generic_handle_irq+0x3c/0x54 [ 311.857878] [<80016c8c>] do_IRQ+0x18/0x2c [ 311.861879] [<80014c40>] ret_from_irq+0x0/0x4 [ 311.866227] [<80016b20>] mips_cpuidle_wait_enter+0x14/0x34 [ 311.871713] [<806d37b0>] cpuidle_enter_state+0x88/0x2c0 [ 311.876934] [<80074308>] cpu_startup_entry+0x36c/0x484 [ 311.882074] [<80e7dc04>] start_kernel+0x4b8/0x4e0 [ 311.886767] [ 311.888253] --[ end trace dd7a60dcc5530db3 ]-- Change-Id: Ic8ac37a28913d4314371de0cd446f8a7cc45864d Signed-off-by: Dragan Cecavac --- arch/mips/boot/dts/jz4780.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/boot/dts/jz4780.dtsi b/arch/mips/boot/dts/jz4780.dtsi index 69aaea5846e4c1..228e295b71ad0e 100644 --- a/arch/mips/boot/dts/jz4780.dtsi +++ b/arch/mips/boot/dts/jz4780.dtsi @@ -770,6 +770,7 @@ phys = <&usb_phy>; phy-names = "usb2-phy"; + g-rx-fifo-size = <256>; g-tx-fifo-size = <256 256 256 256>; }; };