From owner-freebsd-hackers@freebsd.org Sun Mar 10 01:01:10 2019 Return-Path: Delivered-To: freebsd-hackers@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 00FDC153EA98 for ; Sun, 10 Mar 2019 01:01:10 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from ipmail07.adl2.internode.on.net (ipmail07.adl2.internode.on.net [150.101.137.131]) by mx1.freebsd.org (Postfix) with ESMTP id 9208383758 for ; Sun, 10 Mar 2019 01:01:01 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from 124-148-131-52.dyn.iinet.net.au (HELO midget.dons.net.au) ([124.148.131.52]) by ipmail07.adl2.internode.on.net with ESMTP; 10 Mar 2019 11:30:54 +1030 Received: from midget.dons.net.au (localhost [127.0.0.1]) by midget.dons.net.au (8.15.2/8.15.2) with ESMTPS id x2A10gA7004312 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 10 Mar 2019 11:30:48 +1030 (ACDT) (envelope-from darius@dons.net.au) Received: (from mailnull@localhost) by midget.dons.net.au (8.15.2/8.15.2/Submit) id x2A0bsmF086296 for ; Sun, 10 Mar 2019 11:07:54 +1030 (ACDT) (envelope-from darius@dons.net.au) X-Authentication-Warning: midget.dons.net.au: mailnull set sender to using -f Received: from [10.0.2.26] ([10.0.2.26]) by ns.dons.net.au (envelope-sender ) (MIMEDefang) with ESMTP id x2A0bptj086290; Sun, 10 Mar 2019 11:07:54 +1030 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: USB stack getting confused From: "O'Connor, Daniel" In-Reply-To: <6dd8fe5f-6835-d98a-7592-0293406ccd63@selasky.org> Date: Sun, 10 Mar 2019 11:07:51 +1030 Cc: FreeBSD Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <9E316D45-3538-4070-A8B0-05F9B71BC480@dons.net.au> References: <3B29D870-41F9-46AF-B9F3-03106DEC417D@dons.net.au> <6dd8fe5f-6835-d98a-7592-0293406ccd63@selasky.org> To: Hans Petter Selasky X-Mailer: Apple Mail (2.3445.102.3) X-Spam-Score: -1 () No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.1 X-Scanned-By: MIMEDefang 2.83 on 10.0.2.1 X-Rspamd-Queue-Id: 9208383758 X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [5.09 / 15.00]; MV_CASE(0.50)[]; HAS_XAW(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[midget.dons.net.au]; RCPT_COUNT_TWO(0.00)[2]; RCVD_NO_TLS_LAST(0.10)[]; RECEIVED_SPAMHAUS_PBL(0.00)[52.131.148.124.zen.spamhaus.org : 127.0.0.11]; IP_SCORE(0.75)[ip: (2.42), ipnet: 150.101.0.0/16(1.03), asn: 4739(0.33), country: AU(-0.04)]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:4739, ipnet:150.101.0.0/16, country:AU]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; RCVD_IN_DNSWL_LOW(-0.10)[131.137.101.150.list.dnswl.org : 127.0.5.1]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.95)[0.954,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(1.00)[0.998,0]; DMARC_NA(0.00)[dons.net.au]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[0.999,0]; R_SPF_NA(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 01:01:10 -0000 > On 10 Mar 2019, at 01:55, Hans Petter Selasky wrote: > On 3/9/19 11:29 AM, O'Connor, Daniel wrote: >> If I hold the user space process in gdb 'forever' (eg over night) = usbconfig doesn't see the device, but the moment I quit the user space = process it can be seen again. >=20 > Check the output from "procstat -ak". Likely your application is not = closing the USB handle during device detach and so a deadlock happens. I ran it while stopped in the debugger.. [maarsytest 23:34] ~> procstat -k 20033 PID TID COMM TDNAME KSTACK 20033 100135 tclsh8.6 - mi_switch = thread_suspend_switch ptracestop cursig ast doreti_ast Then continued it and ran it a few more times.. [maarsytest 23:34] ~> procstat -k 20033 PID TID COMM TDNAME KSTACK 20033 100135 tclsh8.6 - mi_switch = sleepq_catch_signals sleepq_wait_sig _sleep pipe_read dofileread = kern_readv sys_read amd64_syscall fast_syscall_common [maarsytest 23:34] ~> procstat -k 20033 PID TID COMM TDNAME KSTACK 20033 100135 tclsh8.6 - mi_switch = sleepq_catch_signals sleepq_timedwait_sig _cv_timedwait_sig_sbt = seltdwait kern_select sys_select amd64_syscall fast_syscall_common > Also see: > libusb20_dev_check_connected() . Poll this function regularly to = figure out if disconnect is needed. Hmm, is this exposed in the libusb10 interface? The code I am using uses = that to talk to the device (although I have the source for it so can = modify it) -- Daniel O'Connor "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum