[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <63d1da22-84b0-1b02-2766-99cc298a8ac4@linaro.org>
Date: Fri, 3 Feb 2023 03:49:56 +0100
From: Konrad Dybcio <konrad.dybcio@...aro.org>
To: Johan Hovold <johan+linaro@...nel.org>,
Georgi Djakov <djakov@...nel.org>
Cc: Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Sylwester Nawrocki <s.nawrocki@...sung.com>,
Artur Świgoń <a.swigon@...sung.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Alim Akhtar <alim.akhtar@...sung.com>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-arm-msm@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
linux-tegra@...r.kernel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org, Leonard Crestez <leonard.crestez@....com>,
Alexandre Bailon <abailon@...libre.com>
Subject: Re: [PATCH 04/23] interconnect: imx: fix registration race
On 1.02.2023 11:15, Johan Hovold wrote:
> The current interconnect provider registration interface is inherently
> racy as nodes are not added until the after adding the provider. This
> can specifically cause racing DT lookups to fail.
>
> Switch to using the new API where the provider is not registered until
> after it has been fully initialised.
>
> Fixes: f0d8048525d7 ("interconnect: Add imx core driver")
> Cc: stable@...r.kernel.org # 5.8
> Cc: Leonard Crestez <leonard.crestez@....com>
> Cc: Alexandre Bailon <abailon@...libre.com>
> Signed-off-by: Johan Hovold <johan+linaro@...nel.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@...aro.org>
Konrad
> drivers/interconnect/imx/imx.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/interconnect/imx/imx.c b/drivers/interconnect/imx/imx.c
> index 823d9be9771a..979ed610f704 100644
> --- a/drivers/interconnect/imx/imx.c
> +++ b/drivers/interconnect/imx/imx.c
> @@ -295,6 +295,9 @@ int imx_icc_register(struct platform_device *pdev,
> provider->xlate = of_icc_xlate_onecell;
> provider->data = data;
> provider->dev = dev->parent;
> +
> + icc_provider_init(provider);
> +
> platform_set_drvdata(pdev, imx_provider);
>
> if (settings) {
> @@ -306,20 +309,18 @@ int imx_icc_register(struct platform_device *pdev,
> }
> }
>
> - ret = icc_provider_add(provider);
> - if (ret) {
> - dev_err(dev, "error adding interconnect provider: %d\n", ret);
> + ret = imx_icc_register_nodes(imx_provider, nodes, nodes_count, settings);
> + if (ret)
> return ret;
> - }
>
> - ret = imx_icc_register_nodes(imx_provider, nodes, nodes_count, settings);
> + ret = icc_provider_register(provider);
> if (ret)
> - goto provider_del;
> + goto err_unregister_nodes;
>
> return 0;
>
> -provider_del:
> - icc_provider_del(provider);
> +err_unregister_nodes:
> + imx_icc_unregister_nodes(&imx_provider->provider);
> return ret;
> }
> EXPORT_SYMBOL_GPL(imx_icc_register);
> @@ -328,9 +329,8 @@ void imx_icc_unregister(struct platform_device *pdev)
> {
> struct imx_icc_provider *imx_provider = platform_get_drvdata(pdev);
>
> + icc_provider_deregister(&imx_provider->provider);
> imx_icc_unregister_nodes(&imx_provider->provider);
> -
> - icc_provider_del(&imx_provider->provider);
> }
> EXPORT_SYMBOL_GPL(imx_icc_unregister);
>
Powered by blists - more mailing lists