public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: kernel@collabora.com, "Hector.Yuan" <hector.yuan@mediatek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing
Date: Mon, 22 Jan 2024 09:38:50 +0100	[thread overview]
Message-ID: <011d5f5b-cf10-4476-8b5c-2fc9805e71e2@gmail.com> (raw)
In-Reply-To: <20240110142305.755367-3-nfraprado@collabora.com>



On 10/01/2024 15:23, Nícolas F. R. A. Prado wrote:
> Before proceeding with the probe and enabling frequency scaling for the
> CPUs, make sure that all supplies feeding the CPUs have probed.
> 
> This fixes an issue observed on MT8195-Tomato where if the
> mediatek-cpufreq-hw driver enabled the hardware (by writing to
> REG_FREQ_ENABLE) before the SPMI controller driver (spmi-mtk-pmif),
> behind which lies the big CPU supply, probed the platform would hang
> shortly after with "rcu: INFO: rcu_preempt detected stalls on
> CPUs/tasks" being printed in the log.
> 
> Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> 
> ---
> 
> Changes in v2:
> - Added this commit
> 
>   drivers/cpufreq/mediatek-cpufreq-hw.c | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> index d46afb3c0092..a1aa9385980a 100644
> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> @@ -13,6 +13,7 @@
>   #include <linux/of.h>
>   #include <linux/of_platform.h>
>   #include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
>   #include <linux/slab.h>
>   
>   #define LUT_MAX_ENTRIES			32U
> @@ -300,7 +301,23 @@ static struct cpufreq_driver cpufreq_mtk_hw_driver = {
>   static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
>   {
>   	const void *data;
> -	int ret;
> +	int ret, cpu;
> +	struct device *cpu_dev;
> +	struct regulator *cpu_reg;
> +
> +	/* Make sure that all CPU supplies are available before proceeding. */
> +	for_each_possible_cpu(cpu) {
> +		cpu_dev = get_cpu_device(cpu);
> +		if (!cpu_dev)
> +			return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
> +					     "Failed to get cpu%d device\n", cpu);
> +
> +		cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu");
> +		if (IS_ERR(cpu_reg))
> +			return dev_err_probe(&pdev->dev, PTR_ERR(cpu_reg),
> +					     "CPU%d regulator get failed\n", cpu);
> +	}
> +
>   
>   	data = of_device_get_match_data(&pdev->dev);
>   	if (!data)

  parent reply	other threads:[~2024-01-22  8:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 14:23 [PATCH v2 0/2] Fixes for hang on MT8195-Tomato during mediatek-cpufreq-hw init Nícolas F. R. A. Prado
2024-01-10 14:23 ` [PATCH v2 1/2] arm64: dts: mediatek: cherry: Describe CPU supplies Nícolas F. R. A. Prado
2024-01-10 14:32   ` AngeloGioacchino Del Regno
2024-02-29 20:23     ` Nícolas F. R. A. Prado
2024-03-01  8:52       ` AngeloGioacchino Del Regno
2024-03-01 14:29   ` Nícolas F. R. A. Prado
2024-01-10 14:23 ` [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Nícolas F. R. A. Prado
2024-01-10 14:31   ` AngeloGioacchino Del Regno
2024-01-22  8:38   ` Matthias Brugger [this message]
2024-01-23  6:09   ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=011d5f5b-cf10-4476-8b5c-2fc9805e71e2@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=hector.yuan@mediatek.com \
    --cc=kernel@collabora.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nfraprado@collabora.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox