Date: Sun, 7 Jul 2019 22:46:10 +0200 From: Hans Petter Selasky <hps@selasky.org> To: sgk@troutmask.apl.washington.edu Cc: Ian Lepore <ian@freebsd.org>, freebsd-current@freebsd.org, takawata@freebsd.org Subject: Re: Someone broke USB Message-ID: <2ccb6b71-022d-5b66-3ba9-007e2647b3e2@selasky.org> In-Reply-To: <20190707203635.GA53065@troutmask.apl.washington.edu> References: <20190706210613.GA45709@troutmask.apl.washington.edu> <4d866257df0aa0a671973555b4a9a0eb27088d5c.camel@freebsd.org> <20190706231453.GA46470@troutmask.apl.washington.edu> <20190707080510.GA48223@troutmask.apl.washington.edu> <ff363616-37e2-8a90-7b3a-9eb18c51ba82@selasky.org> <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>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2ccb6b71-022d-5b66-3ba9-007e2647b3e2>
