diff mbox series

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

Message ID DU0PR01MB9382A24116486931F28843BA9D9C2@DU0PR01MB9382.eurprd01.prod.exchangelabs.com (mailing list archive)
State Changes Requested, archived
Headers show
Series [v4] clk: imx8qxp: Defer instead of failing probe | expand

Commit Message

Diogo Manuel Pais Silva Sept. 4, 2024, 6:50 a.m. UTC
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@ttcontrol.com>
---
  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(-)

--
2.34.1

Comments

Stephen Boyd Sept. 5, 2024, 6:35 p.m. UTC | #1
Quoting Diogo Manuel Pais Silva (2024-09-03 23:50:02)
> 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@ttcontrol.com>
> ---

Please stop sending as replies to previous patches.

>  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);

It would be better to move to struct clk_parent_data here and use the
.index member if possible. That would allow the clks to be registered
without their parent(s) being registered. It lets the core take care of
finding the parents.
diff mbox series

Patch

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)