From owner-freebsd-current@freebsd.org Mon Jul 8 09:51:14 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 AFA3E15D9663 for ; Mon, 8 Jul 2019 09:51:14 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (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 7E16194C82; Mon, 8 Jul 2019 09:51:13 +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 2161F260285; Mon, 8 Jul 2019 11:51:08 +0200 (CEST) Subject: Re: Someone broke USB To: sgk@troutmask.apl.washington.edu Cc: Ian Lepore , freebsd-current@freebsd.org, takawata@freebsd.org References: <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> <2ccb6b71-022d-5b66-3ba9-007e2647b3e2@selasky.org> <20190707222555.GA55146@troutmask.apl.washington.edu> From: Hans Petter Selasky Message-ID: <602f5c9b-e15e-d08f-f388-47fc0a560803@selasky.org> Date: Mon, 8 Jul 2019 11:50:31 +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: <20190707222555.GA55146@troutmask.apl.washington.edu> Content-Type: multipart/mixed; boundary="------------4A9CCB06FD1A9D94EA21755E" Content-Language: en-US X-Rspamd-Queue-Id: 7E16194C82 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-5.33 / 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.55)[-0.554,0]; IP_SCORE(-2.57)[ip: (-9.11), ipnet: 2a01:4f8::/29(-1.94), 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:2a01:4f8::/29, 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: Mon, 08 Jul 2019 09:51:14 -0000 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--