>Synopsis:      uchcom(4) seems to not flush received data
>Category:      kernel
>Environment:
        System      : OpenBSD 7.7
        Details     : OpenBSD 7.7 (GENERIC.MP) #625: Sun Apr 13 08:30:20 MDT 
2025
                         
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
        i have a device which presents its serial line as a CH341:

                uchcom0 at uhub1 port 2 configuration 1 interface 0 "QinHeng 
Electronics USB2.0-Serial" rev 1.10/2.54 addr 5
                uchcom0: CH341
                ucom2 at uchcom0: usb0.2.00002.0

        the other end of it is attached to a linux SBC, running a normal 
getty/login/shell.

        when i type, and the remote sends something, the information is not
        flushed immediately and visible, but it seems somehow still stuck in a 
buffer
        somewhere. for example, i would normally expect:

                mischief@megrez:~$     # press enter
                mischief@megrez:~$     # full shell prompt line appears

        but on this serial adapter, instead i get something like:

                mischief@megrez:~$     # press enter
                mischief@megr          # line from remote is not fully flushed, 
press enter again

                mischief@megrez:~$     # the previous line now fully appears
                mischie                # subsequent line not fully flushed again

        this also happens for non-newlines, such as just typing regular
        characters at the shell. for example, if i just type 'a', nothing 
appears until
        i type several 'a' in a row.

        it happens with both cu(1) and picocom from packages.

        in testing, the 'flush' of data seems to happen at exactly a 32-byte
        boundary, e.g., if i type some characters, when they finally appear, if 
i type
        exactly 32 more, it is then flushed and appears, which would make sense 
as the
        size of a buffer for the data. however, the same device does not 
exhibit the
        same behavior when using cu or picocom under linux, so my suspicion was 
that
        this is an issue with the uchcom(4) driver, and not a problem with the 
device
        itself or cu/etc.

        the device in question is listed below from usbdevs, with vid/did 
1a86:7523.

>How-To-Repeat:
        cu -s 115200 -l /dev/cuaU2, try to type
>Fix:
        unsure, but the linux driver may reveal a clue.


dmesg:
OpenBSD 7.7 (GENERIC.MP) #625: Sun Apr 13 08:30:20 MDT 2025
    dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8367374336 (7979MB)
