2022-05-26 00:22:45

by Michael Walle

[permalink] [raw]
Subject: [PATCH net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE

At the moment, if devm_of_phy_get() returns an error the serdes
simply isn't set. While it is bad to ignore an error in general, there
is a particular bug that network isn't working if the serdes driver is
compiled as a module. In that case, devm_of_phy_get() returns
-EDEFER_PROBE and the error is silently ignored.

The serdes is optional, it is not there if the port is using RGMII, in
which case devm_of_phy_get() returns -ENODEV. Rearrange the error
handling so that -ENODEV will be handled but other error codes will
abort the probing.

Fixes: d28d6d2e37d1 ("net: lan966x: add port module support")
Signed-off-by: Michael Walle <[email protected]>
---
drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 6ad68b422129..5784c4161e5e 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1120,8 +1120,13 @@ static int lan966x_probe(struct platform_device *pdev)
lan966x->ports[p]->fwnode = fwnode_handle_get(portnp);

serdes = devm_of_phy_get(lan966x->dev, to_of_node(portnp), NULL);
- if (!IS_ERR(serdes))
- lan966x->ports[p]->serdes = serdes;
+ if (PTR_ERR(serdes) == -ENODEV)
+ serdes = NULL;
+ if (IS_ERR(serdes)) {
+ err = PTR_ERR(serdes);
+ goto cleanup_ports;
+ }
+ lan966x->ports[p]->serdes = serdes;

lan966x_port_init(lan966x->ports[p]);
}
--
2.30.2



2022-05-28 19:03:31

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE

On Fri, 27 May 2022 09:54:37 +0200 Michael Walle wrote:
> > This patch was applied to bpf/bpf.git (master)
>
> bpf tree?

Nah, treat pw-bot like a toddler who occasionally says the darndest
things. BPF and netdev share a patchwork instance. The BPF maintainers
probably forwarded their tree around the same time I pushed this patch
to net and the bot noticed it in their tree first.

2022-05-28 19:08:16

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE

Hello:

This patch was applied to bpf/bpf.git (master)
by Jakub Kicinski <[email protected]>:

On Thu, 26 May 2022 01:12:39 +0200 you wrote:
> At the moment, if devm_of_phy_get() returns an error the serdes
> simply isn't set. While it is bad to ignore an error in general, there
> is a particular bug that network isn't working if the serdes driver is
> compiled as a module. In that case, devm_of_phy_get() returns
> -EDEFER_PROBE and the error is silently ignored.
>
> The serdes is optional, it is not there if the port is using RGMII, in
> which case devm_of_phy_get() returns -ENODEV. Rearrange the error
> handling so that -ENODEV will be handled but other error codes will
> abort the probing.
>
> [...]

Here is the summary with links:
- [net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE
https://git.kernel.org/bpf/bpf/c/b58cdd4388b1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



2022-05-28 20:42:41

by Michael Walle

[permalink] [raw]
Subject: Re: [PATCH net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE

> This patch was applied to bpf/bpf.git (master)

bpf tree?

-michael