xhci/ucom problem with multi character transfers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

xhci/ucom problem with multi character transfers

Ralf Horstmann-2
>Synopsis: xhci/ucom problem with multi character transfers
>Category: kernel
>Environment:
        System      : OpenBSD 5.9
        Details     : OpenBSD 5.9-current (GENERIC.MP) #1996: Wed Apr 20 14:57:08 MDT 2016
                         [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
        When uftdi or uplcom based usb serial adapters are attach to an
        xhci port, there is a problem when sending multiple characters
        to the serial port at once. E.g.

        echo test | cu -l /dev/cuaU0

        This will work on first attempt, but every following attempt will
        result in no output on the serial port. I've attached an
        oscilloscope to the TX line to observe the output.
       
        To make the USB serial converter transmit characters again, there
        are multiple options. Either run:

        cu -l /dev/cuaU0

        and press at least two keys. The first character will be discarded
        but the second will be transmitted normally. So it seem that two
        transfers of a single character will resolve the error condition.
        Second option is something like this:

        (sleep 0.05; echo; sleep 0.05; echo; sleep 0.05) | cu -l /dev/cuaU0

        This bug report contains the dmesg of a NUC, which only has xhci ports
        that can't be switched into ehci mode.

        I can reproduce on a Thinkpad X230 as well, but only with the USB
        ports on the left side that attach to xhci. And only when USB 3 is
        enabled in BIOS. With the USB port on the right side that attaches
        to ehci, the bug is not observable. When disabling USB 3 in BIOS,
        everything works as expected regardless which USB port is used.

        I have tested several uftdi and uplcom adapters, they all behave
        as described above.

        With some debugging enabled the first and second multi character
        transfer look exactly the same:

        ucomopen: open pipes in=129 out=2
        ucomopen: hid 0xec4c02f8 pipes in=0x0 out=0x0
        xhci_pipe_init: pipe=0xffff800000b18000 addr=2 depth=1 port=2 speed=2 dev 1 dci 3 (epAddr=0x81)
        xhci0: xhci_cmd_configure_ep dev 1
        xhci_pipe_init: pipe=0xffff800000aeb000 addr=2 depth=1 port=2 speed=2 dev 1 dci 4 (epAddr=0x2)
        xhci0: xhci_cmd_configure_ep dev 1
        uftdi_open: sc=0xffff8000003aa480
        uftdi_param: sc=0xffff8000003aa480
        uftdi_status: msr=0x00 lsr=0x00
        ucomopen: unit=0, tp=0xffff800000374e00
        uftdi_param: sc=0xffff8000003aa480
        ucomparam: l_modem
        ucom_dtr: onoff=1
        uftdi_set: sc=0xffff8000003aa480, port=1 reg=1 onoff=1
        ucom_rts: onoff=1
        uftdi_set: sc=0xffff8000003aa480, port=1 reg=2 onoff=1
        ucom_hwiflow:
        ucomioctl: cmd=0x2000740d
        ucomioctl: cmd=0x402c7413
        ucomioctl: cmd=0x802c7416
        uftdi_param: sc=0xffff8000003aa480
        ucomparam: l_modem
        ucomioctl: cmd=0x8004667e
        ucomioctl: cmd=0x8004667d
        ucomstart: 5 chars
        ucomwritecb: 0xffffff041c8c71e0 0xffff800000374c00 status=0
        ucomwritecb: cc=5
        ucomclose: unit=0
        ucomstop: flag=3
        ucomstop: flag=3
        ucom_cleanup: closing pipes
        ucom_shutdown
        ucom_dtr: onoff=0
        uftdi_set: sc=0xffff8000003aa480, port=1 reg=1 onoff=0
        ucom_rts: onoff=0
        uftdi_set: sc=0xffff8000003aa480, port=1 reg=2 onoff=0
        xhci_abort_xfer: xfer=0xffffff041c8c72d0 status=IN_PROGRESS err=CANCELLED actlen=0 len=64 idx=61
        xhci0: xhci_cmd_stop_ep dev 1 dci 3
        xhci_event_xfer: stopped xfer=0xffffff041c8c72d0
        xhci0: xhci_cmd_set_tr_deq_async dev 1 dci 3
        ucomreadcb: dying
        xhci0: xhci_cmd_configure_ep dev 1

>How-To-Repeat:
        echo test | cu -l /dev/cuaU0
        echo test | cu -l /dev/cuaU0

        Observe that for the second command no output appears at the serial
        port
>Fix:
        As a workaround, send only single characters to the serial port.
        Or disable USB 3/XHCI support in BIOS.

dmesg:
OpenBSD 5.9-current (GENERIC.MP) #1996: Wed Apr 20 14:57:08 MDT 2016
    [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8457224192 (8065MB)
avail mem = 8196530176 (7816MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xebec0 (46 entries)
bios0: vendor Intel Corp. version "FYBYT10H.86A.0053.2016.0205.1707" date 02/05/2016
bios0: \M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^? \M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?\M^?
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT FIDT MCFG LPIT HPET SSDT SSDT SSDT UEFI
acpi0: wakeup devices UAR5(S4) UAR8(S4) PS2K(S3) PS2M(S3) XHC1(S4) EHC1(S4) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) PWRB(S0) BRCM(S0) BRC3(S0)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Celeron(R) CPU N2830 @ 2.16GHz, 2167.16 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,RDRAND,NXE,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT
cpu0: 1MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 83MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.0.0.0.3.3, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Celeron(R) CPU N2830 @ 2.16GHz, 2166.66 MHz
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,RDRAND,NXE,LONG,LAHF,3DNOWP,PERF,ITSC,SMEP,ERMS,SENSOR,ARAT
cpu1: 1MB 64b/line 16-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 87 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus 2 (RP02)
acpiprt3 at acpi0: bus 3 (RP03)
acpiprt4 at acpi0: bus 4 (RP04)
acpiec0 at acpi0: not present
acpicpu0 at acpi0: C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C1(1000@1 mwait.1), PSS
acpipwrres0 at acpi0: PLPE
acpipwrres1 at acpi0: PLPE
acpipwrres2 at acpi0: USBC, resource for EHC1, OTG1
acpipwrres3 at acpi0: CLK0, resource for CAM1
acpipwrres4 at acpi0: CLK1, resource for CAM0, CAM2
"PNP0103" at acpi0 not configured
"ITE8713" at acpi0 not configured
"DMA0F28" at acpi0 not configured
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID0
"INT3396" at acpi0 not configured
"BCM2E1A" at acpi0 not configured
"BCM4752" at acpi0 not configured
"INTCF0B" at acpi0 not configured
"INTCF1A" at acpi0 not configured
"INTCF1C" at acpi0 not configured
"SMO91D0" at acpi0 not configured
"ATML1000" at acpi0 not configured
"ATML2000" at acpi0 not configured
"INT33BD" at acpi0 not configured
acpivideo0 at acpi0: GFX0
cpu0: Enhanced SpeedStep 2167 MHz: speeds: 2159, 2158, 1992, 1826, 1660, 1494, 1328, 1162, 996, 830, 664, 498 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Bay Trail Host" rev 0x0e
inteldrm0 at pci0 dev 2 function 0 "Intel Bay Trail Video" rev 0x0e
drm0 at inteldrm0
inteldrm0: msi
inteldrm0: 1920x1200
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
ahci0 at pci0 dev 19 function 0 "Intel Bay Trail AHCI" rev 0x0e: msi, AHCI 1.3
ahci0: port 0: 3.0Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, Samsung SSD 850, EXM0> SCSI3 0/direct fixed naa.50025388a0b0ebeb
sd0: 122104MB, 512 bytes/sector, 250069680 sectors, thin
xhci0 at pci0 dev 20 function 0 "Intel Bay Trail xHCI" rev 0x0e: msi
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 "Intel xHCI root hub" rev 3.00/1.00 addr 1
"Intel Bay Trail TXE" rev 0x0e at pci0 dev 26 function 0 not configured
azalia0 at pci0 dev 27 function 0 "Intel Bay Trail HD Audio" rev 0x0e: msi
azalia0: codecs: Realtek/0x0283, Intel/0x2882, using Realtek/0x0283
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel Bay Trail I2C" rev 0x0e: msi
pci1 at ppb0 bus 1
ppb1 at pci0 dev 28 function 1 "Intel Bay Trail PCIE" rev 0x0e: msi
pci2 at ppb1 bus 2
iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless AC 7260" rev 0x73, msi
ppb2 at pci0 dev 28 function 2 "Intel Bay Trail PCIE" rev 0x0e: msi
pci3 at ppb2 bus 3
re0 at pci3 dev 0 function 0 "Realtek 8168" rev 0x0c: RTL8168G/8111G (0x4c00), msi, address c0:3f:d5:6c:7d:a6
rgephy0 at re0 phy 7: RTL8251 PHY, rev. 0
ppb3 at pci0 dev 28 function 3 "Intel Bay Trail PCIE" rev 0x0e: msi
pci4 at ppb3 bus 4
pcib0 at pci0 dev 31 function 0 "Intel Bay Trail LPC" rev 0x0e
ichiic0 at pci0 dev 31 function 3 "Intel Bay Trail SMBus" rev 0x0e: apic 1 int 18
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 8GB DDR3 SDRAM PC3-12800 SO-DIMM
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
uftdi0 at uhub0 port 3 configuration 1 interface 0 "FTDI USB HS SERIAL CONVERTER" rev 1.10/4.00 addr 2
ucom0 at uftdi0 portno 1
ugen0 at uhub0 port 4 "Intel product 0x07dc" rev 2.00/0.01 addr 3
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (2b2f8e6745a3ab79.a) swap on sd0b dump on sd0b
iwm0: hw rev 0x140, fw ver 25.228 (API ver 9), address a0:a8:cd:07:b0:52

usbdevs:
Controller /dev/usb0:
addr 1: super speed, self powered, config 1, xHCI root hub(0x0000), Intel(0x8086), rev 1.00
 port 1 disabled
 port 2 disabled
 port 3 addr 2: full speed, power 44 mA, config 1, USB HS SERIAL CONVERTER(0x6001), FTDI(0x0403), rev 4.00, iSerialNumber FTZ6IF0I
 port 4 addr 3: full speed, self powered, config 1, product 0x07dc(0x07dc), Intel(0x8087), rev 0.01
 port 5 disabled
 port 6 disabled
 port 7 disabled