usb: phy: Restore deferred probing path
PATCH 1/1 usb: phy: Restore deferred probing path
From: Thierry Reding <[email protected]>
Commit 1290a958d48e ("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from __of_usb_find_phy(), which returns -ENODEV if no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is if try_module_get() did fail, which does not make sense.
The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return -ENODEV is if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.
This patch addresses the problem by making __of_usb_find_phy() return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for the try_module_get() call and a separate error code is returned if the latter fails.
--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/usb/phy/phy.c +10 -4
@@ -59,6 +59,9 @@ static struct usb_phy *__of_usb_find_phy(struct device_node *node) {struct usb_phy *phy; +if (!of_device_is_available (node)) +return ERR_PTR (-ENODEV ); +list_for_each_entry (phy, &phy_list, head) {if (node != phy->dev->of_node)continue ;
@@ -66,7 +69,7 @@ static struct usb_phy *__of_usb_find_phy(struct device_node *node)return phy; } -return ERR_PTR (-ENODEV ); +return ERR_PTR (-EPROBE_DEFER ); }static void devm_usb_phy_release (struct device *dev,void *res)
@@ -190,10 +193,13 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,spin_lock_irqsave (&phy_lock, flags); phy =__of_usb_find_phy (node); -if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { -if (!IS_ERR (phy)) - phy =ERR_PTR (-EPROBE_DEFER ); +if (IS_ERR (phy)) { +devres_free (ptr); + goto err1; + } +if (!try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-ENODEV );devres_free (ptr); goto err1; }
Signature · 1 line
2.1.3
Hello.
Quoted 32 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/usb/phy/phy.c +0
-0
[...]
Quoted 7 lines
drivers/usb/phy/phy.c +0
-3@@ -190,10 +193,13 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,spin_lock_irqsave (&phy_lock, flags); phy =__of_usb_find_phy (node); -if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { -if (!IS_ERR (phy)) - phy =ERR_PTR (-EPROBE_DEFER );
drivers/usb/phy/phy.c struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, · line 205
Quoted 10 lines
drivers/usb/phy/phy.c +6
-0+if (IS_ERR (phy)) { +devres_free (ptr); + goto err1; + } +if (!try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-ENODEV );devres_free (ptr); goto err1; }
I think devres_free() should now be called in one place, under the new
'err2' label.
WBR, Sergei
Quoted 49 lines · Sergei Shtylyov
Hello.
Quoted 32 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/usb/phy/phy.c +0
-0[...]
Quoted 12 lines
drivers/usb/phy/phy.c +4
-3@@ -190,10 +193,13 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,spin_lock_irqsave (&phy_lock, flags); phy =__of_usb_find_phy (node); -if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { -if (!IS_ERR (phy)) - phy =ERR_PTR (-EPROBE_DEFER ); +if (IS_ERR (phy)) { +devres_free (ptr); + goto err1; + }
Quoted 8 lines
drivers/usb/phy/phy.c struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, · line 205
Quoted 5 lines
drivers/usb/phy/phy.c +2
-0+if (!try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-ENODEV );devres_free (ptr); goto err1; }I think
devres_free()should now be called in one place, under the new
'err2' label.
That'd make things very confusing, though. devres_free() should only be called on error, whereas both err1 and err0 are shared with the success case as well. If we were to do what you suggest we'd end up with something like this:
...
phy = __of_usb_find_phy(node);
if (IS_ERR(phy))
goto err2;
if (!try_module_get(...)) {
phy = ERR_PTR(-ENODEV);
goto err2;
}
*ptr = phy;
devres_add(dev, ptr);
get_device(phy->dev);
goto err1;
err2:
devres_free(ptr);
err1:
spin_unlock_irqrestore(&phy_lock, flags);
err0:
of_node_put(node);
return phy;
}That's pretty spaghetti-like.
Thierry
Quoted 58 lines · Thierry Reding
Quoted 45 lines
Quoted 32 lines
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/usb/phy/phy.c +0
-0[...]
Quoted 12 lines
drivers/usb/phy/phy.c +4
-3@@ -190,10 +193,13 @@ struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,spin_lock_irqsave (&phy_lock, flags); phy =__of_usb_find_phy (node); -if (IS_ERR (phy) || !try_module_get (phy->dev->driver->owner)) { -if (!IS_ERR (phy)) - phy =ERR_PTR (-EPROBE_DEFER ); +if (IS_ERR (phy)) { +devres_free (ptr); + goto err1; + }Quoted 8 lines
drivers/usb/phy/phy.c struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, · line 205
Quoted 5 lines
drivers/usb/phy/phy.c +2
-0+if (!try_module_get (phy->dev->driver->owner)) { + phy =ERR_PTR (-ENODEV );devres_free (ptr); goto err1; }I think
devres_free()should now be called in one place, under the new
'err2' label.That'd make things very confusing, though.
devres_free()should only be called on error, whereas both err1 and err0 are shared with the success case as well. If we were to do what you suggest we'd end up with something like this:
[...]
Quoted 1 line
That's pretty spaghetti-like.
Oh, sorry, I wasn't looking attentively enough. :-/
Quoted 1 line
Thierry
WBR, Sergei
Quoted 23 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Ping?
Thierry
Greg Kroah-Hartman
maintainerQuoted 24 lines · Thierry Reding
Quoted 23 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Ping?
It's the middle of the merge window, we can't do anything until 3.19-rc1 is out at the earliest.
And then my vacation kicks in, so it will be a week or so more after that :)
greg k-h
Quoted 30 lines · Greg Kroah-Hartman
Quoted 29 lines · Thierry Reding
Quoted 27 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/phy/phy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Quoted 4 lines
Quoted 1 line
Ping?
It's the middle of the merge window, we can't do anything until 3.19-rc1 is out at the earliest.
This fixes a regression that was introduced in commit 1290a958d48e which has been merged for v3.19-rc1, so this really should go in as soon as possible. I brought this up around the time of v3.18-rc5 and it's a shame it's been broken for so long.
Thierry
Quoted 16 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.
Quoted 8 lines
This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Signed-off-by Thierry Reding <[email protected]>
you forgot to add the magic "Fixes: foo bar" here, I'll add it this time, but I've already sent my -rc2 pull request, so this will only show up on -rc3.
Signature · 1 line
balbi
Quoted 24 lines · Felipe Balbi
Quoted 23 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.
Quoted 5 lines
Quoted 1 line
Signed-off-by Thierry Reding <[email protected]>you forgot to add the magic "Fixes: foo bar" here, I'll add it this time, but I've already sent my -rc2 pull request, so this will only show up on -rc3.
Presumably also add the following, since the patch fixes a regression in a previous kernel release:
?
Quoted 31 lines · Stephen Warren
Quoted 24 lines · Felipe Balbi
Quoted 23 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Commit
1290a958d48e("usb: phy: propagate __of_usb_find_phy()'s error on failure") broke platforms that rely on deferred probing to order probing of PHY and host controller drivers. The reason is that the commit simply propagates errors from__of_usb_find_phy(), which returns-ENODEVif no PHY has been registered yet for a given device tree node. The only case in which -EPROBE_DEFER would now be returned is iftry_module_get()did fail, which does not make sense.The correct thing to do is to return -EPROBE_DEFER if a PHY hasn't been registered yet. The only condition under which it makes sense to return
-ENODEVis if the device tree node representing the PHY has been disabled (via the status property) because in that case the PHY will never be registered.This patch addresses the problem by making
__of_usb_find_phy()return an appropriate error code while keeping in line with the above-mentioned commit to propagate error codes rather than overwriting them. At the same time the check for a valid PHY is decoupled from the check for thetry_module_get()call and a separate error code is returned if the latter fails.Quoted 5 lines
Quoted 1 line
Signed-off-by Thierry Reding <[email protected]>you forgot to add the magic "Fixes: foo bar" here, I'll add it this time, but I've already sent my -rc2 pull request, so this will only show up on -rc3.
Quoted 6 lines
Presumably also add the following, since the patch fixes a regression in a previous kernel release:
Cc stable # v3.18?
The offending commit was only merged in v3.19-rc1. That's also the reason why I didn't deem it necessary to include the Fixes: line. Given that the patch was posted prior to the merge window opening and that it fixes a regression I had assumed it would be merged in the same pull- request as the commit causing the regression.
Thierry