From owner-freebsd-current@freebsd.org Sun Jul 7 20:46:58 2019 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C594B15C9447 for ; Sun, 7 Jul 2019 20:46:58 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D5F8974325; Sun, 7 Jul 2019 20:46:57 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id CE7D526030B; Sun, 7 Jul 2019 22:46:48 +0200 (CEST) Subject: Re: Someone broke USB To: sgk@troutmask.apl.washington.edu Cc: Ian Lepore , freebsd-current@freebsd.org, takawata@freebsd.org References: <20190706210613.GA45709@troutmask.apl.washington.edu> <4d866257df0aa0a671973555b4a9a0eb27088d5c.camel@freebsd.org> <20190706231453.GA46470@troutmask.apl.washington.edu> <20190707080510.GA48223@troutmask.apl.washington.edu> <20190707165429.GA50543@troutmask.apl.washington.edu> <025dfdc1-b2d2-ef88-c2d6-32d8f3620a9d@selasky.org> <99a61cc8-495f-a333-b4bc-46fc929bae37@selasky.org> <20190707185818.GA51398@troutmask.apl.washington.edu> <20ee6a81-d513-8332-8e47-6676dbb9a159@selasky.org> <20190707203635.GA53065@troutmask.apl.washington.edu> From: Hans Petter Selasky Message-ID: <2ccb6b71-022d-5b66-3ba9-007e2647b3e2@selasky.org> Date: Sun, 7 Jul 2019 22:46:10 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190707203635.GA53065@troutmask.apl.washington.edu> Content-Type: multipart/mixed; boundary="------------87EAC9ED513B5ACAC551E33C" Content-Language: en-US X-Rspamd-Queue-Id: D5F8974325 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 88.99.82.50 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-5.66 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[selasky.org]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: mail.turbocat.net]; NEURAL_HAM_SHORT(-0.27)[-0.271,0]; IP_SCORE(-3.18)[ip: (-9.38), ipnet: 88.99.0.0/16(-4.74), asn: 24940(-1.78), country: DE(-0.01)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; MIME_UNKNOWN(0.10)[text/x-patch] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2019 20:46:59 -0000 This is a multi-part message in MIME format. --------------87EAC9ED513B5ACAC551E33C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 2019-07-07 22:36, Steve Kargl wrote: > On Sun, Jul 07, 2019 at 09:10:00PM +0200, Hans Petter Selasky wrote: >> On 2019-07-07 20:58, Steve Kargl wrote: >>> I assume the pause goes after "max--;" statement. I also >>> assume you want the info with the sysctl removed from >>> /boot/loader.conf. >> >> You can play with it and see what happens. >> > > Built kernel with pause() added, and commented out the > sysctl in /boot/loader.conf. One reboot took a long > time to get to the a login prompt, but all of my USB > devices were found. A few reboots appeared to hang > after probing the USB mouse (or perhaps I was too > impatient). > > On a side note, it seems the wpi0 mapped to wlan0 > is now unstable. Luckily, I have an ath(4) pccard > that I can use instead of the builtin wifi of the > laptop. The joys of current. :-) > It sounds like we have a race there and that a wait between the probes solves it. Can you try the attached patch on top of -current: --HPS --------------87EAC9ED513B5ACAC551E33C Content-Type: text/x-patch; name="usb_delay.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="usb_delay.diff" Index: sys/dev/usb/usb_hub.c =================================================================== --- sys/dev/usb/usb_hub.c (revision 349802) +++ sys/dev/usb/usb_hub.c (working copy) @@ -2274,18 +2274,19 @@ } /*------------------------------------------------------------------------* - * usb_needs_explore_all + * usb_needs_explore_all_flags * * This function is called whenever a new driver is loaded and will * cause that all USB buses are re-explored. *------------------------------------------------------------------------*/ -void -usb_needs_explore_all(void) +static void +usb_needs_explore_all_flags(int flags) { struct usb_bus *bus; devclass_t dc; device_t dev; int max; + int x; DPRINTFN(3, "\n"); @@ -2297,9 +2298,9 @@ /* * Explore all USB buses in parallel. */ - max = devclass_get_maxunit(dc); - while (max >= 0) { - dev = devclass_get_device(dc, max); + max = devclass_get_maxunit(dc) + 1; + for (x = 0; x < max; x++) { + dev = devclass_get_device(dc, x); if (dev) { bus = device_get_softc(dev); if (bus) { @@ -2306,10 +2307,17 @@ usb_needs_explore(bus, 1); } } - max--; + if (flags & 1) + pause("W", hz / max); } } +void +usb_needs_explore_all(void) +{ + usb_needs_explore_all_flags(0); +} + /*------------------------------------------------------------------------* * usb_needs_explore_init * @@ -2324,7 +2332,7 @@ * being called: */ if (cold == 0) - usb_needs_explore_all(); + usb_needs_explore_all_flags(1); else DPRINTFN(-1, "Cold variable is still set!\n"); } --------------87EAC9ED513B5ACAC551E33C--