Date: Fri, 4 Jan 2019 17:09:09 +0100 From: Hans Petter Selasky <hps@selasky.org> To: Ludovic Rousseau <ludovic.rousseau@gmail.com>, freebsd-usb@freebsd.org Subject: Re: r342378: usbconfig takes 3-5 minutes to read the bus Message-ID: <1af01261-ab9a-a137-233c-180cf7f1b99c@selasky.org> In-Reply-To: <dce9b33a-6f93-97b1-04d5-24d0ce6f856e@selasky.org> References: <5950d771-ffa9-9325-b102-295fd092052e@selasky.org> <20190103094850.GA2595@c720-r342378> <076e01a2-51e7-b140-28c9-1c58d034327b@selasky.org> <20190103113512.GA2547@c720-r342378> <34dfc02b-b252-9f38-a905-31a713012c6a@selasky.org> <CAGstE8B6RxBqBG9uqUXc60JcsB6=-QcmN1Q4kTgbgwoWGVaNyA@mail.gmail.com> <20190104080227.GB2604@c720-r342378> <64a0f5c6-ea58-6fdb-8d94-dd442619cde9@selasky.org> <20190104104601.GA2536@c720-r342378> <85a6ed88-126d-2f89-ba3f-ef3e61e0bf92@selasky.org> <20190104152720.GA2802@c720-r342378> <dce9b33a-6f93-97b1-04d5-24d0ce6f856e@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 1/4/19 5:05 PM, Hans Petter Selasky wrote:
> On 1/4/19 4:27 PM, Matthias Apitz wrote:
>> El día viernes, enero 04, 2019 a las 12:45:47p. m. +0100, Hans Petter
>> Selasky escribió:
>>
>>> On 1/4/19 11:46 AM, Matthias Apitz wrote:
>>>> Jan 4 11:26:39 c720-r342378 kernel: uhub_read_port_status: port 13,
>>>> wPortStatus=0x07a0, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION
>>>> Jan 4 11:26:41 c720-r342378 kernel: uhub_read_port_status: port 1,
>>>> wPortStatus=0xe070, wPortChange=0x161e, err=USB_ERR_TIMEOUT
>>>> Jan 4 11:26:41 c720-r342378 kernel: uhub_read_port_status: port 2,
>>>> wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION
>>>
>>> Hi,
>>>
>>> The problem appears to be that one of the USB HUBs port status request
>>> don't respond: USB_ERR_TIMEOUT, which in turn blocks the enumeration
>>> thread.
>>>
>>> Can you try the attached kernel patch and send new debug log?
>>
>> Hi,
>>
>> I applied the patch and the new debug output is attached.
>>
>> And it works now as it should, without any devd(8) hook. I just start
>> pcsdd as a service via rc.conf and can attach or withdraw the security
>> token. When the token is not attached GnuPG asks me to insert it and
>> when it is inserted I'm asked for the PIN. All as it should be
>>
>> A big THANKS!
>>
>> Should I file a PR to get your patch included upstream?
>>
>
> No PR needed, but I might need you to test one more patch.
>
Can you try this patch aswell and attach new logs?
Thank you!
--HPS
[-- Attachment #2 --]
Index: sys/dev/usb/usb_hub.c
===================================================================
--- sys/dev/usb/usb_hub.c (revision 342455)
+++ sys/dev/usb/usb_hub.c (working copy)
@@ -129,6 +129,8 @@
int sc_disable_enumeration;
int sc_disable_port_power;
#endif
+ uint8_t sc_usb_port_errors; /* error counter */
+#define UHUB_USB_PORT_ERRORS_MAX 4
uint8_t sc_flags;
#define UHUB_FLAG_DID_EXPLORE 0x01
};
@@ -587,14 +589,26 @@
struct usb_port_status ps;
usb_error_t err;
+ if (sc->sc_usb_port_errors >= UHUB_USB_PORT_ERRORS_MAX) {
+ DPRINTFN(4, "port %d, HUB looks dead, too many errors\n", portno);
+ sc->sc_st.port_status = 0;
+ sc->sc_st.port_change = 0;
+ return (USB_ERR_TIMEOUT);
+ }
+
err = usbd_req_get_port_status(
sc->sc_udev, NULL, &ps, portno);
- /* update status regardless of error */
+ if (err == 0) {
+ sc->sc_st.port_status = UGETW(ps.wPortStatus);
+ sc->sc_st.port_change = UGETW(ps.wPortChange);
+ sc->sc_usb_port_errors = 0;
+ } else {
+ sc->sc_st.port_status = 0;
+ sc->sc_st.port_change = 0;
+ sc->sc_usb_port_errors++;
+ }
- sc->sc_st.port_status = UGETW(ps.wPortStatus);
- sc->sc_st.port_change = UGETW(ps.wPortChange);
-
/* debugging print */
DPRINTFN(4, "port %d, wPortStatus=0x%04x, "
Index: sys/dev/usb/usb_request.c
===================================================================
--- sys/dev/usb/usb_request.c (revision 342455)
+++ sys/dev/usb/usb_request.c (working copy)
@@ -1601,8 +1601,9 @@
USETW(req.wValue, 0);
req.wIndex[0] = port;
req.wIndex[1] = 0;
- USETW(req.wLength, sizeof *ps);
- return (usbd_do_request(udev, mtx, &req, ps));
+ USETW(req.wLength, sizeof(*ps));
+
+ return (usbd_do_request_flags(udev, mtx, &req, ps, 0, NULL, 1000));
}
/*------------------------------------------------------------------------*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1af01261-ab9a-a137-233c-180cf7f1b99c>