avail mem = 8087302144 (7712MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.2 @ 0x79801000 (60 entries)
bios0: vendor American Megatrends Inc. version "1.22" date 11/13/2020
bios0: HARDKERNEL ODROID-H2
efi0 at bios0: UEFI 2.7
efi0: American Megatrends rev 0x5000d
acpi0 at bios0: ACPI 6.2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP FPDT FIDT MCFG SSDT DBG2 DBGP HPET LPIT APIC NPKT SSDT 
SSDT SSDT SSDT SSDT SSDT SSDT DMAR WDAT WSMT
acpi0: wakeup devices HDAS(S3) XHC_(S4) XDCI(S4) RP01(S4) RP02(S4) RP03(S4) 
RP04(S4) RP05(S4) RP06(S4)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimcfg0 at acpi0
acpimcfg0: addr 0xe0000000, bus 0-255
acpihpet0 at acpi0: 19200000 Hz
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Celeron(R) J4115 CPU @ 1.80GHz, 1795.04 MHz, 06-7a-01, patch 
00000042
cpu0: cpuid 1 
edx=bfebfbff<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>
 
ecx=47f8ebbf<SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND>
cpu0: cpuid 6 eax=57<SENSOR,ARAT> ecx=1<EFFFREQ>
cpu0: cpuid 7.0 
ebx=2294e287<FSGSBASE,TSC_ADJUST,SGX,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA>
 ecx=40400004<UMIP> edx=ac000400<MD_CLEAR,IBRS,IBPB,STIBP,SSBD>
cpu0: cpuid a vers=4, gp=4, gpwidth=48, ff=3, ffwidth=48
cpu0: cpuid d.1 eax=f<XSAVEOPT,XSAVEC,XGETBV1,XSAVES>
cpu0: cpuid 80000001 edx=2c100800<NXE,PAGE1GB,RDTSCP,LONG> ecx=101<LAHF,3DNOWP>
cpu0: cpuid 80000007 edx=100<ITSC>
cpu0: msr 
10a=14000c6a<IBRS_ALL,SKIP_L1DFL,MDS_NO,IF_PSCHANGE,MISC_PKG_CT,ENERGY_FILT,GDS_NO,RFDS_CLEAR>
cpu0: MELTDOWN
cpu0: 24KB 64b/line 6-way D-cache, 32KB 64b/line 8-way I-cache, 4MB 64b/line 
16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 19MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.2.4.2.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Celeron(R) J4115 CPU @ 1.80GHz, 1795.03 MHz, 06-7a-01, patch 
00000042
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Celeron(R) J4115 CPU @ 1.80GHz, 1795.03 MHz, 06-7a-01, patch 
00000042
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Celeron(R) J4115 CPU @ 1.80GHz, 1795.04 MHz, 06-7a-01, patch 
00000042
cpu3: smt 0, core 3, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 120 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 5 (RP01)
acpiprt2 at acpi0: bus 6 (RP02)
acpiprt3 at acpi0: bus 1 (RP03)
acpiprt4 at acpi0: bus 2 (RP04)
acpiprt5 at acpi0: bus 3 (RP05)
acpiprt6 at acpi0: bus 4 (RP06)
acpiec0 at acpi0: not present
acpipci0 at acpi0 PCI0: 0x00000000 0x00000011 0x00000001
com0 at acpi0 UAR1 addr 0x3f8/0x8 irq 4: ns16550a, 16 byte fifo
com1 at acpi0 UAR2 addr 0x2f8/0x8 irq 3: ns16550a, 16 byte fifo
acpicmos0 at acpi0
acpibtn0 at acpi0: PWRB
glkgpio0 at acpi0 GPO1 uid 1 addr 0xd0c40000/0xcef irq 14, 80 pins
glkgpio1 at acpi0 GPO0 uid 2 addr 0xd0c50000/0xaff irq 14, 80 pins
glkgpio2 at acpi0 GPO2 uid 3 addr 0xd0c90000/0x7bf irq 15, 20 pins
glkgpio3 at acpi0 GPO3 uid 4 addr 0xd0c80000/0x82f irq 14, 35 pins
intelpmc0 at acpi0: PEPD
state 0: 0x7f:1:2:0x00:0x0000000000000060
counter: 0x7f:64:0:0x00:0x0000000000000632
frequency: 0
"PNP0C0B" at acpi0 not configured
acpipwrres0 at acpi0: WRST
acpicpu0 at acpi0: C3(10@150 mwait.1@0x60), C2(10@50 mwait.1@0x21), C1(1000@1 
mwait.1@0x1), PSS
acpicpu1 at acpi0: C3(10@150 mwait.1@0x60), C2(10@50 mwait.1@0x21), C1(1000@1 
mwait.1@0x1), PSS
acpicpu2 at acpi0: C3(10@150 mwait.1@0x60), C2(10@50 mwait.1@0x21), C1(1000@1 
mwait.1@0x1), PSS
acpicpu3 at acpi0: C3(10@150 mwait.1@0x60), C2(10@50 mwait.1@0x21), C1(1000@1 
mwait.1@0x1), PSS
acpipwrres1 at acpi0: FN00, resource for FAN0
acpitz0 at acpi0
acpitz0: critical temperature is 95 degC
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD1F
cpu0: using VERW MDS workaround
cpu0: Enhanced SpeedStep 1795 MHz: speeds: 1801, 1800, 1700, 1600, 1500, 1400, 
1300, 1200, 1100, 1000, 900, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Gemini Lake Host" rev 0x03
inteldrm0 at pci0 dev 2 function 0 "Intel UHD Graphics 600" rev 0x03
drm0 at inteldrm0
inteldrm0: msi, GEMINILAKE, gen 9
azalia0 at pci0 dev 14 function 0 "Intel Gemini Lake HD Audio" rev 0x03: msi
azalia0: codecs: Realtek ALC662, Intel/0x280d, using Realtek ALC662
audio0 at azalia0
"Intel Gemini Lake MEI" rev 0x03 at pci0 dev 15 function 0 not configured
ahci0 at pci0 dev 18 function 0 "Intel Gemini Lake AHCI" rev 0x03: msi, AHCI 
1.3.1
ahci0: port 0: 6.0Gb/s
ahci0: PHY offline on port 1
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, HP SSD S700 120G, R052> 
t10.ATA_HP_SSD_S700_120GB_HBSA10400100421_
sd0: 114473MB, 512 bytes/sector, 234441648 sectors, thin
ppb0 at pci0 dev 19 function 0 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci1 at ppb0 bus 1
rge0 at pci1 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:5c:6d
ppb1 at pci0 dev 19 function 1 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci2 at ppb1 bus 2
rge1 at pci2 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:5c:6e
ppb2 at pci0 dev 19 function 2 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci3 at ppb2 bus 3
rge2 at pci3 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:5c:6f
ppb3 at pci0 dev 19 function 3 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci4 at ppb3 bus 4
rge3 at pci4 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:5c:70
ppb4 at pci0 dev 20 function 0 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci5 at ppb4 bus 5
rge4 at pci5 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:55:ce
ppb5 at pci0 dev 20 function 1 "Intel Gemini Lake PCIE" rev 0xf3: msi
pci6 at ppb5 bus 6
rge5 at pci6 dev 0 function 0 "Realtek RTL8125" rev 0x04: msix, address 
00:1e:06:45:55:cf
xhci0 at pci0 dev 21 function 0 "Intel Gemini Lake xHCI" rev 0x03: msi, xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 
addr 1
dwiic0 at pci0 dev 23 function 0 "Intel Gemini Lake I2C" rev 0x03: apic 1 int 31
iic0 at dwiic0
dwiic1 at pci0 dev 23 function 1 "Intel Gemini Lake I2C" rev 0x03: apic 1 int 32
iic1 at dwiic1
dwiic2 at pci0 dev 23 function 2 "Intel Gemini Lake I2C" rev 0x03: apic 1 int 33
iic2 at dwiic2
dwiic3 at pci0 dev 23 function 3 "Intel Gemini Lake I2C" rev 0x03: apic 1 int 34
iic3 at dwiic3
sdhc0 at pci0 dev 28 function 0 "Intel Gemini Lake eMMC" rev 0x03: apic 1 int 39
sdhc0: SDHC 3.00, 200 MHz base clock
sdmmc0 at sdhc0: 8-bit, sd high-speed, mmc high-speed, ddr52, dma
pcib0 at pci0 dev 31 function 0 "Intel Gemini Lake LPC" rev 0x03
ichiic0 at pci0 dev 31 function 1 "Intel Gemini Lake SMBus" rev 0x03: apic 1 
int 20
iic4 at ichiic0
iic4: addr 0x2e 00=33 01=a0 02=33 03=80 04=33 05=60 0a=4b 10=2a 11=12 12=12 
13=16 14=07 15=17 17=07 19=64 1a=64 1b=64 1d=64 20=80 21=0e 23=08 27=03 30=55 
31=55 32=55 34=55 40=4c 41=01 42=8b 43=38 44=01 45=2a 47=10 48=20 49=fe 4d=3d 
4e=ff 4f=f8 50=20 51=7a 52=1e 53=7f 54=7f 55=7f 56=69 57=21 58=7f 59=7f 5a=7f 
5b=5c 5c=24 5d=7f 5e=7f 5f=7f 60=51 61=28 62=7f 63=7f 64=7f 65=4b 66=2a 67=7f 
68=7f 69=7f 6a=46 6b=2c 6c=7f 6d=7f 6e=7f 6f=41 70=2e 71=7f 72=7f 73=7f 74=3d 
75=32 76=7f 77=7f 78=7f c4=73 c5=a0 c8=24 c9=80 ca=49 cb=d2 cc=2f cd=06 ce=44 
cf=22 d0=20 d3=07 d4=20 d6=20 d7=40 db=12 e3=03 fc=01 fd=26 fe=5d ff=01 words 
00=33ff 01=a0ff 02=33ff 03=80ff 04=33ff 05=60ff 06=00ff 07=00ff
spdmem0 at iic4 addr 0x50: 4GB DDR4 SDRAM PC4-21300 SO-DIMM
spdmem1 at iic4 addr 0x52: 4GB DDR4 SDRAM PC4-21300 SO-DIMM
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
vmm0 at mainbus0: VMX/EPT (using slow L1TF mitigation)
efifb at mainbus0 not configured
scsibus2 at sdmmc0: 2 targets, initiator 0
sd1 at scsibus2 targ 1 lun 0: <Samsung, BJTD4R, 0000> removable
sd1: 29820MB, 512 bytes/sector, 61071360 sectors
uftdi0 at uhub0 port 1 configuration 1 interface 0 "FTDI FT230X Basic UART" rev 
2.00/10.00 addr 2
ucom0 at uftdi0 portno 1: usb0.0.00001.0
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
root on sd0a (b87ef086288f320e.a) swap on sd0b dump on sd0b
inteldrm0: 1920x1080, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)

usbdevs:
Controller /dev/usb0:
addr 01: 8086:0000 Intel, xHCI root hub
         super speed, self powered, config 1, rev 1.00
         driver: uhub0
addr 02: 0403:6015 FTDI, FT230X Basic UART
         full speed, power 90 mA, config 1, rev 10.00, iSerial DT03QUS5
         driver: uftdi0
addr 03: 0403:6015 FTDI, FT230X Basic UART
         full speed, power 90 mA, config 1, rev 10.00, iSerial DT03QV7J
         driver: uftdi1
addr 04: 1a40:0101 Terminus Technology, USB 2.0 Hub
         high speed, self powered, config 1, rev 1.11
         driver: uhub1
addr 05: 1a86:7523 QinHeng Electronics, USB2.0-Serial
         full speed, power 98 mA, config 1, rev 2.54
         driver: uchcom0

Reply via email to