This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OMAP5 usb gadget in-pipe locked (can't enqueue by "usb_ep_queue" function)

Other Parts Discussed in Thread: 4460

Hello,
I got a USB bulk transfer fail on gadget driver at OMAP 5432 ES2.0.
This function works fine on OMAP 4460.

SDK:
ti-glsdk_omap5-uevm_6_03_00_01

Setting:
The USB interface includes in-pipe and out-pipe with bulk mode.

Symptom:
The in-bulk can't trigger the completion callback function after some transfers (or can't queue input data). At this moment host application is read-pending locked. That isn't fail immediately and it is locked after some transmition randomly.

status = usb_ep_queue(in_ep, Req, GFP_ATOMIC);
if (status)
  ERROR(cdev, "%s:%s queue req --> %d\n", __func__, mipi->in_ep->name, status);

Even re-queue a new in-request, its in-queue complete-callback still can't  be triggered(host issued a read function and is pending to get data).

The usb_ep_queue() function hasn't reported error condition.

When in-pipe locked, the out-pipe is still workable.

Where is good entry let me can trace that code? I can't find the queue-callback entry of usb-ep-ops for to debug it.
Please help/give me some comments!

Best regards,
T.J.Hsu

  • Hello T.J.Hsu,

    I would like to notice that there is an USB issue in OMAP5 GLSDK 6.03.00.01 USB: DWC3: usb device plugin on cold start does not get detected and gets detected & workafter unplug/plug of device.

    This issue is solved in OMAP5 GLSDK 6.04.00.02. Apply the following patch in your GLSDK - http://review.omapzoom.org/#/c/35073/

    Did you enable gadget support in your .config file. By default GADGET support is not set:

    #
    # Miscellaneous USB options
    #
    # CONFIG_USB_DYNAMIC_MINORS is not set
    CONFIG_USB_SUSPEND=y
    # CONFIG_USB_OTG is not set
    # CONFIG_USB_OTG_WHITELIST is not set
    # CONFIG_USB_OTG_BLACKLIST_HUB is not set
    CONFIG_USB_DWC3=m
    # CONFIG_USB_DWC3_HOST is not set
    # CONFIG_USB_DWC3_GADGET is not set
    CONFIG_USB_DWC3_DUAL_ROLE=y
    # CONFIG_USB_DWC3_DEBUG is not set
    CONFIG_USB_MON=y
    # CONFIG_USB_WUSB_CBAF is not set

    #
    # USB Physical Layer drivers
    #
    CONFIG_OMAP_USB3=m
    CONFIG_OMAP_CONTROL_USB=m
    # CONFIG_USB_ISP1301 is not set
    # CONFIG_USB_RCAR_PHY is not set
    CONFIG_USB_GADGET=y
    # CONFIG_USB_GADGET_DEBUG is not set
    CONFIG_USB_GADGET_DEBUG_FILES=y
    CONFIG_USB_GADGET_DEBUG_FS=y
    CONFIG_USB_GADGET_VBUS_DRAW=2
    CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2

    Best regards,

    Yanko

  • Dear Yanko,
    Thanks your answer!
    I have ported this USB gadget to GLSDK 6.04.00.02 and updates patches. But this symptom still happens.

    For USB, I set it  device mode only!

    My gadget support setting as:

    #
    # Miscellaneous USB options
    #
    # CONFIG_USB_DYNAMIC_MINORS is not set
    # CONFIG_USB_SUSPEND is not set
    # CONFIG_USB_OTG_WHITELIST is not set
    # CONFIG_USB_OTG_BLACKLIST_HUB is not set
    CONFIG_USB_DWC3=m
    # CONFIG_USB_DWC3_HOST is not set
    CONFIG_USB_DWC3_GADGET=y
    # CONFIG_USB_DWC3_DUAL_ROLE is not set
    # CONFIG_USB_DWC3_DEBUG is not set
    CONFIG_USB_MON=y
    # CONFIG_USB_WUSB_CBAF is not set

    #
    # USB Physical Layer drivers
    #
    CONFIG_OMAP_USB2=m
    CONFIG_OMAP_USB3=m
    CONFIG_OMAP_CONTROL_USB=y
    # CONFIG_USB_ISP1301 is not set
    # CONFIG_USB_RCAR_PHY is not set
    CONFIG_USB_GADGET=y
    CONFIG_USB_GADGET_DEBUG=y
    CONFIG_USB_GADGET_DEBUG_FILES=y
    CONFIG_USB_GADGET_DEBUG_FS=y
    CONFIG_USB_GADGET_VBUS_DRAW=2
    CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2


    //--------------------------------

    Let me explain my test-procedure again.
    My PC program starts test procedure by written a start command to an out-bulk-pipe; and then continuously read back dummy data from another in-bulk-pipe. The dummy data is created in gadget-io-complete routine then enqueues it to in-pipe queue("usb_ep_queue" function).

    ...
    WritePipe(UsbHandle, BulkPipeOut, startTest, ...);  // start loopback testing
    ..
    while (TRUE)  // continue read loop
    {
       ReadPipe(UsbHandle, BulkPipe, RcvBuffer, ...);
       ....
    }

    Every read buffer size is 8192 bytes.

    //--------------------------------
    I  track program code of DWC3/gadget.c; found function dwc3_endpoint_interrupt() doesn't get the last transfer(DWC3_DEPEVT_XFERNOTREADY) completed message ( DWC3_DEPEVT_XFERCOMPLETE). So the ReadPipe(UsbHandle, BulkPipe, RcvBuffer, ...) of host is locked.
    some dump as:


    ....
    [  147.225219] test_io_complete: in data cnt=12647                                              <--- new data 12647 en-queue
    [  147.225219] __dwc3_gadget_ep_queue:sent=12646 completed=12646           <--- had sent and gotten count
    [  147.225219] dwc3_endpoint_interrupt:kick_transfer.                                          <--- try kick transfer 12647 data
    [  147.225219] __dwc3_gadget_kick_transfer() run                                                <---- transfer routine
    [  147.228515] dwc3_endpoint_interrupt:complete.                                                <---- transfer complete 12647 done
    [  147.228515]  test_io_complete: in data cnt=12648                                             <---- new data 12648 en-queue
    [  147.228515] __dwc3_gadget_ep_queue:sent=12647 completed=12647           <--- had sent and gotten count
    [  147.228515] dwc3_endpoint_interrupt:kick_transfer.                                          <--- try kick transfer 12647 data
    [  147.228515] __dwc3_gadget_kick_transfer() run                                                <---  transfer routine

    Locked here !!!

    When locked, the out-pipe still lives. the locked count is random.

    Thanks!
    T.J.Hsu
     

  • Dear Yanko,
    Have you updates about the this continuously read USB locked issue?
    I almost have traced all code about DWC3/gadget.c and checking most registers setting of USB device-mode endpoints(OMAP543x Multimedia Device Technical Reference Manual). But I still can't solve this locked issued.
    A special case,
    a printk (KERN_INFO "\n") added into  __dwc3_gadget_kick_transfer() and set it before dwc3_send_gadget_ep_cmd(), this symptom is gone.

    static int __dwc3_gadget_kick_transfer( ...)
    {
        ....
        printk (KERN_INFO "\n") ;
        ...
        ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
        ...

    }

    if this printk() is added after dwc3_send_gadget_ep_cmd(), this symptom keep going.

    Sometime I got kernel crashed messages as:

    ....

    [   86.935089] 60006
    [   86.937103] 60006
    [   86.939117] 60006
    [   86.941131] 60006
    [   86.943115] INFO: rcu_preempt self-detected stall on CPU { 0}  (t=2688 jiffies g=181 c=180 q=31)
    [   86.952301] [<c001b508>] (unwind_backtrace+0x0/0xf0) from [<c00adb2c>] (rcu_check_callbacks+0x358/0x97c)
    [   86.958312] INFO: rcu_preempt detected stalls on CPUs/tasks: { 0} (detected by 1, t=2690 jiffies, g=181, c=180, q=31)
    [   86.958312] Task dump for CPU 0:
    [   86.958343] swapper/0       R running      0     0      0 0x00000002
    [   86.958343] [<c0565414>] (__schedule+0x388/0x7f8) from [<ffffffff>] (0xffffffff)
    [   86.990875] [<c00adb2c>] (rcu_check_callbacks+0x358/0x97c) from [<c0055e64>] (update_process_times+0x3c/0x6c)
    [   87.001190] [<c0055e64>] (update_process_times+0x3c/0x6c) from [<c008e778>] (tick_sched_handle+0x48/0x54)
    [   87.011169] [<c008e778>] (tick_sched_handle+0x48/0x54) from [<c008ea04>] (tick_sched_timer+0x58/0x8c)
    [   87.020782] [<c008ea04>] (tick_sched_timer+0x58/0x8c) from [<c006b464>] (__run_hrtimer+0x7c/0x27c)
    [   87.030090] [<c006b464>] (__run_hrtimer+0x7c/0x27c) from [<c006c190>] (hrtimer_interrupt+0x108/0x2b0)
    [   87.039703] [<c006c190>] (hrtimer_interrupt+0x108/0x2b0) from [<c0019e00>] (arch_timer_handler_virt+0x34/0x3c)
    [   87.050109] [<c0019e00>] (arch_timer_handler_virt+0x34/0x3c) from [<c00a8310>] (handle_percpu_devid_irq+0x90/0x180)
    [   87.060974] [<c00a8310>] (handle_percpu_devid_irq+0x90/0x180) from [<c00a4b48>] (generic_handle_irq+0x20/0x30)
    [   87.071411] [<c00a4b48>] (generic_handle_irq+0x20/0x30) from [<c0014728>] (handle_IRQ+0x4c/0xb0)
    [   87.080566] [<c0014728>] (handle_IRQ+0x4c/0xb0) from [<c0008500>] (gic_handle_irq+0x28/0x5c)
    [   87.089355] [<c0008500>] (gic_handle_irq+0x28/0x5c) from [<c0567064>] (__irq_svc+0x44/0x7c)
    [   87.098052] Exception stack(0xc083de40 to 0xc083de88)
    [   87.103302] de40: 00000001 00000000 00000000 00000000 c0915c80 ede4fcbc 00000004 c02af6a8
    [   87.111816] de60: c083c000 00000000 c083dea8 ede4ec00 ffff8b00 c083de88 c0095d00 c0566b5c
    [   87.120330] de80: 60000113 ffffffff
    [   87.123962] [<c0567064>] (__irq_svc+0x44/0x7c) from [<c0566b5c>] (_raw_spin_unlock_irq+0x28/0x50)
    [   87.133209] [<c0566b5c>] (_raw_spin_unlock_irq+0x28/0x50) from [<c0054aac>] (run_timer_softirq+0x194/0x2b8)
    [   87.143371] [<c0054aac>] (run_timer_softirq+0x194/0x2b8) from [<c004dbf4>] (__do_softirq+0xe8/0x28c)
    [   87.152893] [<c004dbf4>] (__do_softirq+0xe8/0x28c) from [<c004e140>] (irq_exit+0x98/0xa4)
    [   87.161407] [<c004e140>] (irq_exit+0x98/0xa4) from [<c001472c>] (handle_IRQ+0x50/0xb0)
    [   87.169647] [<c001472c>] (handle_IRQ+0x50/0xb0) from [<c0008500>] (gic_handle_irq+0x28/0x5c)
    [   87.178405] [<c0008500>] (gic_handle_irq+0x28/0x5c) from [<c0567064>] (__irq_svc+0x44/0x7c)
    [   87.187103] Exception stack(0xc083df58 to 0xc083dfa0)
    [   87.192352] df40:                                                       00000001 00000001
    [   87.200897] df60: 00000000 c0032670 c083c000 c083c000 c0903008 c0572b2c c083c000 00000000
    [   87.209411] df80: c0849250 00000000 c0019e44 c083dfa0 c0095d44 c001497c 20000013 ffffffff
    [   87.217926] [<c0567064>] (__irq_svc+0x44/0x7c) from [<c001497c>] (default_idle+0x20/0x3c)
    [   87.226440] [<c001497c>] (default_idle+0x20/0x3c) from [<c0014af8>] (cpu_idle+0x4c/0xfc)
    [   87.234863] [<c0014af8>] (cpu_idle+0x4c/0xfc) from [<c07e27b8>] (start_kernel+0x2ac/0x2fc)
    [   87.243499] 60006
    [   87.245513] 60006

    Value "60006" is USBOTGSS_DEPCMD_i dumped from dwc3_send_gadget_ep_cmd.

    Best regards,

    T.J.

  • Hello T.J.

    dwc3_send_gadget_ep_cmd() will sleep in wait_for_completion_timeout() until the command completes.

    I suggest you referring to the sequence described in the link http://processors.wiki.ti.com/index.php/Linux_Core_DWC3_User%27s_Guide

    I think that you must set dr mode to configure USB ports of OMAP5 as host. Apply this in the file  arch/arm/boot/dts/ omap5-uevm.dts

    Best regards,

    Yanko

  • Hello T.J.

    Have you checked if DWC3 modules are enabled in your omap2plus_defconfig file?

    To enable dwc3 usb and its dependent modules
    The following configs are enabled for dwc3 usb configuration
    CONFIG_USB_DWC3_DUAL_ROLE=y
    CONFIG_USB_XHCI_HCD=y
    CONFIG_USB_XHCI_PLATFORM=y
    CONFIG_EXTCON=y
    CONFIG_OF_EXTCON=y
    CONFIG_EXTCON_GPIO_USBVID=y

    See in arch/arm/configs/android_omap_defconfig file.

    Best regards,
    Yanko
  • Dear Yanko,
    Thanks!
    Yes, I have enabled the DWC3 driver module. And I have tested the DWC3 in dual role mode as your commented at Jul 07; but it doesn't evidently improve.
    Let me do  more checking and testing.
    Best regards,
    T.J.hsu