On 2017/07/20 08:31, Martin Pieuchot wrote: > On 18/07/17(Tue) 13:43, sc dying wrote: >> On 2017/07/18 09:12, Martin Pieuchot wrote: >>> On 17/07/17(Mon) 15:24, sc dying wrote: >>>> On 2017/07/17 08:24, Martin Pieuchot wrote: >>>>> On 15/07/17(Sat) 21:16, sc dying wrote: >>>>>> - Call usbd_set_config before configuring endpoints in ure_init to fix >>>>>> an error when re-opening pipes. I grabbed the code from if_kue.c. >>>>> >>>>> Which error? Calling usbd_set_config() should be avoid as much as >>>>> possible in driver code. >>>> >>>> Without patch, ure on usb-3 port says this error >>>> >>>> ure0: usb errors on rx: IOERROR >>>> >>>> when down the interface and it up. >>> >>> This is certainly a bug in the way pipe are closed, or more likely in >>> xhci(4). Can you reproduce the problem on ehci(4)? Do you find >>> anything useful if you define XHCI_DEBUG in your kernel? >> >> This problem is not seen on ehci. >> >> On xhci with XHCI_DEBUG, curiously, it does not happen. >> I'll look into this. > > Great, I committed your diff without this chunk. I'd be glad to hear > from you if you find the problem with xhci(4).
Thank you for applying the patch. About IOERROR, it happens even if XHCI_DEBUG is defined. It happens on usb 3 mode port, but does not on usb 2 even if it is xhci's port. All I did for test are 1) Plug-in the device 2) ifconfig ure0 inet6 fe80::1 3) ping6 from other host to fe80::1 4) ifconfig ure0 down 5) ifconfig ure0 up 6) ping6 again I forgot step 3) to check if the device replies to ping. If the device does not receive any packets, it can be re-up without errors and works correctly after interface down and up. However, once it receives a packet, re-opening bulk-in pipe for RX immediately fails with TXERR (event_xfer translates it to IOERROR). xhci 4.6.6 says closing all pipes transitions the device state from Configured to Addressed. I thought it is needed to issue configure_ep and SET_CONFIG to transition the device to Configured state correcly again as described in 4.6.6, but this does not explain why the device works on usb 2.