[PATCH v4] clk: imx8qxp: Defer instead of failing probe

From: Diogo Manuel Pais Silva
Date: Wed Sep 04 2024 - 02:50:16 EST


When of_clk_parent_fill is ran without all the parent clocks having been
probed then the probe function will return -EINVAL, making it so that
the probe isn't attempted again. As fw_devlink is on by default this
does not usually happen, but if fw_devlink is disabled then it is very
possible that the parent clock will be probed after the lpcg first
attempt.

Signed-off-by: Diogo Silva <diogo.pais@xxxxxxxxxxxxx>
---
v2: change from dev_warn to dev_err_probe
v3: refresh patch
v4: correctly propagate probe defer error
---
drivers/clk/imx/clk-imx8qxp-lpcg.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-imx8qxp-lpcg.c
index d0ccaa040225..1c3e1a7df8ca 100644
--- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
+++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
@@ -225,8 +225,8 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,

ret = of_clk_parent_fill(np, parent_names, count);
if (ret != count) {
- dev_err(&pdev->dev, "failed to get clock parent names\n");
- return count;
+ return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
+ "failed to get all clock parent names\n");
}

ret = of_property_read_string_array(np, "clock-output-names",
@@ -301,6 +301,8 @@ static int imx8qxp_lpcg_clk_probe(struct platform_device *pdev)
ret = imx_lpcg_parse_clks_from_dt(pdev, np);
if (!ret)
return 0;
+ if (ret == -EPROBE_DEFER)
+ return ret;

ss_lpcg = of_device_get_match_data(dev);
if (!ss_lpcg)
--
2.34.1

________________________________________
From: Peng Fan <peng.fan@xxxxxxx>
Sent: Wednesday, September 4, 2024 4:03 AM
To: Diogo Manuel Pais Silva; Abel Vesa
Cc: abelvesa@xxxxxxxxxx; linux-clk@xxxxxxxxxxxxxxx; shawnguo@xxxxxxxxxx; kernel@xxxxxxxxxxxxxx; s.hauer@xxxxxxxxxxxxxx; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx; sboyd@xxxxxxxxxx; mturquette@xxxxxxxxxxxx; festevam@xxxxxxxxx; imx@xxxxxxxxxxxxxxx; EMC: linux-kernel@xxxxxxxxxxxxxxx
Subject: RE: [PATCH v3] clk: imx8qxp: Defer instead of failing probe

Hi Diogo,

> Subject: [PATCH v3] clk: imx8qxp: Defer instead of failing probe
>
> When of_clk_parent_fill is ran without all the parent clocks having
> been probed then the probe function will return -EINVAL, making it so
> that the probe isn't attempted again. As fw_devlink is on by default
> this does not usually happen, but if fw_devlink is disabled then it is
> very possible that the parent clock will be probed after the lpcg first
> attempt.

Did you meet issue with fw_devlink disabled?

>
> Signed-off-by: Diogo Silva <diogo.pais@xxxxxxxxxxxxx>
> ---
> v2: change from dev_warn to dev_err_probe
> v3: refresh patch
> ---
> drivers/clk/imx/clk-imx8qxp-lpcg.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c b/drivers/clk/imx/clk-
> imx8qxp-lpcg.c
> index d0ccaa040225..cae8f6060fe8 100644
> --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> @@ -225,8 +225,8 @@ static int imx_lpcg_parse_clks_from_dt(struct
> platform_device *pdev,
>
> ret = of_clk_parent_fill(np, parent_names, count);
> if (ret != count) {
> - dev_err(&pdev->dev, "failed to get clock parent names\n");
> - return count;
> + return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
> + "failed to get all clock parent
> + names\n");
> }

The change is not enough, you also need to handle
ret = imx_lpcg_parse_clks_from_dt(pdev, np);
if (!ret)
return 0;
->
ret = imx_lpcg_parse_clks_from_dt(pdev, np);
if (!ret)
return 0;
if (ret == -EPROBE_DEFER)
return ret;

Regards,
Peng.

>
> ret = of_property_read_string_array(np, "clock-output-names",
> --
> 2.34.1
> ________________________________________
> From: Abel Vesa <abel.vesa@xxxxxxxxxx>
> Sent: Wednesday, August 28, 2024 10:31 AM
> To: Diogo Manuel Pais Silva
> Cc: Peng Fan; abelvesa@xxxxxxxxxx; linux-clk@xxxxxxxxxxxxxxx;
> shawnguo@xxxxxxxxxx; kernel@xxxxxxxxxxxxxx;
> s.hauer@xxxxxxxxxxxxxx; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx;
> sboyd@xxxxxxxxxx; mturquette@xxxxxxxxxxxx; festevam@xxxxxxxxx;
> imx@xxxxxxxxxxxxxxx; EMC: linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2] clk: imx8qxp: Defer instead of failing probe
>
> On 24-07-02 08:10:44, Diogo Manuel Pais Silva wrote:
> > When of_clk_parent_fill is ran without all the parent clocks having
> been probed then the probe function will return -EINVAL, making it so
> that the probe isn't attempted again. As fw_devlink is on by default
> this does not usually happen, but if fw_devlink is disabled then it is
> very possible that the parent clock will be probed after the lpcg first
> attempt.
> >
> > Signed-off-by: Diogo Silva <diogo.pais@xxxxxxxxxxxxx>
>
> This patch doesn't apply cleanly.
>
> Please respin.
>
> Thanks!
>
> > ---
> > v2: change from dev_warn to dev_err_probe
> > ---
> > drivers/clk/imx/clk-imx8qxp-lpcg.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> > b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> > index d0ccaa040225..7bd9b745edbe 100644
> > --- a/drivers/clk/imx/clk-imx8qxp-lpcg.c
> > +++ b/drivers/clk/imx/clk-imx8qxp-lpcg.c
> > @@ -225,8 +225,8 @@ static int
> imx_lpcg_parse_clks_from_dt(struct
> > platform_device *pdev,
> >
> > ret = of_clk_parent_fill(np, parent_names, count);
> > if (ret != count) {
> > - dev_err(&pdev->dev, "failed to get clock parent names\n");
> > - return count;
> > + return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
> > + "failed to get all clock parent
> > + names\n");
> > }
> >
> > ret = of_property_read_string_array(np, "clock-output-names",
> > --
> > 2.34.1