Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2557145lqp; Mon, 25 Mar 2024 02:30:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+/ljRPNTn10pRAi/bSkMLGS8ppIqHtvM+PtnF1hs5dp2iI6svRyD9CGldBdmcBlj+j6LCyx86I7vG6znjIA7Dyt+QyomHe+SgqAQnFw== X-Google-Smtp-Source: AGHT+IEKouHF9N7VEH+Ot+atylgQhD+YZS39SsfbiHdtItBwjWvjlzni+B8c2WqeGvdEHeA7Tixg X-Received: by 2002:a05:6214:1308:b0:691:e21:736c with SMTP id pn8-20020a056214130800b006910e21736cmr8502795qvb.30.1711359056940; Mon, 25 Mar 2024 02:30:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711359056; cv=pass; d=google.com; s=arc-20160816; b=h/7LXogMSEwz/ddQg/akbPH+WytyfzTqiLv49eA1hVS0NHAW4EPwwAN9t4v0xxuF10 nGkFmGM08oo8KDpelF34pcLMt5/4fNorr7Q/jtm6PcKHdFNsUrfZURzgJbT+OiEJaSXC tsaHmEoHKDf1k0rgpwu2SDWNXZNncNaEl52lASAZ/eMYaM9lopE3Spibwz13O7OrlTRn 1t5Vva7a8iss6W27t4dTjl7O2Enwfbldiy4Rj5PNNI6cZt8CjQs/F4CiigWs79zZCEvT Pj8NwwdI1mzPy+Z6/mlkwlNMhzgSNzo6ltcO5But9P2NfP/m4Tu9nxhah8Sghtp9hIjt cemg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eitfgqaCpr/4JA2RkqQjr/ZUh8EE50zk58hq7k1N/I4=; fh=1/CfgxdfSr4xUhMCp+L7s821ekbyUVHY/Z/bh+YNqH8=; b=BTktDhCMa+GSj7PZCvJI66YV7ssQ9T4HunI+S/P3IK93SqnL3eE70CcnU/AUbDFvsI zP1P1vLtHoNgi2Uy3hQ6lyqkCIAE57ZzPZ+ny9JhwA8NSgkAO+tc9n5aklTcyrU2zSJJ iPF/jpW1K3dgdtMrG7LgoA6HtOIYpFUyT209U1YmJfIWutUXcMvOqZSGxpJbJBwkwvjB J+FfkB6dXGvhHhxSgsrWbcrvCsQVcifndVVmcMePJtNN1FYS9ACROymWLHSfSwE1i56B T+KJP0vA7572NcovH15/IFgL/ttvvEhRJbbzZm7VFmQsfS+maILN2wf+AATWrTxo7ZYc ywHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g40Kce4+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gg4-20020a056214252400b006968fccad81si1259127qvb.437.2024.03.25.02.30.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g40Kce4+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A7ECB1C315F1 for ; Mon, 25 Mar 2024 09:30:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29FA63709FE; Mon, 25 Mar 2024 03:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g40Kce4+" 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 1B147145B24; Sun, 24 Mar 2024 23:13:45 +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=1711322026; cv=none; b=dJkkO6QHGWoZ2ftf+xI5ZjLBOQxG8WL7C2m8NjDnqVd74vsedwvJSNy+jMS7KqvEm7DDk49M58B6ohY+7sWZ9icoWuRvIjuDxO6fChdBSwWBCxF+b4GD1Hxr7TuOr8eKsKfyEEIPwCNqlACTt5ocRHcIimdqqlzlH71ZUyNfhz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322026; c=relaxed/simple; bh=AG23bdc6T+HcriaBH5aprj0FR+KrOH33r/hrRR9Hni4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O+FgZxrNvyvRx37OopOInFKnfuH7GCNVLWG7MsE1uVOQnhmEnkQnWodGCKsOVZgPcAUVF1NvDaI8RhrLW8utOTyBFcDqDuV9LQbWHHm43V3ty0B0PlMaYviyVEQWP96jZ0SiyorScoWeKLe5+cAFYjZAIfkmBtYEFGPQgNg00SM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g40Kce4+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28F21C433C7; Sun, 24 Mar 2024 23:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322025; bh=AG23bdc6T+HcriaBH5aprj0FR+KrOH33r/hrRR9Hni4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g40Kce4+3HgKGpHHoG10idS7xmXRZ6yUenH4seQlLCVfc2BZW99sk+EHH4M9kJXo1 HOrs9q258+w8yuHGJlajfLQ/WyFsOyV2AkjYkGgwajP0RHtDfVdk/CPkqS6lqrIfZ7 SQauGPtshH/WjO9dKOsr3bS6fbHrfcg2Jv8+F+U4IBA7S5UR8HnVT1WhP+XO/aSzaJ v1iq2iHlO2il/B6fiXVPuD2L30CB8O0xcatWrOwle7jS1honLdZFkzxg6oAtXUlQ8h XVdrVRP42Qenz+YOdMwdOYJec5VcRutj6Ir7PzDfbSAIxPfMmpctMvVenT1gI5u5Yr KzNkn2qBgNcSQ== 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.1 097/451] cpufreq: mediatek-hw: Wait for CPU supplies before probing Date: Sun, 24 Mar 2024 19:06:13 -0400 Message-ID: <20240324231207.1351418-98-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 212bbca8daf32..42240a7d826da 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 @@ -296,7 +297,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