Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp597229imu; Mon, 5 Nov 2018 06:02:47 -0800 (PST) X-Google-Smtp-Source: AJdET5dFnRDYIJ2FLvHkdwgkTWuSGfoMuQ8o9SxUUCp3Oex8vyqRGhj/DqVPipx87dR1WZXwNJ9h X-Received: by 2002:a17:902:6a8b:: with SMTP id n11-v6mr1453473plk.311.1541426567548; Mon, 05 Nov 2018 06:02:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541426567; cv=none; d=google.com; s=arc-20160816; b=RrRst3qRA0WLOBJwuQ79t/madyp17TO23kW/6oLTIXEy07xZW2ZGsI+t1JE1GkWLmG SuxMzzD7MgvNzXMP/dGt+Aib2JF16Kmu3M0wgnAitVQUG0dvqez8/XBVEFWIAE9JaMKX 0BI8vrVa6jojqqtXQ0KRI0EBbjDqNe3xkcndn2yJ5g0PTzfKAGwxLAA6CYIIk/qgfGK3 Sxa1S9bcIDgSbcHCs5Au0QW3xadWvA8m/WGAOd3Fx9cswqvaArBvGcHIbvVp8hE9mo1l kuTt2IDsUs+TMIYZ619DwBnvF+S5sxFYp958h4Y+as0Gx1fqjoMqg41JTe1OjGvlfhm7 6kpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uFVcncG4Y2pOL9e2/D8/RePxAzUFMIILrsMHDQMaEhs=; b=F9aNJ5CaOpUsGw8wctNJxa/Aj4ZnnOzYT9alRbz7ZqbO5QDTA9GFL+xtipm6xfBeRj UtdXklHk+r1+q8e9U9ICGz2A6oCW3KI3MNWJu5z00O4aLe13sD+Xy2KOv3nXGMu1THzH UNah+m8+sG7/BAqEkC476xGEBwMaRARvzCvClJE1MJYIJExTL40fm/FONqD0bRRLz47n jWb4Pk1/jXnlvP69qdgjgsGlcKZL237a6dnu3RJxhhguaGh6+QC9wyX+FaXmrggzZHX5 6h6Y/laROmy1XTuFxJRqesrF072cUKx1xLIsLY32CIV4WPx8fQ4AexbSWgKiqv8AndWs M2aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CxLjWnNS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32-v6si11168979plc.370.2018.11.05.06.02.29; Mon, 05 Nov 2018 06:02:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CxLjWnNS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729893AbeKEXV5 (ORCPT + 99 others); Mon, 5 Nov 2018 18:21:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:60860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729549AbeKEXV5 (ORCPT ); Mon, 5 Nov 2018 18:21:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 12C12204FD; Mon, 5 Nov 2018 14:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541426524; bh=BS+RtQd4SFh1nbCiGv9mMTn2KNAoBgLcEec5r+vZUkk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CxLjWnNS14QkYlU7/IF0WPMvNERgAP7vO4/AZLLvw6zzBUhsexW+2s4ALv2AhkVee KrR/9zfZuYRZIfd/5dyXSHVIexzY+9M5Cu6+VwxUa49VlAmAX2zDaj2O6XTRkCYSxy WDBmiyovVgefY1w2o97zP84ZAnfa8cPB7GuvW7DA= Date: Mon, 5 Nov 2018 15:02:02 +0100 From: Greg KH To: Jonas Bonn Cc: linux-kernel@vger.kernel.org, rafael@kernel.org Subject: Re: KOBJ_BIND uevent Message-ID: <20181105140202.GA14870@kroah.com> References: <20181105132106.GB20797@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 05, 2018 at 02:44:21PM +0100, Jonas Bonn wrote: > Hi, > > On 05/11/2018 14:21, Greg KH wrote: > > On Mon, Nov 05, 2018 at 11:35:57AM +0100, Jonas Bonn wrote: > > > Hi, > > > > > > I have a question about the ordering of uevents, specifically concerning > > > complex USB devices that present multiple interfaces/functions. > > > > > > Before KOBJ_BIND, a USB device would typically present itself as: > > > > > > add usb_device > > > add usb_interface-1 > > > add subsystem-device-1.0 > > > add subsystem-device-1.1 > > > add usb_interface-2 > > > add subsystem-device-2.0 > > > > > > I have noted that the recently added "bind" actions, however, present in the > > > reverse order. > > > > > > bind subsystem-device-1.0 > > > bind subsystem-device-1.1 > > > bind usb-interface-1 > > > bind subsystem-device-2.0 > > > bind usb_interface-2 > > > bind usb_device > > > > > > This secondary ordering could be useful in the sense that the final "bind" > > > action on the usb_device is an indication that the kernel has finished > > > enumeration of all endpoints and has bound all drivers that it could to the > > > available interfaces... i.e. no further events for this device are expected. > > > > Maybe. Maybe not, as userspace might still be in the process of loading > > new kernel drivers based on the add uevents that got sent out. Then > > binding would happen later after the usb_device was "bound". > > > > > The question, then, is: is the above ordering of "bind" events stable, or > > > is it just a consequence of the current implementation and may change in the > > > future? > > > > Not stable at all, sorry, you can not depend on it. > > > > Nor should you even try to, what problem are you wanting to solve here? > > Specifically, I'm dealing with USB modems that fall into two categories: > > i) present a bunch of USB interfaces with one ACM (or similar) class device > on each interface (one TTY for data, control, GPS, etc.) > > ii) present one interface with multiple endpoints that end up as multiple > Linux devices (typically usbmisc device + network interface) > > In both cases, the modem really isn't useful until all the > interfaces/endpoints are ready. It would be nice to be able to have one > uevent that indicates that the kernel has done all it can with the device so > we can evaluate whether we have everything we need. Yes, many many many people have wanted that pony for a few decades now, there is no way for the kernel to provide you this "flag", sorry. > Currently, we set a 1 second delay from the "add usb_device" before > proceeding to evaluate the available modem interfaces; this delay is > normally sufficient for everything to be enumerated and drivers bound, but > it's still just an arbitrary delay. If all of the kernel drivers are in the kernel at the moment, that should be fine. But yes, it is arbitrary, which is what happens with dynamic devices, sorry. good luck! greg k-h