From owner-freebsd-hackers@freebsd.org Sat Mar 9 15:43:16 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 C9B92152A3A0 for ; Sat, 9 Mar 2019 15:43:16 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C8F78C75B for ; Sat, 9 Mar 2019 15:43:16 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [176.74.212.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 6C5152603CF; Sat, 9 Mar 2019 16:43:13 +0100 (CET) Subject: Re: USB stack getting confused To: Konstantin Belousov , "O'Connor, Daniel" Cc: FreeBSD Hackers References: <3B29D870-41F9-46AF-B9F3-03106DEC417D@dons.net.au> <20190309152613.GM2492@kib.kiev.ua> From: Hans Petter Selasky Message-ID: Date: Sat, 9 Mar 2019 16:42:50 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190309152613.GM2492@kib.kiev.ua> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 6C8F78C75B X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-7.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-1.00)[-0.996,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Sat, 09 Mar 2019 15:43:17 -0000 On 3/9/19 4:26 PM, Konstantin Belousov wrote: > On Sat, Mar 09, 2019 at 08:59:30PM +1030, O'Connor, Daniel wrote: >> >> >>> On 9 Mar 2019, at 19:30, Hans Petter Selasky wrote: >>> On 3/9/19 12:08 AM, O'Connor, Daniel wrote: >>>> My program normally runs continually doing acquisitions of data for N seconds, doing some checks and restarting. After a while (~30 1 minute acquisitions or ~8 30 minute ones) my program can't 'see' the device (it uses libusb10) any more (it reconnects each acquisition for $REASONS). Also pretty weirdly usbconfig can't see it either(!). >>> >>> What is printed in dmesg? Maybe the device has a problem. >> >> There is nothing in dmesg - no disconnect / reconnect etc. >> >> 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. > > Does it mean that the file descriptor opened for ugen has a chance to > be closed ? The USB stack will wait for all FDs to be closed during detach also via destroy_dev(). > > I suspect that usb subsystem tried to destroy the device but some internal > refcounting prevents it. Proper use of destroy_dev(_cb)(9) avoids > the issue. --HPS