Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp472364rdb; Mon, 29 Jan 2024 07:54:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7pZuGqSc2RjJslvgYV/gUzegeWxH976pdO3F3YG71xBmIldSnT6waLg1ir0LVE6eoqKW9 X-Received: by 2002:ad4:5ae1:0:b0:68c:385b:ac93 with SMTP id c1-20020ad45ae1000000b0068c385bac93mr7915924qvh.59.1706543651368; Mon, 29 Jan 2024 07:54:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706543651; cv=pass; d=google.com; s=arc-20160816; b=TQBYAen77bDfvNgBQ36S+RSW5WNfx35GMbXGmO+9pAIGlhacQo9XZXZRhOTXiQVVLA 8XY9bQdTBwTGzTzyt/DRFKiYOfc50OeKPnfriHjuIZYmMqXUeostwA6ep3fGMxpUG//0 6O5BF/6MqauLi+5AtTVA9ActBL+R/gGcm/MM4TWWlgdfRuLRA4kgbQu+pKPSQCZhXEbZ pOxfBbQ96KXvVj+FIPh8FT8PdB/TzNR9Xmo5TRKzDu2lu3WGeSqAYEPwHk0LM+bqNIJn DQ2oV0Bsiy09hCgqeHpb1PWD3XbLVT5iqE3fU06fWkiMDtcodT7J4vylLgYPdleYUD+X KoVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=t7JeNMf3M1jpwXhvm3XxOBRb87TdAtupokveQSb3sJI=; fh=YVTETp8cXtXvurBAg0p9Y7xNv3oS3uAn/3CFDkuDNro=; b=NADefTg/4Q2D832BXeLSlPMKL7r7yZDDrpWJRXcsFrlIL3J4EUvV1OaeuXdX/tS+lJ L7+wncFsfe/ExbwNEvuZT5as5em/rQDryYWl133M74DdQjaRkurhggIZN3tRNtZnJaBK kXgjkWCaXscZPlRUduDFTlc5MoDd8n1hRBAKny+ARLqEHl+zX371M6U/8j1WE+PccaQe yBz8mnAa9Ai+OGSC28WgubpeSm/UPiuCHCOzCEQJgejlzt5HAKctrutNrF6SqbYk/ySl 3V3BGlc2QjGc1HunjF8hyZc/yA3jmmzpEKLkUQ6yckJNnKzOsMuHKePjUFo0oCoxYZTz vvMw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-43040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a24-20020a05620a16d800b00783f82a9381si3225391qkn.342.2024.01.29.07.54.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 07:54:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-43040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2340C1C22D40 for ; Mon, 29 Jan 2024 15:54:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67775155319; Mon, 29 Jan 2024 15:53:51 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE210154BFA; Mon, 29 Jan 2024 15:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706543630; cv=none; b=SHNgbfpNtT2y1+EH/VRe7zOKS/S1g7ffuwp5tbwirH3KOwH00YoT5zbA4JmelVSeD4AnC27PxvUEzdOvbJ8XZBSMfYGHGSzFMDb+VbP/WWF5MC9f9jnYYx+U5OOvNTVI7wPDDmqZ0+7KRIapUoztjeuFCo5SQyAbfuEkkIOVw68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706543630; c=relaxed/simple; bh=yUOgoH/cgXK92lzIp6hdtAKfj0+wNYCgmkrU8wjD0Cs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dBkjkU96qH/82o0rLz853+KNjQH7HQXn40GBStkmJ3Ess3tVG4stRXG6/Ttd46Ak7NDniT7fz4yUFxdlMxQiddLf1mBbMAT/U74OJqRTu1vxRaq9N6xvDjzZD7Zlh4UyrSaE7FWQ2bY0IfXAbf3jO+aRxGXO5UjDsOuftTCTUVw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 3735ADA7; Mon, 29 Jan 2024 07:54:32 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 57C023F738; Mon, 29 Jan 2024 07:53:46 -0800 (PST) Date: Mon, 29 Jan 2024 15:53:43 +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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240117104116.2055349-3-quic_sibis@quicinc.com> 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; > + > + return 0; > +} Potentially, once the dom info are exposed you can also drop this accessor and move all of these checks/calculations in the the SCMI cpufreq driver...but maybe Sudeep/Viresh prefer to keep this accessor exposed like others. Thanks, Cristian