From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98A85C4363A for ; Thu, 8 Oct 2020 14:09:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6603621897 for ; Thu, 8 Oct 2020 14:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730510AbgJHOJa (ORCPT ); Thu, 8 Oct 2020 10:09:30 -0400 Received: from netrider.rowland.org ([192.131.102.5]:42135 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730494AbgJHOJ2 (ORCPT ); Thu, 8 Oct 2020 10:09:28 -0400 Received: (qmail 496113 invoked by uid 1000); 8 Oct 2020 10:09:27 -0400 Date: Thu, 8 Oct 2020 10:09:27 -0400 From: Alan Stern To: Matthias Kaehlcke Cc: Doug Anderson , Rob Herring , Greg Kroah-Hartman , Frank Rowand , "linux-kernel@vger.kernel.org" , Linux USB List , Bastien Nocera , Stephen Boyd , Ravi Chandra Sadineni , Krzysztof Kozlowski , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Peter Chen Subject: Re: [PATCH v4 1/2] dt-bindings: usb: Add binding for discrete onboard USB hubs Message-ID: <20201008140927.GB495091@rowland.harvard.edu> References: <20201006171524.GB423499@rowland.harvard.edu> <20201006192536.GB191572@google.com> <20201007010023.GA438733@rowland.harvard.edu> <20201007160336.GA620323@google.com> <20201007163838.GA457977@rowland.harvard.edu> <20201007172847.GB620323@google.com> <20201007192542.GA468921@rowland.harvard.edu> <20201007194229.GC620323@google.com> <20201007201732.GE468921@rowland.harvard.edu> <20201007214226.GA669360@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201007214226.GA669360@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 07, 2020 at 02:42:26PM -0700, Matthias Kaehlcke wrote: > On Wed, Oct 07, 2020 at 04:17:32PM -0400, Alan Stern wrote: > > The peering relation goes both ways, so it should be included in the > > hub_2_0 description too. Given that, the driver could check hub_2_0's > > peer's DT description for the appropriate resources. > > That mitigates the issue somewhat, however we still have to convince Rob that > both references are needed. Strictly speaking, the peering relation applies to ports, not devices. The representation in DT doesn't have to be symmetrical; as long as the kernel understands it, the kernel can set up its own internal symmetrical respresentation. > > > All this mess can be avoided by having a single instance in control of the > > > resources which is guaranteed to suspend after the USB devices. > > > > Yes. At the cost of registering, adding a driver for, and making users > > aware of a fictitious platform device. > > Registration is trivial and the driver code will be needed anyway, I'm > pretty convinced that a separate platform driver will be simpler than > plumbing things into the hub driver, with the additional checks of who is > suspended or not, etc. If other resources like resets are involved there > could be further possible race conditions at probe time. Another issue is > the sysfs attribute. We said to attach it to the primary hub. What happens > when the primary hub goes away? I guess we could force unbinding the peers > as we did in the driver under discussion to avoid confusion/inconsistencies, > but it's another tradeoff. > > My view of the pros and cons of extending the hub driver vs. having a platform > driver: > > - pros > - sysfs attribute is attached to a USB hub device > - no need to register a platform device (trivial) > - potentially more USB awareness (not clear if needed) > > - cons > - possible races involving resources between peer hubs during initialization > - increased complexity from keeping track of peers, checking suspend order > and avoiding races > - peers are forced to unbind when primary goes away > - need DT links to peers for all USB hubs, not only in the primary > - pollution of the generic hub code with device specific stuff instead > of keeping it in a self contained driver > - sysfs attribute is attached to only one of the hubs, which is better than > having it on both, but not necessarily better than attaching it to the > platform device with the 'control logic' > > So yes, there are tradeoffs, IMO balance isn't as clear as your comment > suggests. Well, I guess I'm okay with either approach. One more thing to keep in mind, though: With the platform device, there should be symlinks from the hubs' sysfs directories to the platform device (and possibly symlinks going the other way as well). Alan Stern