From patchwork Wed Jan 10 14:23:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 186915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp825390dyi; Wed, 10 Jan 2024 06:26:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCsobaVsatJEUl+TR7E47RDapjvSMgpG+1RhvYpyY2oc+qa0unf26iJ7qebrp2VWj1l4nJ X-Received: by 2002:a17:903:18f:b0:1d5:73f7:c016 with SMTP id z15-20020a170903018f00b001d573f7c016mr894919plg.109.1704896765118; Wed, 10 Jan 2024 06:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704896765; cv=none; d=google.com; s=arc-20160816; b=pxT/rU3uhYWazcCH8eUSrv2VNzE7i5g7OOsjlzHVoDHRBXRaxEydjKpTHobY6+nPmR lfDItUfe2tFfwVo0OXBnXIl1RvRowWunrYlRkOdzu2dlBvAFAhWplkUugqdz/o0pw75D hVgf6wAVZDYwp55BvcQXYSDsp93Xn4ymIOJkEfR7CaVi2eWt62NXtQufoyzHkXzO/csp +aH3bL0vr/fdroIh2pK71Pl6iYMNL0qm49g3xKiTRti+GQYTQSFmiGLtzG820zeLsFFy ZN6ENKiuX1R7fBPNBZEuU6/jraoa1uh22gTMbGN47G8zGdPwrjY+nWfAlEkgEB8oj55x YP9A== ARC-Message-Signature: i=1; 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=p2owic68I20DATGgxJ34JHR73fjNMYd+pcOW+WhXYvs=; fh=Kz22TZrlQB3XjCvYOJZJAfHgkHeRQHzAuy6TVyzWbxg=; b=GwCzzM1OLJGb0vcd5+jBT+Cmjb9NiSAKUSRBth+oleZfeBE0jGivSXHizn2d6tUp3q n0psWMmBDccRxqkjvFU3rwCk3kVilh4kGfG85BgG8mk+EStp2b0eh3Cd/A4IYKNgPLeB X/zXJlqwMElCmGX4TlYirEpW02SreJGhldhErSjy6iHV3C0NaHv64K43qsoE2oXhRy2f 6WyoC+AWk8oGkUwFrxJrQXg5LMzGsuxdTRcCKSiwVsKhO4Xig7R4sDPgrDeVk7Uvr5as eN7Pv0P6vk80uNVC/E5afsloA27u76GN/bA9bBsfmRnKyWiAq4ZDreld4ANLWLA5xVKP bmdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=xk4R8Lo4; spf=pass (google.com: domain of linux-kernel+bounces-22353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22353-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x20-20020a170902ea9400b001d4ca2fcc4asi3708713plb.291.2024.01.10.06.26.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 06:26:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22353-ouuuleilei=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=@collabora.com header.s=mail header.b=xk4R8Lo4; spf=pass (google.com: domain of linux-kernel+bounces-22353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22353-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 6EACD285CD7 for ; Wed, 10 Jan 2024 14:26:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99AB54BAAC; Wed, 10 Jan 2024 14:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="xk4R8Lo4" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 90A984A9AA; Wed, 10 Jan 2024 14:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704896724; bh=GruA9Ly7wkFPn1q/+QSDJ+FMjRv9dhzwRyz0dijp/xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xk4R8Lo4pdDJpjNYh1MtD+Fi9asVHGwd6N8WSTyS4n1YXL+rfh8hRstEzqczRMEG8 fU8Uk++gBqW0TPdT57E8MF8Uw5MoBResvXMQMhVzU0TF+uC+3A2ELhP1Dg31GCT6Ht ZDYu469Es+04GxBmXOy7hD/7N03Qu5GnsMv01VeL6xSkqUL+wqBafX4F42UexZ5dSo W8eoUnXV+e21oX3chkWAEQcPwE9yu3Sa9Jam4fArXt4w0YV4TwWmm0aaZy7+yGPUxi ebfNbZE8HAaYqUh1iG4dOowf7YC/SKdSkZ7PUuJ0lixRBfWIu2Tc/XVQ8Ag3HxTdJj DFJKMiAhXOZHw== Received: from localhost.localdomain (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 6EA3C378045F; Wed, 10 Jan 2024 14:25:20 +0000 (UTC) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Viresh Kumar , "Rafael J . Wysocki" , AngeloGioacchino Del Regno , Matthias Brugger Cc: kernel@collabora.com, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , "Hector.Yuan" , Liam Girdwood , Mark Brown , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v2 2/2] cpufreq: mediatek-hw: Wait for CPU supplies before probing Date: Wed, 10 Jan 2024 11:23:02 -0300 Message-ID: <20240110142305.755367-3-nfraprado@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240110142305.755367-1-nfraprado@collabora.com> References: <20240110142305.755367-1-nfraprado@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787713830325534307 X-GMAIL-MSGID: 1787713830325534307 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 --- 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 #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)