linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Pierre Gondois <pierre.gondois@arm.com>
Cc: linux-kernel@vger.kernel.org,
	Christian Loehle <christian.loehle@arm.com>,
	Ionela Voinescu <ionela.voinescu@arm.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/3] firmware: arm_scmi: Populate fast channel rate_limit
Date: Mon, 4 Mar 2024 08:00:17 +0000	[thread overview]
Message-ID: <ZeV_kdcPSb-MFesS@pluto> (raw)
In-Reply-To: <20240222135702.2005635-3-pierre.gondois@arm.com>

On Thu, Feb 22, 2024 at 02:57:00PM +0100, Pierre Gondois wrote:
> Arm SCMI spec. v3.2, s4.5.3.12 PERFORMANCE_DESCRIBE_FASTCHANNEL
> defines a per-domain rate_limit for performance requests:
> """
> Rate Limit in microseconds, indicating the minimum time
> required between successive requests. A value of 0
> indicates that this field is not applicable or supported
> on the platform.
> """"
> The field is first defined in SCMI v2.0.
> 
> Add support to fetch this value and advertise it through
> a fast_switch_rate_limit() callback.
> 
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>

Hi,

LGTM.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>

Thanks,
Cristian

> ---
>  drivers/firmware/arm_scmi/driver.c    |  5 ++++-
>  drivers/firmware/arm_scmi/perf.c      | 32 +++++++++++++++++++++++----
>  drivers/firmware/arm_scmi/powercap.c  | 12 ++++++----
>  drivers/firmware/arm_scmi/protocols.h |  4 +++-
>  include/linux/scmi_protocol.h         |  4 ++++
>  5 files changed, 47 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 3ea64b22cf0d..1d38ecfafc59 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -1617,7 +1617,7 @@ static void
>  scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
>  			     u8 describe_id, u32 message_id, u32 valid_size,
>  			     u32 domain, void __iomem **p_addr,
> -			     struct scmi_fc_db_info **p_db)
> +			     struct scmi_fc_db_info **p_db, u32 *rate_limit)
>  {
>  	int ret;
>  	u32 flags;
> @@ -1661,6 +1661,9 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
>  		goto err_xfer;
>  	}
>  
> +	if (rate_limit)
> +		*rate_limit = le32_to_cpu(resp->rate_limit) & GENMASK(19, 0);
> +
>  	phys_addr = le32_to_cpu(resp->chan_addr_low);
>  	phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32;
>  	addr = devm_ioremap(ph->dev, phys_addr, size);
> diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
> index 37c80376bd0a..fbcbd703198a 100644
> --- a/drivers/firmware/arm_scmi/perf.c
> +++ b/drivers/firmware/arm_scmi/perf.c
> @@ -789,23 +789,27 @@ static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
>  
>  	ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
>  				   PERF_LEVEL_GET, 4, dom->id,
> -				   &fc[PERF_FC_LEVEL].get_addr, NULL);
> +				   &fc[PERF_FC_LEVEL].get_addr, NULL,
> +				   &fc[PERF_FC_LEVEL].rate_limit);
>  
>  	ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
>  				   PERF_LIMITS_GET, 8, dom->id,
> -				   &fc[PERF_FC_LIMIT].get_addr, NULL);
> +				   &fc[PERF_FC_LIMIT].get_addr, NULL,
> +				   &fc[PERF_FC_LIMIT].rate_limit);
>  
>  	if (dom->info.set_perf)
>  		ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
>  					   PERF_LEVEL_SET, 4, dom->id,
>  					   &fc[PERF_FC_LEVEL].set_addr,
> -					   &fc[PERF_FC_LEVEL].set_db);
> +					   &fc[PERF_FC_LEVEL].set_db,
> +					   &fc[PERF_FC_LEVEL].rate_limit);
>  
>  	if (dom->set_limits)
>  		ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
>  					   PERF_LIMITS_SET, 8, dom->id,
>  					   &fc[PERF_FC_LIMIT].set_addr,
> -					   &fc[PERF_FC_LIMIT].set_db);
> +					   &fc[PERF_FC_LIMIT].set_db,
> +					   &fc[PERF_FC_LIMIT].rate_limit);
>  
>  	dom->fc_info = fc;
>  }
> @@ -974,6 +978,25 @@ static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
>  	return dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr;
>  }
>  
> +static int scmi_fast_switch_rate_limit(const struct scmi_protocol_handle *ph,
> +				       u32 domain, u32 *rate_limit)
> +{
> +	struct perf_dom_info *dom;
> +
> +	if (!rate_limit)
> +		return -EINVAL;
> +
> +	dom = scmi_perf_domain_lookup(ph, domain);
> +	if (IS_ERR(dom))
> +		return PTR_ERR(dom);
> +
> +	if (!dom->fc_info)
> +		return -EINVAL;
> +
> +	*rate_limit = dom->fc_info[PERF_FC_LEVEL].rate_limit;
> +	return 0;
> +}
> +
>  static enum scmi_power_scale
>  scmi_power_scale_get(const struct scmi_protocol_handle *ph)
>  {
> @@ -996,6 +1019,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,
> +	.fast_switch_rate_limit = scmi_fast_switch_rate_limit,
>  	.power_scale_get = scmi_power_scale_get,
>  };
>  
> diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c
> index a4c6cd4716fe..604184c044ff 100644
> --- a/drivers/firmware/arm_scmi/powercap.c
> +++ b/drivers/firmware/arm_scmi/powercap.c
> @@ -703,20 +703,24 @@ static void scmi_powercap_domain_init_fc(const struct scmi_protocol_handle *ph,
>  	ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
>  				   POWERCAP_CAP_SET, 4, domain,
>  				   &fc[POWERCAP_FC_CAP].set_addr,
> -				   &fc[POWERCAP_FC_CAP].set_db);
> +				   &fc[POWERCAP_FC_CAP].set_db,
> +				   &fc[POWERCAP_FC_CAP].rate_limit);
>  
>  	ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
>  				   POWERCAP_CAP_GET, 4, domain,
> -				   &fc[POWERCAP_FC_CAP].get_addr, NULL);
> +				   &fc[POWERCAP_FC_CAP].get_addr, NULL,
> +				   &fc[POWERCAP_FC_CAP].rate_limit);
>  
>  	ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
>  				   POWERCAP_PAI_SET, 4, domain,
>  				   &fc[POWERCAP_FC_PAI].set_addr,
> -				   &fc[POWERCAP_FC_PAI].set_db);
> +				   &fc[POWERCAP_FC_PAI].set_db,
> +				   &fc[POWERCAP_FC_PAI].rate_limit);
>  
>  	ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
>  				   POWERCAP_PAI_GET, 4, domain,
> -				   &fc[POWERCAP_FC_PAI].get_addr, NULL);
> +				   &fc[POWERCAP_FC_PAI].get_addr, NULL,
> +				   &fc[POWERCAP_PAI_GET].rate_limit);
>  
>  	*p_fc = fc;
>  }
> diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h
> index e683c26f24eb..8b5d9ce4a33a 100644
> --- a/drivers/firmware/arm_scmi/protocols.h
> +++ b/drivers/firmware/arm_scmi/protocols.h
> @@ -234,6 +234,7 @@ struct scmi_fc_info {
>  	void __iomem *set_addr;
>  	void __iomem *get_addr;
>  	struct scmi_fc_db_info *set_db;
> +	u32 rate_limit;
>  };
>  
>  /**
> @@ -268,7 +269,8 @@ struct scmi_proto_helpers_ops {
>  				 u8 describe_id, u32 message_id,
>  				 u32 valid_size, u32 domain,
>  				 void __iomem **p_addr,
> -				 struct scmi_fc_db_info **p_db);
> +				 struct scmi_fc_db_info **p_db,
> +				 u32 *rate_limit);
>  	void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
>  };
>  
> diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
> index acd956ffcb84..fafedb3b6604 100644
> --- a/include/linux/scmi_protocol.h
> +++ b/include/linux/scmi_protocol.h
> @@ -139,6 +139,8 @@ struct scmi_perf_domain_info {
>   *	at a given frequency
>   * @fast_switch_possible: indicates if fast DVFS switching is possible or not
>   *	for a given device
> + * @fast_switch_rate_limit: gets the minimum time (us) required between
> + *	successive fast_switching requests
>   * @power_scale_mw_get: indicates if the power values provided are in milliWatts
>   *	or in some other (abstract) scale
>   */
> @@ -168,6 +170,8 @@ struct scmi_perf_proto_ops {
>  			     unsigned long *rate, unsigned long *power);
>  	bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
>  				     u32 domain);
> +	int (*fast_switch_rate_limit)(const struct scmi_protocol_handle *ph,
> +				      u32 domain, u32 *rate_limit);
>  	enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
>  };
>  
> -- 
> 2.25.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-03-04  8:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 13:56 [PATCH 0/3] scmi-cpufreq: Set transition_delay_us Pierre Gondois
2024-02-22 13:56 ` [PATCH 1/3] firmware: arm_scmi: Populate perf commands rate_limit Pierre Gondois
2024-03-04  7:55   ` Cristian Marussi
2024-03-05 11:47   ` Sudeep Holla
2024-02-22 13:57 ` [PATCH 2/3] firmware: arm_scmi: Populate fast channel rate_limit Pierre Gondois
2024-03-04  8:00   ` Cristian Marussi [this message]
2024-03-05 11:46   ` Sudeep Holla
2024-02-22 13:57 ` [PATCH 3/3] cpufreq: scmi: Set transition_delay_us Pierre Gondois
2024-03-04  8:15   ` Cristian Marussi
2024-03-04  7:00 ` [PATCH 0/3] scmi-cpufreq: " Viresh Kumar
2024-03-04 11:42   ` Sudeep Holla
2024-03-06  5:24     ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZeV_kdcPSb-MFesS@pluto \
    --to=cristian.marussi@arm.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ionela.voinescu@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pierre.gondois@arm.com \
    --cc=rafael@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).