From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F31E142E87; Sun, 24 Mar 2024 22:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320589; cv=none; b=amGfwpqR3YyyQYIz/NI3+ZbSmkLSx63YN9tb5+PCQnnlxUsZOjouKzgFqTPuqIki5KBZUAIy9/hNWPwnt4tvirYoFDLbHsJMHbPZaOC3Mxy3cTF2xSI0+cMIicNkFMwyDyUqD5SLck8T0oA/yvgNdZP2IQwOUlNxQebglIpvp9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320589; c=relaxed/simple; bh=yo2Z2RP8nH+NEKT0SUBmtftPM/25colUC9zO2Yovi1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GixN6oq42Wxva0wxCVbc8OVKJbMJAoziv+BMgpHhZ10zfN5kVCfPy4Mm+AgXDm5we6g0npnvKox7X+g8wgiyBnRJ4AGryqhOwn6B12dqFWM4TIUREVuA9eujC8ofesqDskSk63qIjGT+uXgzLj1aEBbKNC4ZQo4w89Amxz3bd4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PeholQze; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PeholQze" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0615C433F1; Sun, 24 Mar 2024 22:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320589; bh=yo2Z2RP8nH+NEKT0SUBmtftPM/25colUC9zO2Yovi1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PeholQzeA+RAG7yyB+zDJCH9NOPBGYXFFE4stTux1rKPVaw5uN1yJUuB0iNmRMxcD 9GKqyeZGW96h8PP2kIs2+CSbJPRKbgg8GfCdxf5HtfqTlwn/0XVWtpCJlELg6cRulG nqIVdjpI4F8dBe6pItymDyP2kjJ46QdgAEgfDCSNZeXhAG94x1LGE1g091AAwzzSyc utSZC5tSAj9R4w65nuJZl4unw/Vv0z7bIEvbbUMFgGiK5EiybM28jUVJwv3QXXAN28 PHFcY6q/jP2ZkO2Izx5pF5nkvGJKOP5RK9IQz+CAPJ8TktYdApdG3zyjUMvwbhBEtt DwHeiKdOh62Og== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , AngeloGioacchino Del Regno , Matthias Brugger , Viresh Kumar , Sasha Levin Subject: [PATCH 6.7 151/713] cpufreq: mediatek-hw: Wait for CPU supplies before probing Date: Sun, 24 Mar 2024 18:37:57 -0400 Message-ID: <20240324224720.1345309-152-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: NĂ­colas F. R. A. Prado [ Upstream commit 788715b5f21c6455264fe00a1779e61bec407fe2 ] 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Matthias Brugger Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- 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 d46afb3c00923..a1aa9385980ae 100644 --- a/drivers/cpufreq/mediatek-cpufreq-hw.c +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #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) -- 2.43.0