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.

Linux: AM335x Quad-USB-to-UART Bridge (CP2108) Communcation Freeze

Tool/software: Linux

When I repeatedly open and close ttyUSB0, ttyUSB1, ttyUSB2, ttyUSB3 several times, errors will occur.

All the ttyUSB0, ttyUSB1, ttyUSB2, ttyUSB3  devices can no longer be open agin,  Here is the error message:

[ 185.127665] cp210x ttyUSB2: failed set request 0x0 status: -110

The requested massage  is sent through this usb_control_msg()  API

Please help me,  what causes it and how to repair it.

Thanks

Shuming

 

  • Please post which Linux version you use.
  • Hi Biser

    Linux version is : Linux version 4.14.40-rt29-gd5443cbd3b

    Thanks

    Shuming
  • Hi Shuming,

    Do you see the same problem with non-RT kernel from Processor SDK?
    Is this on your custom board or any AM335x EVM?
  • Hi Biser

    I get the sdk "ti-processor-sdk-linux-am335x-evm-05.03.00.07" from " software-dl.ti.com/.../index_FDS.html"

    compiler the non-RT kernel, after the system boot done, I can't find any usb device

    root@NECRO:~# ls /proc/bus/
    input pci
    root@NECRO:~# cat /proc/version
    Linux version 4.14.79-ge669d52447 (fan@ubuntu) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5 PREEMPT Mon Apr 15 05:55:41 PDT 2019

    root@NECRO:~# lsusb
    unable to initialize libusb: -99

    Thanks
    Shuming
  • Hi Shuming,
    The error message '-99' means the usb kernel drivers failed to initialize USB, most likely the drivers are not installed properly.
    When you update the kernel zImage, you also have to update the kernel modules as well.
  • Hi Bin

    Thanks for you reply, I update the new kernel modules, no error message '-99',

    but ,the same timeout error message in the non-RT kernel
    [ 218.640713] cp210x ttyUSB2: failed set request 0x12 status: -110
    [ 223.680714] cp210x ttyUSB2: failed set request 0x0 status: -110


    root@NECRO:~# cat /proc/version
    Linux version 4.14.79-ge669d52447 (fan@ubuntu) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #6 PREEMPT Mon Apr 15 18:04:56 PDT 2019


    Thanks
  • Hi,

    Can you please attach /proc/config.gz you have on your non-rt kernel?
    I tested my cp2108 device (vid:pid - 10c4:ea71) on non-rt TI v4.14.40 kernel but was unable to see the issue.

    How do you exactly run the test? using cat command to open the ports or something else?
    I did 'cat' and 'serial-test' util, but none of them can produce the failure.

    Do you see the problem on your custom board, or any TI AM335x EVM, such as Beaglebone Black?
  • 2818.config.gz

    Hi Bin,

    The flowing is my test steps on non-RT kernel. 

    root@NECRO:~# ls /dev/ttyUSB*

    /dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3

    root@NECRO:~# cat /proc/version

    Linux version 4.14.79-ge669d52447 (fan@ubuntu) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #6 PREEMPT Mon Apr 15 18:04:56 PDT 2019

    root@NECRO:~# cat /dev/ttyUSB1 &

    [1] 717

    root@NECRO:~# kill $(pidof cat)

    root@NECRO:~# cat /dev/ttyUSB2 &

    [2] 721

    [1]   Terminated              cat /dev/ttyUSB1

    root@NECRO:~# kill $(pidof cat)

    root@NECRO:~# cat /dev/ttyUSB3 &

    [3] 724

    [2]   Terminated              cat /dev/ttyUSB2

    root@NECRO:~# kill $(pidof cat)

    root@NECRO:~# cat /dev/ttyUSB1 &

    [1] 728

    root@NECRO:~# kill $(pidof cat)

    root@NECRO:~# cat /dev/ttyUSB0 &

    [2] 733

    [1]   Terminated              cat /dev/ttyUSB1

    root@NECRO:~# kill $(pidof cat)

    root@NECRO:~# cat /dev/ttyUSB3 &

    [3] 737

    root@NECRO:~# [  233.600688] cp210x ttyUSB0: failed set request 0x12 status: -110

    [  237.760719] cp210x ttyUSB3: failed set request 0x0 status: -110

    [  237.766724] cp210x ttyUSB3: cp210x_open - Unable to enable UART

    cat: can't open '/dev/ttyUSB3': Input/output error

    [  238.640691] cp210x ttyUSB0: failed set request 0x0 status: -110

    This error on my custom board, I have no TI AM335x EVM board.

    Thanks

    Shuming

  • We had a similar issue a work around i found was to unload and reload musb_dsps and musb_hdrc, this might help you out for the time being

    These modules should be under "/lib/modules/$(uname -r)/kernel/drivers/usb/musb"

    unload:
    rmmod musb_dsps
    rmmod musb_hdrc

    reload:
    insmod musb_hdrc.ko
    insmod musb_dsps.ko

    This is just a workaround though.

  • Hi Ben,

    I tested the same kernel with your .config, but was unable to see the problem.

    Here is the test script I used, ran for almost 30min until now.

    #!/bin/sh
    while true; do
            for i in 0 1 2 3; do
                    cat /dev/ttyUSB${i} || exit 1 &
                    sleep 1
                    kill $(pidof cat) || exit 2
                    sleep 1
            done
    done
    

    By the way, attached below is a kernel patch fixing a cppi driver bug. I don't think it is related, but can you please give it a try?

    From 01a3e84503d595623be207943e01b34028320025 Mon Sep 17 00:00:00 2001
    From: Bin Liu <b-liu@ti.com>
    Date: Fri, 9 Nov 2018 14:54:06 -0600
    Subject: [PATCH] dma: cppi41: delete channel from pending list when stop
     channel
    
    The driver defines three states for a cppi channel.
    - idle: .chan_busy == 0 && not in .pending list
    - pending: .chan_busy == 0 && in .pending list
    - busy: .chan_busy == 1 && not in .pending list
    
    There are cases in which the cppi channel could be in the pending state
    when cppi41_dma_issue_pending() is called after cppi41_runtime_suspend()
    is called.
    
    cppi41_stop_chan() has a bug for these cases to set channels to idle state.
    It only checks the .chan_busy flag, but not the .pending list, then later
    when cppi41_runtime_resume() is called the channels in .pending list will
    be transitioned to busy state.
    
    Removing channels from the .pending list solves the problem.
    
    Fixes: 975faaeb9985 ("dma: cppi41: start tear down only if channel is busy")
    Cc: stable@vger.kernel.org # v3.15+
    Signed-off-by: Bin Liu <b-liu@ti.com>
    ---
     drivers/dma/ti/cppi41.c | 16 +++++++++++++++-
     1 file changed, 15 insertions(+), 1 deletion(-)
    
    diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
    index beab6d1dea93..f28be46bd3a2 100644
    --- a/drivers/dma/ti/cppi41.c
    +++ b/drivers/dma/ti/cppi41.c
    @@ -723,8 +723,22 @@ static int cppi41_stop_chan(struct dma_chan *chan)
     
     	desc_phys = lower_32_bits(c->desc_phys);
     	desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
    -	if (!cdd->chan_busy[desc_num])
    +	if (!cdd->chan_busy[desc_num]) {
    +		struct cppi41_channel *cc, *_ct;
    +
    +		/*
    +		 * channels might still be in the pendling list if
    +		 * cppi41_dma_issue_pending() is called after
    +		 * cppi41_runtime_suspend() is called
    +		 */
    +		list_for_each_entry_safe(cc, _ct, &cdd->pending, node) {
    +			if (cc != c)
    +				continue;
    +			list_del(&cc->node);
    +			break;
    +		}
     		return 0;
    +	}
     
     	ret = cppi41_tear_down_chan(c);
     	if (ret)
    -- 
    2.17.1
    
    

  • Do you have a USB hub on your custom board?
  • Hi Bin

    Yes, I have USB hub on my custom board

    I patch the file 0001-dma-cppi41-delete-channel-from-pending-list-when-sto.patch.txt, It has no effect.

    root@NECRO:~# cat uart.sh
    #!/bin/sh
    while true; do
    for i in 0 1 2 3; do
    cat /dev/ttyUSB${i} || exit 1 &
    sleep 1
    kill $(pidof cat) || exit 2
    sleep 1
    done
    done
    root@NECRO:~# sh uart.sh
    uart.sh: line 3: 1062 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1067 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1072 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1084 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1089 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1101 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1095 Terminated cat /dev/ttyUSB${i}
    uart.sh: line 3: 1078 Terminated cat /dev/ttyUSB${i}
    ^C
    root@NECRO:~# dmesg
    [ 785.767812] cp210x ttyUSB1: failed set request 0x0 status: -110
    [ 785.773779] cp210x ttyUSB1: cp210x_open - Unable to enable UART
    [ 787.847846] cp210x ttyUSB2: failed set request 0x0 status: -110
    [ 787.853817] cp210x ttyUSB2: cp210x_open - Unable to enable UART
    [ 787.928073] cp210x ttyUSB3: failed set request 0x0 status: -110
    [ 791.927881] cp210x ttyUSB0: failed set request 0x0 status: -110
    [ 791.933850] cp210x ttyUSB0: cp210x_open - Unable to enable UART


    Not only cp2108, but also other devices use USB hub on my custom board,
    It may not be appropriate to re-load musb_hdrc.ko and musb_dsps.ko module,

    Thanks

    Shuming
  • Shuming,

    Thanks for the information. With a hub now I can reproduce the problem.

    Can you please test the following patch to see if it fixes the issue for you?
    www.spinics.net/.../msg162293.html

    Please note that the patch has one line which is incorrect.

    +           (urb->dev->tt->hub != musb_to_hcd(musb)->self.root_hub) &&

    should be

    +               (urb->dev->tt->hub != musb->hcd->self.root_hub) &&
  • Hi Bin

    Thank you for your strong support.!

    With the above patch, the communication freeze issue was solved.

    Thanks
    Shuming
  • I can confirm this corrected a past problem I had where the same issue would arise with ttyACM ports, I tried to reply to the old post with this however it appears to be locked.

    e2e.ti.com/.../764860

    Thanks,
    Ben
  • Hi Ben,

    Thanks for the update. Glad the patch also solves your use case.
    I have unlocked and updated your old thread with the closure.