mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jagadeesh Kona <quic_jkona@quicinc.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	"Cristian Marussi" <cristian.marussi@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Taniya Das <quic_tdas@quicinc.com>,
	"Ajit Pandey" <quic_ajipan@quicinc.com>,
	Imran Shaik <quic_imrashai@quicinc.com>,
	Vivek Aknurwar <quic_viveka@quicinc.com>,
	Mike Tipton <quic_mdtipton@quicinc.com>
Subject: Re: [PATCH] cpufreq: scmi: Avoid overflow of target_freq in fast switch
Date: Mon, 20 May 2024 10:55:49 +0530	[thread overview]
Message-ID: <24063964-fa44-4093-bbfe-950eeb7d01b3@quicinc.com> (raw)
In-Reply-To: <20240517070157.19553-1-quic_jkona@quicinc.com>



On 5/17/2024 12:31 PM, Jagadeesh Kona wrote:
> Conversion of target_freq to HZ in scmi_cpufreq_fast_switch()
> can lead to overflow if the multiplied result is greater than
> UINT_MAX, since type of target_freq is unsigned int. Avoid this
> overflow by assigning target_freq to u64 variable for converting
> it to HZ.
> 
> Signed-off-by: Jagadeesh Kona <quic_jkona@quicinc.com>
> ---
>   drivers/cpufreq/scmi-cpufreq.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
> index 3b4f6bfb2f4c..42be87aebe6f 100644
> --- a/drivers/cpufreq/scmi-cpufreq.c
> +++ b/drivers/cpufreq/scmi-cpufreq.c
> @@ -63,9 +63,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy,
>   					     unsigned int target_freq)
>   {
>   	struct scmi_data *priv = policy->driver_data;
> +	u64 freq = target_freq;
>   

To keep type of freq consistent with the rate parameter of scmi 
.freq_set() callback which is unsigned long, will move the above freq 
variable from u64 to unsigned long and post the v2 series.

Thanks,
Jagadeesh

> -	if (!perf_ops->freq_set(ph, priv->domain_id,
> -				target_freq * 1000, true))
> +	if (!perf_ops->freq_set(ph, priv->domain_id, freq * 1000, true))
>   		return target_freq;
>   
>   	return 0;

      reply	other threads:[~2024-05-20  5:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  7:01 Jagadeesh Kona
2024-05-20  5:25 ` Jagadeesh Kona [this message]

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=24063964-fa44-4093-bbfe-950eeb7d01b3@quicinc.com \
    --to=quic_jkona@quicinc.com \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=quic_ajipan@quicinc.com \
    --cc=quic_imrashai@quicinc.com \
    --cc=quic_mdtipton@quicinc.com \
    --cc=quic_tdas@quicinc.com \
    --cc=quic_viveka@quicinc.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

all inboxes | Powered by JetHome®