From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6FEACC47258 for ; Wed, 31 Jan 2024 11:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UxDtRowMl3onQesjTrGFSMr86Ip1zHu175Ndl/oV8iM=; b=w4BzH3TiG2eymt gd5r6bafthRGpaUjnMfMwdG4zx7ncTZo7IXcCILgcajYAuJ1bqErK2JJRiAmsqUTp0YmHfaPtUsV1 d7u6FpvTEbVMLp707srX6rGMCNkx2jA2bRx5E//ykku/iGdqfKA5cAQv+QAwbLdjesyvJPVBfqi+v HOoUSwrpE5b2eD2/LWCDt6cvloBnUJA7B/Op29Hc3BMGxDSTrRAYTy8JhHBjGYq5luStDP+tbdK5g WwTlyzUq0WA2OAjRuU7u+LRXuBUP+LEOaJSTRjJjmyTrY48wC72YKf4M1KXCNknuw/khRWzEAqRDd FGR0yevtpO2D281TXnbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rV92f-00000003C3v-0quJ; Wed, 31 Jan 2024 11:46:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rV92c-00000003C31-0htC for linux-arm-kernel@lists.infradead.org; Wed, 31 Jan 2024 11:46:07 +0000 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 CF5BCDA7; Wed, 31 Jan 2024 03:46:43 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4AD343F762; Wed, 31 Jan 2024 03:45:58 -0800 (PST) Date: Wed, 31 Jan 2024 11:45:47 +0000 From: Cristian Marussi To: Sibi Sankar Cc: sudeep.holla@arm.com, rafael@kernel.org, viresh.kumar@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, lukasz.luba@arm.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_mdtipton@quicinc.com, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH V2 2/4] firmware: arm_scmi: Add perf_freq_xlate interface Message-ID: References: <20240117104116.2055349-1-quic_sibis@quicinc.com> <20240117104116.2055349-3-quic_sibis@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240117104116.2055349-3-quic_sibis@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240131_034606_272137_C07FD996 X-CRM114-Status: GOOD ( 22.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 17, 2024 at 04:11:14PM +0530, Sibi Sankar wrote: > Add a new perf_freq_xlate interface to the existing perf_ops to translate > a given perf index to frequency. > > This can be used by the cpufreq driver and framework to determine the > throttled frequency from a given perf index and apply HW pressure > accordingly. > > Signed-off-by: Sibi Sankar > --- > > v2: > * Rename opp_xlate -> freq_xlate [Viresh] > > drivers/firmware/arm_scmi/perf.c | 21 +++++++++++++++++++++ > include/linux/scmi_protocol.h | 3 +++ > 2 files changed, 24 insertions(+) > > diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c > index ae7681eda276..e286f04ee6e3 100644 > --- a/drivers/firmware/arm_scmi/perf.c > +++ b/drivers/firmware/arm_scmi/perf.c > @@ -977,6 +977,26 @@ static int scmi_notify_support(const struct scmi_protocol_handle *ph, u32 domain > return 0; > } > > +static int scmi_perf_freq_xlate(const struct scmi_protocol_handle *ph, u32 domain, > + int idx, unsigned long *freq) > +{ > + struct perf_dom_info *dom; > + > + dom = scmi_perf_domain_lookup(ph, domain); > + if (IS_ERR(dom)) > + return PTR_ERR(dom); > + > + if (idx >= dom->opp_count) > + return -ERANGE; > + > + if (!dom->level_indexing_mode) > + *freq = dom->opp[idx].perf * dom->mult_factor; > + else > + *freq = dom->opp[idx].indicative_freq * dom->mult_factor; > + As said elsewhere the plan would be to change slightly the SCMI core to avoid the need for this patch and the previous one (while NOT exposing too much Perf info)... ... anyway just looking at the above freq calc logic in this patch, be aware that as it stands it seems to me broken, since the idx you use to peek into the opp array comes (in the next patch) from the range_max carried by the notification and that can be, indeed, a perf_level OR a perf_index BUT it is absolutely NOT guaranteed to be an index into the opp[] array...so it may work in your case if you have a platform defining level or indexes matching the opp[] indexes BUT it is not true in general. (but as said, this will be handled by the core and possibly this patch dropped...) Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel