Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2363437lqp; Sun, 24 Mar 2024 15:54:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW61LxdqyFnGlMq6seMD8M69h9dHG2bRNZ8NllMXCNzqKJJeIAwCpskaEldN3GLwFmwLroagC01YN0eU4s575xwSB53rKLre333KbWCHQ== X-Google-Smtp-Source: AGHT+IF8peiPkgpSfaispEk45CeSUB0bIQ0E9muJHfT1z8jHX+qkxKiaCGEDWeaB44W5A6dJbn5E X-Received: by 2002:a05:6a21:339a:b0:1a3:aaea:a45b with SMTP id yy26-20020a056a21339a00b001a3aaeaa45bmr7498381pzb.39.1711320858374; Sun, 24 Mar 2024 15:54:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320858; cv=pass; d=google.com; s=arc-20160816; b=fp91NsANJlwpaCIeuTwlIaZ8TIa03Hx8sgplSnd6kEGEWAw4xy4vUJJxeUeuTHGzsm s3TJTJSbX+IiX/QgldCM/hjHy0MeWaNAkWao5LIs8eEdFEvFSHQghXsEJv/I3va22D9w fYmBFXzVxcblw4HTUIR7Aipr9dVPd7n7nqIJ05YkwEiLxijg/af5M2WGToEcnXd0PbQ+ EeE4Fxfnad1hlMG4n7ha61DBvIXf2KOslnLjMwUuyOg7jUNf2PAeq9ulvmTT8+CCat37 OkHRkgTGGQ1rHHCjW1ThWpphIgDm2YJXXLhWw4aK4YgLMBE6K6wG5lWWUSCZpAP6ftiG lT/Q== 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=tuPDJ+dmnx+f7vSGlaCVIZxzL6BIsVlYEcg94bWApt0=; fh=1/CfgxdfSr4xUhMCp+L7s821ekbyUVHY/Z/bh+YNqH8=; b=WzMI3PFIUzKMSRZosh0tSn5RPBuiW/1eLsu6BoDAhUmWrx20DOFWhzjERRpEU+njLR EunBiRKbugad9yt/MFMGK7fVIrCt1rxM+nc5hF6QT8TJroPouELbWoQgOmvOrgbUdtYk HxdMfcI2GPPEk07wRNcwmhhevr+jenhoWkwLO0GdmxNbTy5tewVJaDRbjJYtzckutaFE snJRTsLFiAG1fxvbRQJwBmeSVvcTDSatjHcu5g2CqR4jau9Bli/qjCbHR/nNjkuD+PRd OQz9czXxlFALclTAXc8YH/1zKzprdoYN/7hqO2WRWArTmMl5OjiDcB9Ed2EllmeF+DC1 wbdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Py55qTDL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112967-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k69-20020a636f48000000b005f057f3a771si1604948pgc.591.2024.03.24.15.54.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:54:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Py55qTDL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112967-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112967-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 000C8281418 for ; Sun, 24 Mar 2024 22:54:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B10D129A60; Sun, 24 Mar 2024 22:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Py55qTDL" 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 202AD1292E3; Sun, 24 Mar 2024 22:36:18 +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=1711319779; cv=none; b=MKALo1B9EkEK4IKzCLqYnuYJ+RYo3hrYyqaodLFFBn7+HCoTa+NwRn3C2bSfUfcx3aNKBoi6oCopp3hAKuYt2ogvo/+ujx98ehphTAHRb+5t74CX0LhuCz4qMb4T49UQB/45c45O6vEvFg9G6EzeY1wjZT2n9ugCvFu4yzPuyGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319779; c=relaxed/simple; bh=yo2Z2RP8nH+NEKT0SUBmtftPM/25colUC9zO2Yovi1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p0nGN5B5LpfUWCOx4jX5gowyzYWEiaWdLCDLkFV81buoKThaAYP7WVDCuAmzE0+TRh/tdzUSRcYS840z1hinzYmGVlPsYz1PtUiY3c5umpVZtVHp6F0qfEehqoMXRn1FdBlhUXKngi3EJeoWcDrD/qTVHLH5Z9N/9yFwxdETKh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Py55qTDL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9A25C43399; Sun, 24 Mar 2024 22:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319778; bh=yo2Z2RP8nH+NEKT0SUBmtftPM/25colUC9zO2Yovi1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Py55qTDLnp4Cka0kJJBwaLJmzy59kAZAxgjV8nRDnzbKPntaqRHDHxPIHtNKpag92 4n6VSgb9L+PzB/a0se0PQWw6PGshpf6670O0NVuS7eL/Os7bESzHNNXLOZvGRact1Q LlmDD4BC2Mep9cTfyLAL0zJMIuXCP0PTMxaHTRQaO9amwCkPWuRFNxYIcZBEaptzMH LXKwVEVu2m0x4R8PxiUhyNN0qGdbp8heSsWMlMISQYYuPzzfNz5kcvJZDN9TdYtTd/ IN5lzMc2k1k7SUPMnO6yzLb7YE4CVFfK9gGULUccvZ2yTwJCWJRm7LB0f+sP+hV4hp JvfnIi52xfuUA== 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.8 080/715] cpufreq: mediatek-hw: Wait for CPU supplies before probing Date: Sun, 24 Mar 2024 18:24:19 -0400 Message-ID: <20240324223455.1342824-81-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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