From patchwork Wed Jun 17 09:43:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Mazzucato X-Patchwork-Id: 11609501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8500090 for ; Wed, 17 Jun 2020 09:44:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A89D20CC7 for ; Wed, 17 Jun 2020 09:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725773AbgFQJoG (ORCPT ); Wed, 17 Jun 2020 05:44:06 -0400 Received: from foss.arm.com ([217.140.110.172]:54442 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbgFQJoF (ORCPT ); Wed, 17 Jun 2020 05:44:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6956431B; Wed, 17 Jun 2020 02:44:04 -0700 (PDT) Received: from ubuntu.arm.com (unknown [10.57.54.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7CE393F6CF; Wed, 17 Jun 2020 02:44:02 -0700 (PDT) From: Nicola Mazzucato To: linux-kernel@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: lukasz.luba@arm.com Subject: [PATCH 1/2] firmware: arm_scmi: Add fast_switch_possible() api Date: Wed, 17 Jun 2020 10:43:31 +0100 Message-Id: <20200617094332.8391-1-nicola.mazzucato@arm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a new fast_switch_possible interface to the existing perf_ops api to export the information of whether or not fast_switch is possible in this driver. This can be used by the CPUFreq driver and framework to choose proper mechanism for frequency change. Suggested-by: Lukasz Luba Signed-off-by: Nicola Mazzucato --- drivers/firmware/arm_scmi/perf.c | 12 ++++++++++++ include/linux/scmi_protocol.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index eadc171e254b..ef747a9bb948 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -697,6 +697,17 @@ static int scmi_dvfs_est_power_get(const struct scmi_handle *handle, u32 domain, return ret; } +static bool scmi_fast_switch_possible(const struct scmi_handle *handle, + struct device *dev) +{ + struct perf_dom_info *dom; + struct scmi_perf_info *pi = handle->perf_priv; + + dom = pi->dom_info + scmi_dev_domain_id(dev); + + return (dom->fc_info && dom->fc_info->level_set_addr); +} + static struct scmi_perf_ops perf_ops = { .limits_set = scmi_perf_limits_set, .limits_get = scmi_perf_limits_get, @@ -708,6 +719,7 @@ static struct scmi_perf_ops perf_ops = { .freq_set = scmi_dvfs_freq_set, .freq_get = scmi_dvfs_freq_get, .est_power_get = scmi_dvfs_est_power_get, + .fast_switch_possible = scmi_fast_switch_possible, }; static int scmi_perf_protocol_init(struct scmi_handle *handle) diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index ce2f5c28b2df..19e50b89117e 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -118,6 +118,8 @@ struct scmi_perf_ops { unsigned long *rate, bool poll); int (*est_power_get)(const struct scmi_handle *handle, u32 domain, unsigned long *rate, unsigned long *power); + bool (*fast_switch_possible)(const struct scmi_handle *handle, + struct device *dev); }; /** From patchwork Wed Jun 17 09:43:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Mazzucato X-Patchwork-Id: 11609505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F1B990 for ; Wed, 17 Jun 2020 09:44:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F7F020CC7 for ; Wed, 17 Jun 2020 09:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgFQJoT (ORCPT ); Wed, 17 Jun 2020 05:44:19 -0400 Received: from foss.arm.com ([217.140.110.172]:54466 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbgFQJoS (ORCPT ); Wed, 17 Jun 2020 05:44:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 37DD031B; Wed, 17 Jun 2020 02:44:18 -0700 (PDT) Received: from ubuntu.arm.com (unknown [10.57.54.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BD12C3F6CF; Wed, 17 Jun 2020 02:44:15 -0700 (PDT) From: Nicola Mazzucato To: linux-kernel@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: lukasz.luba@arm.com Subject: [PATCH 2/2] cpufreq: arm_scmi: Set fast_switch_possible conditionally Date: Wed, 17 Jun 2020 10:43:32 +0100 Message-Id: <20200617094332.8391-2-nicola.mazzucato@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200617094332.8391-1-nicola.mazzucato@arm.com> References: <20200617094332.8391-1-nicola.mazzucato@arm.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the fast_switch_possible flag is set unconditionally to true. Based on this, schedutil does not create a thread for frequency switching and would always use the fast switch path. However, if the platform does not support frequency fast switch, this may cause the governor to attempt an operation that is not supported by the platform. Fix this by correctly retrieve the fast_switch capability from the driver which knows if the platform can support this feature. Suggested-by: Lukasz Luba Signed-off-by: Nicola Mazzucato Acked-by: Viresh Kumar --- drivers/cpufreq/scmi-cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 61623e2ff149..1cf688fcb56b 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -198,7 +198,8 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = latency; - policy->fast_switch_possible = true; + policy->fast_switch_possible = + handle->perf_ops->fast_switch_possible(handle, cpu_dev); em_register_perf_domain(policy->cpus, nr_opp, &em_cb);