Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp792794pxu; Wed, 7 Oct 2020 16:34:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZiPhovaLDqIeJMnq0k1awaekkn84rN3ng29jIf1gfEIspupjPGVD6BeW/dWPpgVZVUeG1 X-Received: by 2002:a50:cf8a:: with SMTP id h10mr6256864edk.43.1602113677999; Wed, 07 Oct 2020 16:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602113677; cv=none; d=google.com; s=arc-20160816; b=gF5pqFkp2e8bo+56H4ZB5Bpti42Ppe/zejuiE8yuUTrJP873XbyFGC27EJn8MwHTDo 9OTPWBM5LWREmGZfrNXj7vhugi/F9sa8cD5bcWAqi8zDamMwgcku/BkvFddlnmBTQlLz 3ITl/4YDs+LdQjob8TqQwtC+ShqaUHVCYx7Z5uTVV8te8G2EZDgUJvmVhxCRjPcuuH4m kkoWcci0vhpc+vDiVllGnvxryB7Uzj1lBuwbnXQmjzdxglOTyhPwx1js7MTKW3mwVIPh w6bl+QbG4a9Nr/+5MD1V/RPbNGK+bE6cWW4hdlyAE9LSWBqALz4f3HH/4+soAQgChdiP wX1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zJrmD0uI1sV3Rv4ItPk0Mq8recNL4HitjbN23S3Dp0M=; b=HGs2Za7xLC2+UDifAZ9VZG2hwFUTJqxQt5Fm8Hi1WS8BwRyoXHJnNG3Y0Kwxlgba3H LBSKLY3obXJauGo7UpYQbqMIo0TaYb0KtBqTyyPf4ZcobvRPI2tOU5k9WsT/MtWNcJwT XKpIRJCUNYuhWLBlGUq1Qxjzg0SSd0if4HmDh8AdS6CGWOvpTlxOr3MqiiYzRLPM5Iqu gG2QZxjWGKyG2fJuVuk12R8zfHD+q7KhWkcMQY7tA8+y76CpzCmAgnJIFP5oqg4nt4Mm i7vPhup4WFX09HxUoLrkEuyTYjzERtS87d7/L6uRnZa5LPipoTWsgCKZKMrZB0vfbJNF qv0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si3408790edm.62.2020.10.07.16.34.14; Wed, 07 Oct 2020 16:34:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbgJGTZn (ORCPT + 99 others); Wed, 7 Oct 2020 15:25:43 -0400 Received: from netrider.rowland.org ([192.131.102.5]:44797 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726671AbgJGTZn (ORCPT ); Wed, 7 Oct 2020 15:25:43 -0400 Received: (qmail 469681 invoked by uid 1000); 7 Oct 2020 15:25:42 -0400 Date: Wed, 7 Oct 2020 15:25:42 -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: <20201007192542.GA468921@rowland.harvard.edu> References: <20201006004510.GD4135817@google.com> <20201006141820.GA416765@rowland.harvard.edu> <20201006165957.GA191572@google.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201007172847.GB620323@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 10:28:47AM -0700, Matthias Kaehlcke wrote: > On Wed, Oct 07, 2020 at 12:38:38PM -0400, Alan Stern wrote: > > On Wed, Oct 07, 2020 at 09:03:36AM -0700, Matthias Kaehlcke wrote: > > > Ok, I wasn't sure if the hubs suspend asynchronously from each other. If they > > > do it should indeed not be a problem to have the "master" wait for its peers. > > > > Well, order of suspending is selectable by the user. It can be either > > asynchronous or reverse order of device registration, which might pose a > > problem. We don't know in advance which of two peer hubs will be > > registered first. It might be necessary to introduce some additional > > explicit synchronization. > > I'm not sure we are understanding each other completely. I agree that > synchronization is needed to have the primary hub wait for its peers, that > was one of my initial concerns. > > Lets use an example to clarify my secondary concern: a hub chip provides a > USB 3 and a USB 2 hub, lets say the USB 3 hub is the primary. > > Here is some pseudo-code for the suspend function: > > hub_suspend(hub) > ... > > if (hub->primary) { > device_pm_wait_for_dev(hub->peer) > > // check for connected devices and turn regulator off > } > > ... > } > > What I meant with 'asynchronous suspend' in this context: > > Can hub_suspend() of the peer hub be executed (asynchronously) while the > primary is blocked on device_pm_wait_for_dev(), Yes, that's exactly what would happen with async suspend. > or would the primary wait > forever if the peer hub isn't suspended yet? That wouldn't happen. device_pm_wait_for_dev is smart; it will return immediately if neither device uses async suspend. But in that case you could end up removing power from the peer hub before it had suspended. That's why I said you might need to add additional synchronization. The suspend routines for the two hubs could each check to see whether the other device had suspended yet, and the last one would handle the power regulator. The additional synchronization is for the case where the two checks end up being concurrent. > > > > And hubs would need to know their peers in any case, because you have to > > > > check if any devices attached to the peer have wakeup enabled. > > > > > > My concern was about all hubs (including 'secondaries') having to know their > > > peers and check on each other, in the scenario we are now talking about only > > > the "master" hub needs to know and check on its peers, which is fine. > > > > Not all hubs would need this. Only ones marked in DT as having a power > > regulator. > > Sure, as long as the primary (with a power regulator) can wait for its peers > to suspend without the risk of blocking forever (my doubt above). If we take this approach, we'll have to give up on the idea that the primary can always suspend after the peer. Alan Stern