linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Johan Hovold <johan@kernel.org>
Cc: Rob Herring <robh@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Douglas Anderson <dianders@chromium.org>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Ravi Chandra Sadineni <ravisadineni@chromium.org>
Subject: Re: [PATCH] usb: misc: onboard_usb_hub: Don't defer probing for 'incomplete' DT nodes
Date: Tue, 20 Dec 2022 14:15:19 +0000	[thread overview]
Message-ID: <Y6HDXiRzaAZ+3uTp@google.com> (raw)
In-Reply-To: <Y6FqiA/SoZHr36jl@hovoldconsulting.com>

Hi Johan,

On Tue, Dec 20, 2022 at 08:55:52AM +0100, Johan Hovold wrote:
> On Tue, Dec 20, 2022 at 12:45:01AM +0000, Matthias Kaehlcke wrote:
> > Some boards have device tree nodes for USB hubs supported by the
> > onboard_usb_hub driver, but the nodes don't have all properties
> > needed for the driver to work properly (which is not necessarily
> > an error in the DT). Currently _find_onboard_hub() returns
> > -EPROBE_DEFER in such cases, which results in an unusable USB hub,
> > since successive probes fail in the same way. Use the absence of
> > the "vdd" supply as an indicator of such 'incomplete' DT nodes
> > and return -ENODEV.
> > 
> > Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver")
> > Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > 
> >  drivers/usb/misc/onboard_usb_hub.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c
> > index d63c63942af1..2968da515016 100644
> > --- a/drivers/usb/misc/onboard_usb_hub.c
> > +++ b/drivers/usb/misc/onboard_usb_hub.c
> > @@ -363,6 +363,15 @@ static struct onboard_hub *_find_onboard_hub(struct device *dev)
> >  	hub = dev_get_drvdata(&pdev->dev);
> >  	put_device(&pdev->dev);
> >  
> > +	/*
> > +	 * Some boards have device tree nodes for USB hubs supported by this
> > +	 * driver, but the nodes don't have all properties needed for the driver
> > +	 * to work properly. Use the absence of the "vdd" supply as an indicator
> > +	 * of such nodes.
> > +	 */
> > +	if (!of_get_property(pdev->dev.of_node, "vdd", NULL))
> > +		return ERR_PTR(-ENODEV);
> 
> Does this not break your original use case? Don't you want "vdd-supply"
> here?

Ouch, yes it does (to a certain degree). Thanks for pointing it out. My
sanity check didn't catch this because the platform driver still probes
successfully and powers the hub on.

> That said, this seems like the wrong property to look for both in
> principle and as it is described as optional by the binding:
> 
> 	Documentation/devicetree/bindings/usb/realtek,rts5411.yaml
> 
> It seems that you should use the compatible property and check that it
> holds one of the expected values:
> 
>  - usbbda,5411
>  - usbbda,411
> 
> rather than treat every hub node as describing a realtek hub (AFAIK,
> there is no generic binding for this yet).

The driver only probes for specific hub models, among them the Microchip
USB2514B hub with which Stefan encountered the regression [1].

My initial assumption when writing this driver was that the existence of
a node for a supported hub means that the driver should be used. However
the regression encountered by Stefan makes clear that this assumption is
incorrect. It's not common, but a device tree may have nodes for onboard
USB devices, among them hubs (which might become more common with this
driver). Not in all instances the hub nodes were added with the intention
of using this driver for power sequencing the hub (e.g. [2]). The
compatible string alone doesn't indicate that the onboard_hub driver
should be instantiated for a given hub, which is why I'm using the
existence of "vdd-supply" as indicator.

Thanks

m.

[1] https://lore.kernel.org/linux-usb/d04bcc45-3471-4417-b30b-5cf9880d785d@i2se.com/
[2] https://elixir.bootlin.com/linux/v6.1/source/arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi

  reply	other threads:[~2022-12-20 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20  0:45 [PATCH] usb: misc: onboard_usb_hub: Don't defer probing for 'incomplete' DT nodes Matthias Kaehlcke
2022-12-20  6:24 ` Thorsten Leemhuis
2022-12-20  6:58 ` Greg Kroah-Hartman
2022-12-20  7:55 ` Johan Hovold
2022-12-20 14:15   ` Matthias Kaehlcke [this message]
2022-12-23 13:42     ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6HDXiRzaAZ+3uTp@google.com \
    --to=mka@chromium.org \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ravisadineni@chromium.org \
    --cc=robh@kernel.org \
    --cc=stefan.wahren@i2se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).