* [PATCHv2 0/2] Fix RK3588 error prints
@ 2023-04-05 16:10 Sebastian Reichel
2023-04-05 16:10 ` [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling Sebastian Reichel
2023-04-05 16:10 ` [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling Sebastian Reichel
0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Reichel @ 2023-04-05 16:10 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Maxime Coquelin, netdev, linux-kernel, Sebastian Reichel, kernel
Hi,
This fixes a couple of false positive error messages printed
by stmmac on RK3588. I expect them to go via net-next since
the fixes are not critical.
Changes since PATCHv1:
* https://lore.kernel.org/all/20230317174243.61500-1-sebastian.reichel@collabora.com/
* Add Fixes tags
* Use loop to request clocks
-- Sebastian
Sebastian Reichel (2):
net: ethernet: stmmac: dwmac-rk: rework optional clock handling
net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 74 ++++++-------------
1 file changed, 24 insertions(+), 50 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling
2023-04-05 16:10 [PATCHv2 0/2] Fix RK3588 error prints Sebastian Reichel
@ 2023-04-05 16:10 ` Sebastian Reichel
2023-04-05 17:42 ` Simon Horman
2023-04-05 19:05 ` Andrew Lunn
2023-04-05 16:10 ` [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling Sebastian Reichel
1 sibling, 2 replies; 7+ messages in thread
From: Sebastian Reichel @ 2023-04-05 16:10 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Maxime Coquelin, netdev, linux-kernel, Sebastian Reichel, kernel
The clock requesting code is quite repetitive. Fix this by requesting
the clocks in a loop. Also use devm_clk_get_optional instead of
devm_clk_get, since the old code effectively handles them as optional
clocks. This removes error messages about missing clocks for platforms
not using them and correct -EPROBE_DEFER handling.
The new code also tries to get "clk_mac_ref" and "clk_mac_refout" when
the PHY is not configured as PHY_INTERFACE_MODE_RMII to keep the code
simple. This is possible since we use devm_clk_get_optional() for the
clock lookup anyways.
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Fixes: 7ad269ea1a2b7 ("GMAC: add driver for Rockchip RK3288 SoCs integrated GMAC")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-rk.c | 63 ++++++-------------
1 file changed, 20 insertions(+), 43 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 4b8fd11563e4..6fdad0f10d6f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1475,54 +1475,31 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
{
struct rk_priv_data *bsp_priv = plat->bsp_priv;
struct device *dev = &bsp_priv->pdev->dev;
- int ret;
+ int i, ret;
+ struct {
+ struct clk **ptr;
+ const char *name;
+ } clocks[] = {
+ { &bsp_priv->mac_clk_rx, "mac_clk_rx" },
+ { &bsp_priv->mac_clk_tx, "mac_clk_tx" },
+ { &bsp_priv->aclk_mac, "aclk_mac" },
+ { &bsp_priv->pclk_mac, "pclk_mac" },
+ { &bsp_priv->clk_mac, "stmmaceth" },
+ { &bsp_priv->clk_mac_ref, "clk_mac_ref" },
+ { &bsp_priv->clk_mac_refout, "clk_mac_refout" },
+ { &bsp_priv->clk_mac_speed, "clk_mac_speed" },
+ };
bsp_priv->clk_enabled = false;
- bsp_priv->mac_clk_rx = devm_clk_get(dev, "mac_clk_rx");
- if (IS_ERR(bsp_priv->mac_clk_rx))
- dev_err(dev, "cannot get clock %s\n",
- "mac_clk_rx");
-
- bsp_priv->mac_clk_tx = devm_clk_get(dev, "mac_clk_tx");
- if (IS_ERR(bsp_priv->mac_clk_tx))
- dev_err(dev, "cannot get clock %s\n",
- "mac_clk_tx");
-
- bsp_priv->aclk_mac = devm_clk_get(dev, "aclk_mac");
- if (IS_ERR(bsp_priv->aclk_mac))
- dev_err(dev, "cannot get clock %s\n",
- "aclk_mac");
-
- bsp_priv->pclk_mac = devm_clk_get(dev, "pclk_mac");
- if (IS_ERR(bsp_priv->pclk_mac))
- dev_err(dev, "cannot get clock %s\n",
- "pclk_mac");
-
- bsp_priv->clk_mac = devm_clk_get(dev, "stmmaceth");
- if (IS_ERR(bsp_priv->clk_mac))
- dev_err(dev, "cannot get clock %s\n",
- "stmmaceth");
-
- if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) {
- bsp_priv->clk_mac_ref = devm_clk_get(dev, "clk_mac_ref");
- if (IS_ERR(bsp_priv->clk_mac_ref))
- dev_err(dev, "cannot get clock %s\n",
- "clk_mac_ref");
-
- if (!bsp_priv->clock_input) {
- bsp_priv->clk_mac_refout =
- devm_clk_get(dev, "clk_mac_refout");
- if (IS_ERR(bsp_priv->clk_mac_refout))
- dev_err(dev, "cannot get clock %s\n",
- "clk_mac_refout");
- }
+ for (i=0; i < ARRAY_SIZE(clocks); i++) {
+ *clocks[i].ptr = devm_clk_get_optional(dev, clocks[i].name);
+ if (IS_ERR(*clocks[i].ptr))
+ return dev_err_probe(dev, PTR_ERR(*clocks[i].ptr),
+ "cannot get clock %s\n",
+ clocks[i].name);
}
- bsp_priv->clk_mac_speed = devm_clk_get(dev, "clk_mac_speed");
- if (IS_ERR(bsp_priv->clk_mac_speed))
- dev_err(dev, "cannot get clock %s\n", "clk_mac_speed");
-
if (bsp_priv->clock_input) {
dev_info(dev, "clock input from PHY\n");
} else {
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
2023-04-05 16:10 [PATCHv2 0/2] Fix RK3588 error prints Sebastian Reichel
2023-04-05 16:10 ` [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling Sebastian Reichel
@ 2023-04-05 16:10 ` Sebastian Reichel
2023-04-05 17:43 ` Simon Horman
1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Reichel @ 2023-04-05 16:10 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Maxime Coquelin, netdev, linux-kernel, Sebastian Reichel, kernel
The usual devm_regulator_get() call already handles "optional"
regulators by returning a valid dummy and printing a warning
that the dummy regulator should be described properly. This
code open coded the same behaviour, but masked any errors that
are not -EPROBE_DEFER and is quite noisy.
This change effectively unmasks and propagates regulators errors
not involving -ENODEV, downgrades the error print to warning level
if no regulator is specified and captures the probe defer message
for /sys/kernel/debug/devices_deferred.
Fixes: 2e12f536635f8 ("net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 6fdad0f10d6f..d9deba110d4b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1656,14 +1656,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
}
}
- bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
+ bsp_priv->regulator = devm_regulator_get(dev, "phy");
if (IS_ERR(bsp_priv->regulator)) {
- if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) {
- dev_err(dev, "phy regulator is not available yet, deferred probing\n");
- return ERR_PTR(-EPROBE_DEFER);
- }
- dev_err(dev, "no regulator found\n");
- bsp_priv->regulator = NULL;
+ ret = PTR_ERR(bsp_priv->regulator);
+ dev_err_probe(dev, ret, "failed to get phy regulator\n");
+ return ERR_PTR(ret);
}
ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling
2023-04-05 16:10 ` [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling Sebastian Reichel
@ 2023-04-05 17:42 ` Simon Horman
2023-04-05 19:05 ` Andrew Lunn
1 sibling, 0 replies; 7+ messages in thread
From: Simon Horman @ 2023-04-05 17:42 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev, linux-kernel, kernel
On Wed, Apr 05, 2023 at 06:10:42PM +0200, Sebastian Reichel wrote:
> The clock requesting code is quite repetitive. Fix this by requesting
> the clocks in a loop. Also use devm_clk_get_optional instead of
> devm_clk_get, since the old code effectively handles them as optional
> clocks. This removes error messages about missing clocks for platforms
> not using them and correct -EPROBE_DEFER handling.
>
> The new code also tries to get "clk_mac_ref" and "clk_mac_refout" when
> the PHY is not configured as PHY_INTERFACE_MODE_RMII to keep the code
> simple. This is possible since we use devm_clk_get_optional() for the
> clock lookup anyways.
>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Fixes: 7ad269ea1a2b7 ("GMAC: add driver for Rockchip RK3288 SoCs integrated GMAC")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
> + for (i=0; i < ARRAY_SIZE(clocks); i++) {
nit: spaces around '='. i.e. 'i = 0;'
> + *clocks[i].ptr = devm_clk_get_optional(dev, clocks[i].name);
> + if (IS_ERR(*clocks[i].ptr))
> + return dev_err_probe(dev, PTR_ERR(*clocks[i].ptr),
> + "cannot get clock %s\n",
> + clocks[i].name);
> }
...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
2023-04-05 16:10 ` [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling Sebastian Reichel
@ 2023-04-05 17:43 ` Simon Horman
2023-04-05 18:20 ` Sebastian Reichel
0 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2023-04-05 17:43 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev, linux-kernel, kernel
On Wed, Apr 05, 2023 at 06:10:43PM +0200, Sebastian Reichel wrote:
> The usual devm_regulator_get() call already handles "optional"
> regulators by returning a valid dummy and printing a warning
> that the dummy regulator should be described properly. This
> code open coded the same behaviour, but masked any errors that
> are not -EPROBE_DEFER and is quite noisy.
>
> This change effectively unmasks and propagates regulators errors
> not involving -ENODEV, downgrades the error print to warning level
> if no regulator is specified and captures the probe defer message
> for /sys/kernel/debug/devices_deferred.
>
> Fixes: 2e12f536635f8 ("net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 6fdad0f10d6f..d9deba110d4b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1656,14 +1656,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
> }
> }
>
> - bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
> + bsp_priv->regulator = devm_regulator_get(dev, "phy");
> if (IS_ERR(bsp_priv->regulator)) {
> - if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) {
> - dev_err(dev, "phy regulator is not available yet, deferred probing\n");
> - return ERR_PTR(-EPROBE_DEFER);
> - }
> - dev_err(dev, "no regulator found\n");
> - bsp_priv->regulator = NULL;
Does phy_power_on() need to be updated for this change?
F.e. Does the bsp_priv->regulator == NULL still make sense?
> + ret = PTR_ERR(bsp_priv->regulator);
> + dev_err_probe(dev, ret, "failed to get phy regulator\n");
> + return ERR_PTR(ret);
> }
>
> ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
2023-04-05 17:43 ` Simon Horman
@ 2023-04-05 18:20 ` Sebastian Reichel
0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Reichel @ 2023-04-05 18:20 UTC (permalink / raw)
To: Simon Horman
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev, linux-kernel, kernel
[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]
Hi Simon,
On Wed, Apr 05, 2023 at 07:43:15PM +0200, Simon Horman wrote:
> On Wed, Apr 05, 2023 at 06:10:43PM +0200, Sebastian Reichel wrote:
> > The usual devm_regulator_get() call already handles "optional"
> > regulators by returning a valid dummy and printing a warning
> > that the dummy regulator should be described properly. This
> > code open coded the same behaviour, but masked any errors that
> > are not -EPROBE_DEFER and is quite noisy.
> >
> > This change effectively unmasks and propagates regulators errors
> > not involving -ENODEV, downgrades the error print to warning level
> > if no regulator is specified and captures the probe defer message
> > for /sys/kernel/debug/devices_deferred.
> >
> > Fixes: 2e12f536635f8 ("net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator")
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 11 ++++-------
> > 1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > index 6fdad0f10d6f..d9deba110d4b 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> > @@ -1656,14 +1656,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
> > }
> > }
> >
> > - bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
> > + bsp_priv->regulator = devm_regulator_get(dev, "phy");
> > if (IS_ERR(bsp_priv->regulator)) {
> > - if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) {
> > - dev_err(dev, "phy regulator is not available yet, deferred probing\n");
> > - return ERR_PTR(-EPROBE_DEFER);
> > - }
> > - dev_err(dev, "no regulator found\n");
> > - bsp_priv->regulator = NULL;
>
> Does phy_power_on() need to be updated for this change?
> F.e. Does the bsp_priv->regulator == NULL still make sense?
Yes, it can be removed (but does not hurt). The regulator API
returns NULL for devm_regulator_get when CONFIG_REGULATOR is
not enabled. But regulator_enable/regulator_disable are just
'return 0;' stubs for that case anyways.
-- Sebastian
> > + ret = PTR_ERR(bsp_priv->regulator);
> > + dev_err_probe(dev, ret, "failed to get phy regulator\n");
> > + return ERR_PTR(ret);
> > }
> >
> > ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
> > --
> > 2.39.2
> >
>
> --
> To unsubscribe, send mail to kernel-unsubscribe@lists.collabora.co.uk.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling
2023-04-05 16:10 ` [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling Sebastian Reichel
2023-04-05 17:42 ` Simon Horman
@ 2023-04-05 19:05 ` Andrew Lunn
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2023-04-05 19:05 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
netdev, linux-kernel, kernel
On Wed, Apr 05, 2023 at 06:10:42PM +0200, Sebastian Reichel wrote:
> The clock requesting code is quite repetitive. Fix this by requesting
> the clocks in a loop. Also use devm_clk_get_optional instead of
> devm_clk_get, since the old code effectively handles them as optional
> clocks. This removes error messages about missing clocks for platforms
> not using them and correct -EPROBE_DEFER handling.
>
> The new code also tries to get "clk_mac_ref" and "clk_mac_refout" when
> the PHY is not configured as PHY_INTERFACE_MODE_RMII to keep the code
> simple. This is possible since we use devm_clk_get_optional() for the
> clock lookup anyways.
>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Fixes: 7ad269ea1a2b7 ("GMAC: add driver for Rockchip RK3288 SoCs integrated GMAC")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 63 ++++++-------------
> 1 file changed, 20 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 4b8fd11563e4..6fdad0f10d6f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1475,54 +1475,31 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
> {
> struct rk_priv_data *bsp_priv = plat->bsp_priv;
> struct device *dev = &bsp_priv->pdev->dev;
> - int ret;
> + int i, ret;
> + struct {
> + struct clk **ptr;
> + const char *name;
> + } clocks[] = {
> + { &bsp_priv->mac_clk_rx, "mac_clk_rx" },
> + { &bsp_priv->mac_clk_tx, "mac_clk_tx" },
> + { &bsp_priv->aclk_mac, "aclk_mac" },
> + { &bsp_priv->pclk_mac, "pclk_mac" },
> + { &bsp_priv->clk_mac, "stmmaceth" },
> + { &bsp_priv->clk_mac_ref, "clk_mac_ref" },
> + { &bsp_priv->clk_mac_refout, "clk_mac_refout" },
> + { &bsp_priv->clk_mac_speed, "clk_mac_speed" },
> + };
> + for (i=0; i < ARRAY_SIZE(clocks); i++) {
> + *clocks[i].ptr = devm_clk_get_optional(dev, clocks[i].name);
> + if (IS_ERR(*clocks[i].ptr))
> + return dev_err_probe(dev, PTR_ERR(*clocks[i].ptr),
> + "cannot get clock %s\n",
> + clocks[i].name);
> }
Could devm_clk_bulk_get_optional() be used?
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-04-05 19:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05 16:10 [PATCHv2 0/2] Fix RK3588 error prints Sebastian Reichel
2023-04-05 16:10 ` [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional clock handling Sebastian Reichel
2023-04-05 17:42 ` Simon Horman
2023-04-05 19:05 ` Andrew Lunn
2023-04-05 16:10 ` [PATCHv2 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling Sebastian Reichel
2023-04-05 17:43 ` Simon Horman
2023-04-05 18:20 ` Sebastian Reichel
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).