On Mon, Jan 17, 2022 at 10:01:17PM +0900, SASANO Takayoshi wrote: > > Hi, > > Sometimes uchcom(4) looks Rx jammed. > Here is the movie (at Mastodon) that the problem has occured: > https://social.tchncs.de/@uaa/107637913051446044 > > Receiving an exact wMaxPacketSize bytes bulk packet from CH34x causes > this problem, because this means USB transaction is not finished. > > uchcom(4)'s ibufsize for ucom(4) is too large, it should be same as > wMaxPacketsize for bulk-in endpoint.
I often encounter the same issue while installing. I have had a similar diff in my tree. Tested: uchcom0 at uhub0 port 4 configuration 1 interface 0 "QinHeng Electronics USB2.0-Serial" rev 1.10/2.63 addr 5 uchcom0: CH341 ucom0 at uchcom0 ok kevlo@ > Here's the diff. > > Index: uchcom.c > =================================================================== > RCS file: /cvs/src/sys/dev/usb/uchcom.c,v > retrieving revision 1.31 > diff -u -p -r1.31 uchcom.c > --- uchcom.c 19 Nov 2021 07:58:34 -0000 1.31 > +++ uchcom.c 17 Jan 2022 12:21:55 -0000 > @@ -113,7 +113,6 @@ int uchcomdebug = 0; > #define UCHCOM_RESET_VALUE 0x501F /* line mode? */ > #define UCHCOM_RESET_INDEX 0xD90A /* baud rate? */ > > -#define UCHCOMIBUFSIZE 256 > #define UCHCOMOBUFSIZE 256 > > struct uchcom_softc > @@ -141,6 +140,7 @@ struct uchcom_softc > struct uchcom_endpoints > { > int ep_bulkin; > + int ep_bulkin_size; > int ep_bulkout; > int ep_intr; > int ep_intr_size; > @@ -293,9 +293,9 @@ uchcom_attach(struct device *parent, str > uca.portno = UCOM_UNK_PORTNO; > uca.bulkin = endpoints.ep_bulkin; > uca.bulkout = endpoints.ep_bulkout; > - uca.ibufsize = UCHCOMIBUFSIZE; > + uca.ibufsize = endpoints.ep_bulkin_size; > uca.obufsize = UCHCOMOBUFSIZE; > - uca.ibufsizepad = UCHCOMIBUFSIZE; > + uca.ibufsizepad = endpoints.ep_bulkin_size; > uca.opkthdrlen = 0; > uca.device = dev; > uca.iface = sc->sc_iface; > @@ -349,7 +349,7 @@ int > uchcom_find_endpoints(struct uchcom_softc *sc, > struct uchcom_endpoints *endpoints) > { > - int i, bin=-1, bout=-1, intr=-1, isize=0; > + int i, bin=-1, bout=-1, intr=-1, binsize=0, isize=0; > usb_interface_descriptor_t *id; > usb_endpoint_descriptor_t *ed; > > @@ -370,6 +370,7 @@ uchcom_find_endpoints(struct uchcom_soft > } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && > UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { > bin = ed->bEndpointAddress; > + binsize = UGETW(ed->wMaxPacketSize); > } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && > UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { > bout = ed->bEndpointAddress; > @@ -402,6 +403,7 @@ uchcom_find_endpoints(struct uchcom_soft > endpoints->ep_intr = intr; > endpoints->ep_intr_size = isize; > endpoints->ep_bulkin = bin; > + endpoints->ep_bulkin_size = binsize; > endpoints->ep_bulkout = bout; > > return 0; > > -- > SASANO Takayoshi (JG1UAA) <u...@mx5.nisiq.net> >