From patchwork Mon Feb 15 07:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Mazzucato X-Patchwork-Id: 383137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC206C433DB for ; Mon, 15 Feb 2021 07:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF09464E6D for ; Mon, 15 Feb 2021 07:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbhBOHuI (ORCPT ); Mon, 15 Feb 2021 02:50:08 -0500 Received: from foss.arm.com ([217.140.110.172]:60432 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhBOHtz (ORCPT ); Mon, 15 Feb 2021 02:49:55 -0500 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 A9850113E; Sun, 14 Feb 2021 23:49:09 -0800 (PST) Received: from ubuntu.arm.com (unknown [10.57.16.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D2A0B3F40C; Sun, 14 Feb 2021 23:49:07 -0800 (PST) From: Nicola Mazzucato To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, vireshk@kernel.org, cristian.marussi@arm.com Cc: morten.rasmussen@arm.com, chris.redpath@arm.com, ionela.voinescu@arm.com, nicola.mazzucato@arm.com Subject: [PATCH v7 1/3] scmi-cpufreq: Remove deferred probe Date: Mon, 15 Feb 2021 07:51:37 +0000 Message-Id: <20210215075139.30772-2-nicola.mazzucato@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210215075139.30772-1-nicola.mazzucato@arm.com> References: <20210215075139.30772-1-nicola.mazzucato@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The current implementation of the scmi_cpufreq_init() function returns -EPROBE_DEFER when the OPP table is not populated. In practice the cpufreq core cannot handle this error code. Therefore, fix the return value and clarify the error message. Reviewed-by: Ionela Voinescu Signed-off-by: Nicola Mazzucato --- drivers/cpufreq/scmi-cpufreq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 491a0a24fb1e..34bf2eb8d465 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -155,9 +155,11 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) nr_opp = dev_pm_opp_get_opp_count(cpu_dev); if (nr_opp <= 0) { - dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n"); - ret = -EPROBE_DEFER; - goto out_free_opp; + dev_err(cpu_dev, "%s: No OPPs for this device: %d\n", + __func__, ret); + + ret = -ENODEV; + goto out_free_priv; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); From patchwork Mon Feb 15 07:51:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Mazzucato X-Patchwork-Id: 383136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2185AC433E9 for ; Mon, 15 Feb 2021 07:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D922C64E71 for ; Mon, 15 Feb 2021 07:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbhBOHuK (ORCPT ); Mon, 15 Feb 2021 02:50:10 -0500 Received: from foss.arm.com ([217.140.110.172]:60442 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbhBOHt6 (ORCPT ); Mon, 15 Feb 2021 02:49:58 -0500 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 C03C711D4; Sun, 14 Feb 2021 23:49:12 -0800 (PST) Received: from ubuntu.arm.com (unknown [10.57.16.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F0ACA3F40C; Sun, 14 Feb 2021 23:49:10 -0800 (PST) From: Nicola Mazzucato To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, vireshk@kernel.org, cristian.marussi@arm.com Cc: morten.rasmussen@arm.com, chris.redpath@arm.com, ionela.voinescu@arm.com, nicola.mazzucato@arm.com Subject: [PATCH v7 2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM Date: Mon, 15 Feb 2021 07:51:38 +0000 Message-Id: <20210215075139.30772-3-nicola.mazzucato@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210215075139.30772-1-nicola.mazzucato@arm.com> References: <20210215075139.30772-1-nicola.mazzucato@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org By design, SCMI performance domains define the granularity of performance controls, they do not describe any underlying hardware dependencies (although they may match in many cases). It is therefore possible to have some platforms where hardware may have the ability to control CPU performance at different granularity and choose to describe fine-grained performance control through SCMI. In such situations, the energy model would be provided with inaccurate information based on controls, while it still needs to know the performance boundaries. To restore correct functionality, retrieve information of CPUs under the same performance domain from operating-points-v2 in DT, and pass it on to EM. Reviewed-by: Ionela Voinescu Tested-by: Ionela Voinescu Signed-off-by: Nicola Mazzucato --- drivers/cpufreq/scmi-cpufreq.c | 72 ++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 34bf2eb8d465..fc9866511f01 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -126,6 +126,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) struct scmi_data *priv; struct cpufreq_frequency_table *freq_table; struct em_data_callback em_cb = EM_DATA_CB(scmi_get_cpu_power); + cpumask_var_t opp_shared_cpus; bool power_scale_mw; cpu_dev = get_cpu_device(policy->cpu); @@ -134,32 +135,62 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) return -ENODEV; } - ret = handle->perf_ops->device_opps_add(handle, cpu_dev); - if (ret) { - dev_warn(cpu_dev, "failed to add opps to the device\n"); - return ret; - } + if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL)) + ret = -ENOMEM; + /* Obtain CPUs that share SCMI performance controls */ ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus); if (ret) { dev_warn(cpu_dev, "failed to get sharing cpumask\n"); - return ret; + goto out_free_cpumask; } - ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); - if (ret) { - dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", - __func__, ret); - return ret; + /* + * Obtain CPUs that share performance levels. + * The OPP 'sharing cpus' info may come from DT through an empty opp + * table and opp-shared. + */ + ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, opp_shared_cpus); + if (ret || !cpumask_weight(opp_shared_cpus)) { + /* + * Either opp-table is not set or no opp-shared was found. + * Use the CPU mask from SCMI to designate CPUs sharing an OPP + * table. + */ + cpumask_copy(opp_shared_cpus, policy->cpus); } + /* + * Add OPPs only on those CPUs for which we haven't already done so. + */ nr_opp = dev_pm_opp_get_opp_count(cpu_dev); if (nr_opp <= 0) { - dev_err(cpu_dev, "%s: No OPPs for this device: %d\n", - __func__, ret); - - ret = -ENODEV; - goto out_free_priv; + ret = handle->perf_ops->device_opps_add(handle, cpu_dev); + if (ret) { + dev_warn(cpu_dev, "failed to add opps to the device\n"); + goto out_free_cpumask; + } + + nr_opp = dev_pm_opp_get_opp_count(cpu_dev); + if (nr_opp <= 0) { + dev_err(cpu_dev, "%s: No OPPs for this device: %d\n", + __func__, ret); + + ret = -ENODEV; + goto out_free_opp; + } + + ret = dev_pm_opp_set_sharing_cpus(cpu_dev, opp_shared_cpus); + if (ret) { + dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", + __func__, ret); + + goto out_free_opp; + } + + power_scale_mw = handle->perf_ops->power_scale_mw_get(handle); + em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, + opp_shared_cpus, power_scale_mw); } priv = kzalloc(sizeof(*priv), GFP_KERNEL); @@ -192,17 +223,18 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) policy->fast_switch_possible = handle->perf_ops->fast_switch_possible(handle, cpu_dev); - power_scale_mw = handle->perf_ops->power_scale_mw_get(handle); - em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus, - power_scale_mw); - + free_cpumask_var(opp_shared_cpus); return 0; out_free_priv: kfree(priv); + out_free_opp: dev_pm_opp_remove_all_dynamic(cpu_dev); +out_free_cpumask: + free_cpumask_var(opp_shared_cpus); + return ret; } From patchwork Mon Feb 15 07:51:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Mazzucato X-Patchwork-Id: 382888 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp874543jao; Sun, 14 Feb 2021 23:50:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3dqn7JkYGFCSW6w/CUSU5nsZ00x1gNMW7ZeLa/4N8DRGHe8xyYrum0qS52qa2E+jT/Shb X-Received: by 2002:a05:6402:125a:: with SMTP id l26mr14805196edw.188.1613375451628; Sun, 14 Feb 2021 23:50:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613375451; cv=none; d=google.com; s=arc-20160816; b=k6A3GL1BpjHaPeD9mNHvSNtlztFxfZgp1uouY3hv3yCDGwX8V3aVrVCHQlgJxajFvd uyOqoRu9FoGdS1521HY1oDpQ7zQLasIlLYDs4r1Qq8VH17rjvvOBjAD5hcvTrPYmiPeD 1W47LBEEo45i1gvi94ZYVfqB32F1xnQTHDZj8bPI3Q/UwwzGruh2vSZrmhvhXxWogykA fL3eaMj+A6khkUHLOj9jG/znWvwa5PaDNsumlYftDNH1DjqJ8hAqnqfw4ptexL/qelrS bzNUZHSaj+YA5bbwIApH/fi8GKpUp7TWtdEHWVV4MQ3y+B4buZj7PSEyirvTwLncHjun 0ZnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=G1E9/g7KRMrz7FSSYzua2K4K+5deV5zPbq3JNZlyZT8=; b=Ch9/Zb3Nhzbygxvc/2ctUKBUe+WUFG6G5sM/05gayiFOwndcrqslELXxjmNgPUA/BJ K2c8kg9nhNDCH3+WWiobRmmPY62v/UtQI+rNV4W6YUV3GOjwHK22Ap09tS6J+iFiE6bI CLW5Ot4gqmz7o3w33RXSBN22CFusxvW3tV3UQ+SbOEFI7up3uzOuZG6vWKiVDgsic8gc +NiFABnNvwi3CZJB28c6as/w5AZuMtA84sGdPQLn8xi/mNH5S98C74Ig++KNqTVT0mb4 kkGmCoUztbv21J/D9CQRngeMyaxW8TBk9y4PGYr1EoQmEXPUboef1NiYBuU1sIGLWrQE /mqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si6294951ejr.489.2021.02.14.23.50.51; Sun, 14 Feb 2021 23:50:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbhBOHuL (ORCPT + 7 others); Mon, 15 Feb 2021 02:50:11 -0500 Received: from foss.arm.com ([217.140.110.172]:60450 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbhBOHuB (ORCPT ); Mon, 15 Feb 2021 02:50:01 -0500 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 CEE1B139F; Sun, 14 Feb 2021 23:49:15 -0800 (PST) Received: from ubuntu.arm.com (unknown [10.57.16.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0249C3F40C; Sun, 14 Feb 2021 23:49:13 -0800 (PST) From: Nicola Mazzucato To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, vireshk@kernel.org, cristian.marussi@arm.com Cc: morten.rasmussen@arm.com, chris.redpath@arm.com, ionela.voinescu@arm.com, nicola.mazzucato@arm.com Subject: [PATCH v7 3/3] cpufreq: blacklist Arm Vexpress platforms in cpufreq-dt-platdev Date: Mon, 15 Feb 2021 07:51:39 +0000 Message-Id: <20210215075139.30772-4-nicola.mazzucato@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210215075139.30772-1-nicola.mazzucato@arm.com> References: <20210215075139.30772-1-nicola.mazzucato@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Sudeep Holla Add "arm,vexpress" to cpufreq-dt-platdev blacklist since the actual scaling is handled by the firmware cpufreq drivers(scpi, scmi and vexpress-spc). Signed-off-by: Sudeep Holla --- drivers/cpufreq/cpufreq-dt-platdev.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.27.0 diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index bd2db0188cbb..91e6a0c10dbf 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -103,6 +103,8 @@ static const struct of_device_id whitelist[] __initconst = { static const struct of_device_id blacklist[] __initconst = { { .compatible = "allwinner,sun50i-h6", }, + { .compatible = "arm,vexpress", }, + { .compatible = "calxeda,highbank", }, { .compatible = "calxeda,ecx-2000", },