Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4907263iog; Wed, 22 Jun 2022 08:05:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sdsPJtZNmtIARZLEvjiv5vMfMrExqP7MuGBwjnNFFTd5Zleg+J9WdodWQYCOBsbahBL4S/ X-Received: by 2002:a17:90b:2407:b0:1ec:dd93:511a with SMTP id nr7-20020a17090b240700b001ecdd93511amr5689933pjb.212.1655910343938; Wed, 22 Jun 2022 08:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655910343; cv=none; d=google.com; s=arc-20160816; b=1GbeOW8IW3MczQSC38y8lv76d/Z2xpki4Ewc6+MvFotfbRfVlF+2CQxA+gdXVwzzdU sdWfj1SM2WnF4w9uaCsq0BDwDogIL+buvphUkTI9wbcxsMsCGN0jY3hULYFArSIoWwKj RyvthS+vOJNLah3YZN+RkqVTnGg3OBANROuX90gXe8xp3u2/TWIUCRIddppERXWf5WCP zXJlfAIcLXe3bM2ih01BeS3BCprn2dKLJRWbtdwuPm587V9PQ8cIXkHgRqIqXJy5O8UY iWB0WAzsnTJ7A4ONQ+7zsM++4MPUg3DR/nlo7XkdN8+y3ewOPduR6P1Y1zcPd6I8JO2Z Vd3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=i1MA/RDgkO+/P26+QERE8cd/P/DjCZz2b2axPTCwuc4=; b=XyZzJn5C2364t2iIUHt1DOFl2O7sLqa/C5cfV0a7zkXftHVbE62VzQ+jQEaxR7e9UK g/BE9Woc70lEZuk012IyUh+hdBkudD56GlrNUDg4cnIRMsAw+hZRNZknUzPbCJ1gFInk 4Nvm3frpeErle3K9DNTNb31l2/8B/Cpwx7QJZ1ESFYrgnlwjdY+Uw557vaQ1oxwxep67 3NuNrijYDwyG3wXH73mZc796FkD/gfnWMPe3uxibUEfVoawl+DQfSn15V1hVf7SQEXdV ZAyC/wL1i/WrJLOqpaz682XkEMbaMinhXb/mARhwfnWR47mb8n44rZ71BXBt8FI7oQ1Z Z/iA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i63-20020a638742000000b003fddf6f5bb4si2012474pge.302.2022.06.22.08.05.18; Wed, 22 Jun 2022 08:05:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S1358920AbiFVO70 (ORCPT + 99 others); Wed, 22 Jun 2022 10:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358839AbiFVO6W (ORCPT ); Wed, 22 Jun 2022 10:58:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D10F534B99; Wed, 22 Jun 2022 07:58:20 -0700 (PDT) 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 C01B913D5; Wed, 22 Jun 2022 07:58:20 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.38.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D18293F792; Wed, 22 Jun 2022 07:58:17 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com, viresh.kumar@linaro.org, rafael@kernel.org, dietmar.eggemann@arm.com, nm@ti.com, sboyd@kernel.org, sudeep.holla@arm.com, cristian.marussi@arm.com, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] firmware: arm_scmi: Get detailed power scale from perf Date: Wed, 22 Jun 2022 15:58:01 +0100 Message-Id: <20220622145802.13032-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220622145802.13032-1-lukasz.luba@arm.com> References: <20220622145802.13032-1-lukasz.luba@arm.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,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 In SCMI v3.1 the power scale can be in micro-Watts. The upper layers, e.g. cpufreq and EM should handle received power values properly (upscale when needed). Thus, provide an interface which allows to check what is the scale for power values. The old interface allowed to distinguish between bogo-Watts and milli-Watts only (which was good for older SCMI spec). Signed-off-by: Lukasz Luba --- drivers/firmware/arm_scmi/perf.c | 18 +++++++++++------- include/linux/scmi_protocol.h | 8 +++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index bbb0331801ff..92414e53f908 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -170,8 +170,7 @@ struct perf_dom_info { struct scmi_perf_info { u32 version; int num_domains; - bool power_scale_mw; - bool power_scale_uw; + enum scmi_power_scale power_scale; u64 stats_addr; u32 stats_size; struct perf_dom_info *dom_info; @@ -201,9 +200,13 @@ static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph, u16 flags = le16_to_cpu(attr->flags); pi->num_domains = le16_to_cpu(attr->num_domains); - pi->power_scale_mw = POWER_SCALE_IN_MILLIWATT(flags); + + if (POWER_SCALE_IN_MILLIWATT(flags)) + pi->power_scale = SCMI_POWER_MILLIWATTS; if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3) - pi->power_scale_uw = POWER_SCALE_IN_MICROWATT(flags); + if (POWER_SCALE_IN_MICROWATT(flags)) + pi->power_scale = SCMI_POWER_MICROWATTS; + pi->stats_addr = le32_to_cpu(attr->stats_addr_low) | (u64)le32_to_cpu(attr->stats_addr_high) << 32; pi->stats_size = le32_to_cpu(attr->stats_size); @@ -792,11 +795,12 @@ static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph, return dom->fc_info && dom->fc_info->level_set_addr; } -static bool scmi_power_scale_mw_get(const struct scmi_protocol_handle *ph) +static enum scmi_power_scale +scmi_power_scale_get(const struct scmi_protocol_handle *ph) { struct scmi_perf_info *pi = ph->get_priv(ph); - return pi->power_scale_mw; + return pi->power_scale; } static const struct scmi_perf_proto_ops perf_proto_ops = { @@ -811,7 +815,7 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .freq_get = scmi_dvfs_freq_get, .est_power_get = scmi_dvfs_est_power_get, .fast_switch_possible = scmi_fast_switch_possible, - .power_scale_mw_get = scmi_power_scale_mw_get, + .power_scale_get = scmi_power_scale_get, }; static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 704111f63993..a0a246310ba1 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -60,6 +60,12 @@ struct scmi_clock_info { }; }; +enum scmi_power_scale { + SCMI_POWER_BOGOWATTS, + SCMI_POWER_MILLIWATTS, + SCMI_POWER_MICROWATTS +}; + struct scmi_handle; struct scmi_device; struct scmi_protocol_handle; @@ -135,7 +141,7 @@ struct scmi_perf_proto_ops { unsigned long *rate, unsigned long *power); bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph, struct device *dev); - bool (*power_scale_mw_get)(const struct scmi_protocol_handle *ph); + enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); }; /** -- 2.17.1