From patchwork Tue Nov 14 10:07:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 164803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1758497vqg; Tue, 14 Nov 2023 02:08:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IERZjPdt8RkG3UjaFt06rpasH42L+NJvPS1E4mkiSb5NR0CRX5MLlUYFTGOHChiND3K2/sA X-Received: by 2002:a05:6a20:1b26:b0:151:35ad:f331 with SMTP id ch38-20020a056a201b2600b0015135adf331mr2284318pzb.14.1699956504311; Tue, 14 Nov 2023 02:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699956504; cv=none; d=google.com; s=arc-20160816; b=rnpF3iQ7XJHUUBYFwKdn7uVc0VDmHvkgXYTQfcg0deeWsBRy7UP5GFUE3MekOUisjS nzXPRRRY2A4NVkCctV7L/n15I5tuiSnSjWPAGeMdIFOUc6syKI5NbGZ0wn3b6DCeSTDL n3dkjRS3Nd+/UvVTBwAU24KtN1HfWc9cdIrViMqtlvTwyLEFYZcbPWV0z1d0FS1Nxel+ WQdD9rT33g2hmgyyjAhOnxcEHZFLR34aYyth28fvMJ9e9k4l1/gQi8M4CVDnSB5oIFHA 0oM3MUnJyiEgkmB9sqowGX9Ry7X40Vww+jC1uDbD/UDT1k9R6d+u4sTkUcXu2x0ZCRv6 lsBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=yHgv5IBYwVg9IetpTlbJF+51/fhwpJWv33OEEqG+teg=; fh=mH/O2WdYjyW7y4Q4GqtRUwu0yNzAy5Jw/EWynSIFpfo=; b=butXd7/wdwUfcuh5qKUba6JUYQHPl2h+aeo8GFrI19u4GYkY0Z4qDSaW5/kZHIGOFN HJkStVrCg+vU2NAMJAaCU3lJHqNKg5X5bePwnUjgP2IT4Awm1iiVqtkquSF9AnvSVlWT 2tI/lBEKkRZp5YBSwlkMQEtQpKeMF273Zb8Ipgdrm6QT9Q2g2fumoZ9ihPIK6abp5cpp 8kdhUCpQGNDaw+a6QdoG/yEaVzJ69nydRkFmBM60JF1Kkbr8LE3H1XUT/1jvKRInXYFL K/Y+w38cciZND38rmwojJ9igjGLbUEXy9DF3PSfmpfxphXd/RUA3gUl0cjyOHfNeuI0f wcjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=eKsnWCnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y123-20020a62ce81000000b0068e29a05fa4si7292918pfg.326.2023.11.14.02.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 02:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=eKsnWCnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 95492801BFE6; Tue, 14 Nov 2023 02:08:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232482AbjKNKIQ (ORCPT + 30 others); Tue, 14 Nov 2023 05:08:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230411AbjKNKIO (ORCPT ); Tue, 14 Nov 2023 05:08:14 -0500 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1D0E19E; Tue, 14 Nov 2023 02:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=yHgv5IBYwVg9IetpTlbJF+51/fhwpJWv33OEEqG+teg=; b=eKsnWCnc1ymT2nYgpQ4N5mP2Ts vzX2Vs5Jao1r1uvsVkAO0srNqEyTGx3hAj3YK2bz2DWTzkDgEFjXjM/D+YdTt6BpzDBhbuXfChCzB eBy9Ukx3B13rnp8It6u8JC/wgY733XetB+gFrpHGnoBeaChuwn2dvoqkaaz7UsurzfgrltyiN3BeF U1NT0u8+DoihyjbDJVtVW2kZXKuMvCvPws5CxnBBj3os+2oJwBOblL31S9N4e2UDv4GkAOMKlo5FW IpwlpwJi5iy2cDohjP8NwsbPmZaL+tY+hTsE+ynht5S8fuzswxXEf9orS3jwGV1ltfRtNwSAcJwdL F1H+Z9fw==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1r2qL0-0050az-0B; Tue, 14 Nov 2023 11:08:06 +0100 From: Stephan Gerhold Date: Tue, 14 Nov 2023 11:07:43 +0100 Subject: [PATCH v3 1/3] cpufreq: qcom-nvmem: Enable virtual power domain devices MIME-Version: 1.0 Message-Id: <20231114-msm8909-cpufreq-v3-1-926097a6e5c1@kernkonzept.com> References: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> In-Reply-To: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> To: Viresh Kumar , Ulf Hansson Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Ilia Lin , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Stephan Gerhold , Stephan Gerhold , stable@vger.kernel.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 14 Nov 2023 02:08:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782533591209570550 X-GMAIL-MSGID: 1782533591209570550 The genpd core caches performance state votes from devices that are runtime suspended as of commit 3c5a272202c2 ("PM: domains: Improve runtime PM performance state handling"). They get applied once the device becomes active again. To attach the power domains needed by qcom-cpufreq-nvmem the OPP core calls genpd_dev_pm_attach_by_id(). This results in "virtual" dummy devices that use runtime PM only to control the enable and performance state for the attached power domain. However, at the moment nothing ever resumes the virtual devices created for qcom-cpufreq-nvmem. They remain permanently runtime suspended. This means that performance state votes made during cpufreq scaling get always cached and never applied to the hardware. Fix this by enabling the devices after attaching them. Without this fix performance states votes are silently ignored, and the CPU/CPR voltage is never adjusted. This has been broken since 5.14 but for some reason no one noticed this on QCS404 so far. Cc: stable@vger.kernel.org Fixes: 1cb8339ca225 ("cpufreq: qcom: Add support for qcs404 on nvmem driver") Signed-off-by: Stephan Gerhold Reviewed-by: Ulf Hansson --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 46 +++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index 6355a39418c5..d239a45ed497 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ struct qcom_cpufreq_match_data { struct qcom_cpufreq_drv_cpu { int opp_token; + struct device **virt_devs; }; struct qcom_cpufreq_drv { @@ -424,6 +426,18 @@ static const struct qcom_cpufreq_match_data match_data_ipq8074 = { .get_version = qcom_cpufreq_ipq8074_name_version, }; +static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) +{ + const char * const *name = drv->data->genpd_names; + int i; + + if (!drv->cpus[cpu].virt_devs) + return; + + for (i = 0; *name; i++, name++) + pm_runtime_put(drv->cpus[cpu].virt_devs[i]); +} + static int qcom_cpufreq_probe(struct platform_device *pdev) { struct qcom_cpufreq_drv *drv; @@ -478,6 +492,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) of_node_put(np); for_each_possible_cpu(cpu) { + struct device **virt_devs = NULL; struct dev_pm_opp_config config = { .supported_hw = NULL, }; @@ -498,7 +513,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) if (drv->data->genpd_names) { config.genpd_names = drv->data->genpd_names; - config.virt_devs = NULL; + config.virt_devs = &virt_devs; } if (config.supported_hw || config.genpd_names) { @@ -509,6 +524,27 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) goto free_opp; } } + + if (virt_devs) { + const char * const *name = config.genpd_names; + int i, j; + + for (i = 0; *name; i++, name++) { + ret = pm_runtime_resume_and_get(virt_devs[i]); + if (ret) { + dev_err(cpu_dev, "failed to resume %s: %d\n", + *name, ret); + + /* Rollback previous PM runtime calls */ + name = config.genpd_names; + for (j = 0; *name && j < i; j++, name++) + pm_runtime_put(virt_devs[j]); + + goto free_opp; + } + } + drv->cpus[cpu].virt_devs = virt_devs; + } } cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, @@ -522,8 +558,10 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) dev_err(cpu_dev, "Failed to register platform device\n"); free_opp: - for_each_possible_cpu(cpu) + for_each_possible_cpu(cpu) { + qcom_cpufreq_put_virt_devs(drv, cpu); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); + } return ret; } @@ -534,8 +572,10 @@ static void qcom_cpufreq_remove(struct platform_device *pdev) platform_device_unregister(cpufreq_dt_pdev); - for_each_possible_cpu(cpu) + for_each_possible_cpu(cpu) { + qcom_cpufreq_put_virt_devs(drv, cpu); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); + } } static struct platform_driver qcom_cpufreq_driver = { From patchwork Tue Nov 14 10:07:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 164804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1758527vqg; Tue, 14 Nov 2023 02:08:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXsFnJTTKqX072NHLYNjs97nnrAETIVH059rNHARM30RNR7HrYOKqVXTfstS965Yi0gaDN X-Received: by 2002:a05:6830:7192:b0:6ce:2733:f71b with SMTP id el18-20020a056830719200b006ce2733f71bmr2022851otb.26.1699956508333; Tue, 14 Nov 2023 02:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699956508; cv=none; d=google.com; s=arc-20160816; b=bARbXfceBSKoxFBu3HqIpyJfkERkeFDQYF1uJkLAl1Sv03QuJi8nDTpcRIVDusG6YH BMc7Zz9090UmUvMmMaVx6l20QyNK/ja1vnUTZGf9F5Lk89GdFlwMTscOwt9BL9kUunqa PFDiWp17fHvEr9XmezBAg6qoDvun1T/7YsYu/51Q0HNKmdT45iuQJTV4wq95A6uFNH/B kVqoVK5NcoprfpCuQQ2xLWPlfUd+cwbV3cD+PSeLWsgBAnL7SH64NlrcvDzzJgraE4ha tOVP13/JZJrQwrVyVIki4C1+OcldmZX1ocEEw8wJz1nYbKkA5iouC7gRpUS1j1fn0zK2 8hDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=U1jqULllO9yyumvw2SGWYMHOTDF/1W4JaEKNAJ5zL9g=; fh=baZlWuGVVef3WThMpLPuu/B8EmVlLN4ljFIX27Lw9Ds=; b=gV+R5IRW3Fu9gzvF6+e3vFYJEbd3YXNNvEO4ZfM45EdkB29uBITfv+AywK7cTo5ykm WGt3W87CS6VkSXJPl60k4+aW1I6fbbkz1yYPpUNPqd6Ht6fiVRYPYFfyhZyhuUuBLuzQ aPiUF2hdF0JqSQy6fWKHzwluz/54yP732RZVSrtzMEYSD5hf+z52P48XtJJClofOBlkW aXNax7daBNX6+aHhP60uQeDtXL0W5cN3lssmY3r6sShzFJzizwMcttYxWxm4rOM27Ll2 86Nm7VI+YujhFm4mxgQYepvcy/eBqu9cPwJ/iUIr2/hgiE4M242JsUBmgzlUnDFW4mTC L1jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=UxxEL2jH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b005aa589ef664si6187955pgb.557.2023.11.14.02.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 02:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=UxxEL2jH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7B68E801B9E6; Tue, 14 Nov 2023 02:08:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232570AbjKNKIT (ORCPT + 30 others); Tue, 14 Nov 2023 05:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbjKNKIP (ORCPT ); Tue, 14 Nov 2023 05:08:15 -0500 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02565191; Tue, 14 Nov 2023 02:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=U1jqULllO9yyumvw2SGWYMHOTDF/1W4JaEKNAJ5zL9g=; b=UxxEL2jHHreKo90GBCCSwoWIWo BK0IvKT7BIo8AvjH9p+jhGpnag+bgSLKbojRzqF++uxhYAp66MHtkhCBqCFHJAoR0jDypw2tC/j8z OtPyf5iendwiO82EXogfOWJMVcK+fRsVA+ZPNGw3nit6MreWLBtelCw1aUIGKdqlkAQTSoFHHg3Dl 48lLbp5ntWDSzBdEPo0ufpzbKVwRQv9dlSzBIijDnqG/RALi6Cs4jT4V/89/uNEc81eq9UxzciBIo uHzm0n4sMaYjfLW4zYbvuNem0tldizO36ls4ytVh0Gz3uSXlaNc/5gm+WsMcOIyByYlf29JH1MqGi 3wA1ytrg==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1r2qL2-0050az-0X; Tue, 14 Nov 2023 11:08:08 +0100 From: Stephan Gerhold Date: Tue, 14 Nov 2023 11:07:44 +0100 Subject: [PATCH v3 2/3] cpufreq: qcom-nvmem: Preserve PM domain votes in system suspend MIME-Version: 1.0 Message-Id: <20231114-msm8909-cpufreq-v3-2-926097a6e5c1@kernkonzept.com> References: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> In-Reply-To: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> To: Viresh Kumar , Ulf Hansson Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Ilia Lin , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Stephan Gerhold , Stephan Gerhold X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 14 Nov 2023 02:08:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782533595708392820 X-GMAIL-MSGID: 1782533595708392820 From the Linux point of view, the power domains used by the CPU must stay always-on. This is because we still need the CPU to keep running until the last instruction, which will typically be a firmware call that shuts down the CPU cleanly. At the moment the power domain votes (enable + performance state) are dropped during system suspend, which means the CPU could potentially malfunction while entering suspend. We need to distinguish between two different setups used with qcom-cpufreq-nvmem: 1. CPR power domain: The backing regulator used by CPR should stay always-on in Linux; it is typically disabled automatically by hardware when the CPU enters a deep idle state. However, we should pause the CPR state machine during system suspend. 2. RPMPD: The power domains used by the CPU should stay always-on in Linux (also across system suspend). The CPU typically only uses the *_AO ("active-only") variants of the power domains in RPMPD. For those, the RPM firmware will automatically drop the votes internally when the CPU enters a deep idle state. Make this work correctly by calling device_set_awake_path() on the virtual genpd devices, so that the votes are maintained across system suspend. The power domain drivers need to set GENPD_FLAG_ACTIVE_WAKEUP to opt into staying on during system suspend. For now we only set this for the RPMPD case. For CPR, not setting it will ensure the state machine is still paused during system suspend, while the backing regulator will stay on with "regulator-always-on". Signed-off-by: Stephan Gerhold Reviewed-by: Ulf Hansson --- This patch can be merged independently from the pmdomain one for RPMPD. Both are needed to actually preserve the votes during system suspend but there is no compile-time dependency. --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index d239a45ed497..ea05d9d67490 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -426,6 +427,18 @@ static const struct qcom_cpufreq_match_data match_data_ipq8074 = { .get_version = qcom_cpufreq_ipq8074_name_version, }; +static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) +{ + const char * const *name = drv->data->genpd_names; + int i; + + if (!drv->cpus[cpu].virt_devs) + return; + + for (i = 0; *name; i++, name++) + device_set_awake_path(drv->cpus[cpu].virt_devs[i]); +} + static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsigned int cpu) { const char * const *name = drv->data->genpd_names; @@ -578,11 +591,25 @@ static void qcom_cpufreq_remove(struct platform_device *pdev) } } +static int qcom_cpufreq_suspend(struct device *dev) +{ + struct qcom_cpufreq_drv *drv = dev_get_drvdata(dev); + unsigned int cpu; + + for_each_possible_cpu(cpu) + qcom_cpufreq_suspend_virt_devs(drv, cpu); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(qcom_cpufreq_pm_ops, qcom_cpufreq_suspend, NULL); + static struct platform_driver qcom_cpufreq_driver = { .probe = qcom_cpufreq_probe, .remove_new = qcom_cpufreq_remove, .driver = { .name = "qcom-cpufreq-nvmem", + .pm = pm_sleep_ptr(&qcom_cpufreq_pm_ops), }, }; From patchwork Tue Nov 14 10:07:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 164805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1758671vqg; Tue, 14 Nov 2023 02:08:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJk6UuLX+acnfMyy0SrSPhLIInaOZDsX6DsW0sbHKk1EyID4+3HDeZhM6VH3xEpBrFTCsh X-Received: by 2002:a05:6a21:7889:b0:187:15e2:fe02 with SMTP id bf9-20020a056a21788900b0018715e2fe02mr1042350pzc.13.1699956528962; Tue, 14 Nov 2023 02:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699956528; cv=none; d=google.com; s=arc-20160816; b=IBwCcXOc/aSIjGERc05VPWv55EDY/phT1UnYqciwS7FO9m8tptBxpk+UfOMRlLtcpf Ciro29h6P+aUeN+dD+wNyV6BEjikIhlqzqCVTkSywcqsBNr5Varai1yhqNqx4FTjLxlV DAGNqy8JsDM3it+ZO/TfX3FIuj5sBmnDbdT9pFEQkhY0nx3as1T2IyruoaIk7vCdwpi3 CIL9EUnUgjt5MSbyXCwYUZekRGKgcSNMy/AE4NyTcMYVWHnt+Wm58GQ1FCa+X2qkZ2VA xgu66scTvp7hWDLGWQ/UoB1ueWENcmETDLPipjD4+WcB2soOJAT693QaceWyHjCNvG7R JD8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=nMk7zTRFOdK2rz7OlbU43But/2vJEYeFTpihGg8XE7g=; fh=baZlWuGVVef3WThMpLPuu/B8EmVlLN4ljFIX27Lw9Ds=; b=gJcN/uDEeYro8TYn9A/AxP/w66aGyHSeMteNdHBxSEUzwEVBhcge1BEqZL0Hu5t4Ri zwprLx1rli88QcFW+z9MEJ76fBN8nI8lH640Jj4V85DGyTVyqE7I8cakEjpAb6dkqRvn gX0RmKHHJVfRixZsyhwHQgAkrDACSt32TbwzAdyzDR3njSWQVnABa8HjWPQ8TePOn/or /wRn80XrUTBNm/Wxc6lHI1Yj0yPqiYiGOHt2TXgbKtsNaYo1RoJ9oj4du66HQ2m9Mnvs WjyEXnxRBel9tNOsxVkC6MtXb56D5eA/kfyIbJR0u6ziVWMN0GTZdalOFoNHzefwj53x Apnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=SiabwveP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ja22-20020a170902efd600b001ca152d038dsi7357365plb.281.2023.11.14.02.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 02:08:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=SiabwveP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1554280B31DF; Tue, 14 Nov 2023 02:08:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232629AbjKNKI0 (ORCPT + 30 others); Tue, 14 Nov 2023 05:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232528AbjKNKIR (ORCPT ); Tue, 14 Nov 2023 05:08:17 -0500 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02E7119F; Tue, 14 Nov 2023 02:08:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=nMk7zTRFOdK2rz7OlbU43But/2vJEYeFTpihGg8XE7g=; b=SiabwvePpKfwYhWDzfZmkNiNNQ 3ZaIv65InR4KA6aJNFIaF9JgNoRa2C/kuMmOHZUbq1sdbczJFTJskPIpIvx8pNDZst2i6oDDgL8Ya fIXA/8Agl+Ru22hY67BJJ1XH6tZzdRpDfGkYYWEAEUwc0yaRFjfq8mLKEKqywU5DDV4e1k+VdYB+s gR+UdQe4ru9fbqlTD8gbky86aoKPdqW5x9FJ2LaOM0QzM64p9xTewGlcIuC89+4XfRfDRRXUjhQcz mWDy349lfOrZdio0Pxp5r4ObvXJAJJD+pUUbus17HiIKt+97xAfHNLa6U9Lr6K/mDvGj6N2toClDj Ul0bMbBQ==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1r2qL4-0050az-0q; Tue, 14 Nov 2023 11:08:10 +0100 From: Stephan Gerhold Date: Tue, 14 Nov 2023 11:07:45 +0100 Subject: [PATCH v3 3/3] pmdomain: qcom: rpmpd: Set GENPD_FLAG_ACTIVE_WAKEUP MIME-Version: 1.0 Message-Id: <20231114-msm8909-cpufreq-v3-3-926097a6e5c1@kernkonzept.com> References: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> In-Reply-To: <20231114-msm8909-cpufreq-v3-0-926097a6e5c1@kernkonzept.com> To: Viresh Kumar , Ulf Hansson Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Ilia Lin , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Stephan Gerhold , Stephan Gerhold X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 14 Nov 2023 02:08:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782533617158029365 X-GMAIL-MSGID: 1782533617158029365 Set GENPD_FLAG_ACTIVE_WAKEUP for all RPM power domains so that power domains necessary for wakeup/"awake path" devices are kept on across suspend. This is needed for example for the *_AO ("active-only") variants of the RPMPDs used by the CPU. Those should maintain their votes also across system suspend to ensure the CPU can keep running for the whole suspend process (ending in a firmware call). When the RPM firmware detects that the CPUs are in a deep idle state it will drop those votes automatically. Signed-off-by: Stephan Gerhold Reviewed-by: Ulf Hansson --- drivers/pmdomain/qcom/rpmpd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pmdomain/qcom/rpmpd.c b/drivers/pmdomain/qcom/rpmpd.c index 07590a3ef19c..7796d65f96e8 100644 --- a/drivers/pmdomain/qcom/rpmpd.c +++ b/drivers/pmdomain/qcom/rpmpd.c @@ -1044,6 +1044,7 @@ static int rpmpd_probe(struct platform_device *pdev) rpmpds[i]->pd.power_off = rpmpd_power_off; rpmpds[i]->pd.power_on = rpmpd_power_on; rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.flags = GENPD_FLAG_ACTIVE_WAKEUP; pm_genpd_init(&rpmpds[i]->pd, NULL, true); data->domains[i] = &rpmpds[i]->pd;