Date: Mon, 8 Jul 2019 11:50:31 +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: <602f5c9b-e15e-d08f-f388-47fc0a560803@selasky.org> In-Reply-To: <20190707222555.GA55146@troutmask.apl.washington.edu> References: <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> <2ccb6b71-022d-5b66-3ba9-007e2647b3e2@selasky.org> <20190707222555.GA55146@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. --------------4A9CCB06FD1A9D94EA21755E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Steve, Can you test this patch? I made a slight variant which delay the explore threads instead of the main thread running all the sysinits. --HPS --------------4A9CCB06FD1A9D94EA21755E Content-Type: text/x-patch; name="usb_delay.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="usb_delay.diff" Index: sys/dev/usb/controller/usb_controller.c =================================================================== --- sys/dev/usb/controller/usb_controller.c (revision 349802) +++ sys/dev/usb/controller/usb_controller.c (working copy) @@ -105,6 +105,10 @@ SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); +static int usb_explore_wait = 250; +SYSCTL_INT(_hw_usb, OID_AUTO, explore_wait, CTLFLAG_RWTUN, + &usb_explore_wait, 0, "Delay in milliseconds between initial root HUB explore."); + static devclass_t usb_devclass; static device_method_t usb_methods[] = { @@ -373,6 +377,13 @@ if (bus->no_explore != 0) return; + if (bus->explore_delay == 0) { + int ms = device_get_unit(bus->bdev) * usb_explore_wait; + bus->explore_delay = 1; + if (ms != 0) + usb_pause_mtx(&bus->bus_mtx, howmany(ms * hz, 1000)); + } + if (udev != NULL) { USB_BUS_UNLOCK(bus); uhub_explore_handle_re_enumerate(udev); Index: sys/dev/usb/usb_bus.h =================================================================== --- sys/dev/usb/usb_bus.h (revision 349802) +++ sys/dev/usb/usb_bus.h (working copy) @@ -131,6 +131,7 @@ uint8_t do_probe; /* set if USB should be re-probed */ uint8_t no_explore; /* don't explore USB ports */ uint8_t dma_bits; /* number of DMA address lines */ + uint8_t explore_delay; /* set if USB explore did initial delay */ }; #endif /* _USB_BUS_H_ */ --------------4A9CCB06FD1A9D94EA21755E--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?602f5c9b-e15e-d08f-f388-47fc0a560803>