[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200929165007.GA1621304@google.com>
Date: Tue, 29 Sep 2020 09:50:07 -0700
From: Matthias Kaehlcke <mka@...omium.org>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
Bastien Nocera <hadess@...ess.net>,
Stephen Boyd <swboyd@...omium.org>,
Douglas Anderson <dianders@...omium.org>,
Ravi Chandra Sadineni <ravisadineni@...omium.org>,
Krzysztof Kozlowski <krzk@...nel.org>,
devicetree@...r.kernel.org, Peter Chen <peter.chen@....com>,
"Alexander A. Klimov" <grandmaster@...klimov.de>,
"David S. Miller" <davem@...emloft.net>,
Johan Hovold <johan@...nel.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Rob Herring <robh@...nel.org>
Subject: Re: [PATCH v4 2/2] USB: misc: Add onboard_usb_hub driver
On Tue, Sep 29, 2020 at 12:00:36PM -0400, Alan Stern wrote:
> On Mon, Sep 28, 2020 at 06:43:55PM -0700, Matthias Kaehlcke wrote:
> > > Have you tried manually unbinding and rebinding the two drivers a few
> > > times to make sure they will still work?
> >
> > I went through a few dozen bund/unbind cycles for both drivers and things
> > looked good overall, but then last minute I found that determining whether
> > wakeup capable devices are connected doesn't always work as (I) expected.
> > I didn't see this earlier, it seems to be reproduce more easily after
> > unbinding and rebinding the platform driver.
> >
> > During development I already noticed that usb_wakeup_enabled_descendants()
> > returns a cached value, which was a problem for an earlier version of the
> > driver. The values are updated by hub_suspend(), my (flawed) assumption
> > was that the USB driver would always suspend before the platform driver.
> > This generally seems to be the case on my development platform after boot,
> > but not necessarily after unbinding and rebinding the driver. Using the
> > _suspend_late hook instead of _suspend seems to be a reliable workaround.
>
> Yes, for unrelated (i.e., not in a parent-child relation) devices, the
> PM subsystem doesn't guarantee ordering of suspend and resume callbacks.
> You can enforce the ordering by using device_pm_wait_for_dev(). But the
> suspend_late approach seems like a better solution in this case.
Thanks for the confirmation. Good to know about device_pm_wait_for_dev(),
even if we are not going to use it in this case.
> > > I'm a little concerned about all the devm_* stuff in here; does that
> > > get released when the driver is unbound from the device or when the device
> > > is unregistered? And if the latter, what happens if you have multiple
> > > sysfs attribute groups going at the same time?
> >
> > The memory gets released when the device is unbound:
> >
> > device_release_driver
> > device_release_driver_internal
> > __device_release_driver
> > devres_release_all
> >
> > Anyway, if you prefer I can change the driver to use kmalloc/kfree.
>
> No, that's fine. I just wasn't sure about this and wanted to check.
I think the only concern would be a scenario where the USB devices are
unbound and rebound over and over again, which would result in a
struct udev_node being kept around for every bind until the platform
device is removed. It seems unlikely and shouldn't be a big problem
as long as the number of bind/unbind cycles is in the thousands rather
than millions.
Powered by blists - more mailing lists