From: Felipe Balbi <balbi@ti.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Arjun Sreedharan <arjun024@gmail.com>,
Felipe Balbi <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-next@vger.kernel.org,
kernel-build-reports@lists.linaro.org
Subject: Re: [PATCH] usb:phy: propagate __of_usb_find_phy()'s error on failure
Date: Mon, 24 Nov 2014 08:36:46 -0600 [thread overview]
Message-ID: <20141124143646.GA20705@saruman> (raw)
In-Reply-To: <20141124131034.GB4061@ulmo.nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 2721 bytes --]
Hi,
On Mon, Nov 24, 2014 at 02:10:41PM +0100, Thierry Reding wrote:
> On Thu, Nov 20, 2014 at 09:23:36PM +0530, Arjun Sreedharan wrote:
> > When __of_usb_find_phy() fails, it returns -ENODEV - its
> > error code has to be returned by devm_usb_get_phy_by_phandle().
> > Only when the former function succeeds and try_module_get()
> > fails should -EPROBE_DEFER be returned.
> >
> > Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
> > ---
> > drivers/usb/phy/phy.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
>
> This causes a boot regression on at least NVIDIA Dalmore (I boot over
> NFS using a USB network adapter).
>
> The commit message is somewhat insufficient because while it explains
> what the code does and asserts that it is the right thing to do, it
> fails to explain why.
you also fail to explain it causes a regressions with Dalmore. This is
really the correct patch, we shouldn't be overwritting the error passed
in by upper layers.
> > diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> > index 045cd30..0310112 100644
> > --- a/drivers/usb/phy/phy.c
> > +++ b/drivers/usb/phy/phy.c
> > @@ -191,7 +191,9 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
> >
> > phy = __of_usb_find_phy(node);
> > if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
> > - phy = ERR_PTR(-EPROBE_DEFER);
> > + if (!IS_ERR(phy))
> > + phy = ERR_PTR(-EPROBE_DEFER);
>
> If we look at this closer, __of_usb_find_phy() return a valid pointer if
> a PHY was found or ERR_PTR(-ENODEV) otherwise. But since the phandle has
> already been validated, the only reason why __of_usb_find_phy() fails is
> because the PHY that the phandle refers to hasn't been registered yet.
>
> Returning -EPROBE_DEFER is the correct thing to do in this situation
> because it gives the PHY driver an opportunity to register and the USB
> host controller to try probing again. I suppose one could argue that
> __of_usb_find_phy() should return ERR_PTR(-EPROBE_DEFER) on failure
> instead of ERR_PTR(-ENODEV), since evidently the device does exist, it
> just hasn't been registered yet. On the other hand it could happen that
> the phandle refers to a device tree node that's status = "disabled", in
> which case ERR_PTR(-ENODEV) might be appropriate.
>
> Also, -EPROBE_DEFER isn't really the proper error for try_module_get()
> failure. Other functions (usb_get_phy() and usb_get_phy_dev()) return
> -ENODEV instead, so it'd be more consistent to stick with that. Hence I
> propose something like the below instead.
I don't mind patch below, but I want to know why Dalmore regressed with
$subject.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-11-24 14:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1416498816-3292-1-git-send-email-arjun024@gmail.com>
2014-11-24 13:10 ` [PATCH] usb:phy: propagate __of_usb_find_phy()'s error on failure Thierry Reding
2014-11-24 14:36 ` Felipe Balbi [this message]
2014-11-24 15:16 ` Thierry Reding
2014-11-24 15:36 ` Felipe Balbi
2014-11-24 15:37 ` Felipe Balbi
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=20141124143646.GA20705@saruman \
--to=balbi@ti.com \
--cc=arjun024@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-build-reports@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=thierry.reding@gmail.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).