All of lore.kernel.org
 help / color / mirror / Atom feed
From: quentin.perret@arm.com (Quentin Perret)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero
Date: Thu, 6 Sep 2018 14:17:54 +0100	[thread overview]
Message-ID: <20180906131752.ysubfiufocddpoey@queper01-lin> (raw)
In-Reply-To: <1536165491-27813-1-git-send-email-sudeep.holla@arm.com>

Hi Sudeep,

On Wednesday 05 Sep 2018 at 17:38:11 (+0100), Sudeep Holla wrote:
> @@ -166,7 +166,12 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
>  					le32_to_cpu(attr->sustained_freq_khz);
>  		dom_info->sustained_perf_level =
>  					le32_to_cpu(attr->sustained_perf_level);
> -		dom_info->mult_factor =	(dom_info->sustained_freq_khz * 1000) /
> +		if (!dom_info->sustained_freq_khz ||
> +		    !dom_info->sustained_perf_level)
> +			dom_info->mult_factor =	1;

I'm sorry I missed that the first time I reviewed this patch, but after
discussing with Ionela, we found out that there is actually a case where
this could be a problem. If you have perf levels that are 1,2,3,4 (for
example), then with mult_factor=1 you'll register OPPs at 1Hz, 2Hz, 3Hz,
4Hz into PM_OPP. And that will be turned into 0 KHz for all of them at
the CPUFreq level when divided by 1000 in dev_pm_opp_init_cpufreq_table().

I guess a quick fix would be to have a default mult_factor of 1000 ...

What do you think ?

Thanks,
Quentin

WARNING: multiple messages have this Message-ID (diff)
From: Quentin Perret <quentin.perret@arm.com>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: arm@kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Ionela Voinescu <ionela.voinescu@arm.com>,
	Kevin Hilman <khilman@linaro.org>,
	Olof Johansson <olof@lixom.net>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero
Date: Thu, 6 Sep 2018 14:17:54 +0100	[thread overview]
Message-ID: <20180906131752.ysubfiufocddpoey@queper01-lin> (raw)
In-Reply-To: <1536165491-27813-1-git-send-email-sudeep.holla@arm.com>

Hi Sudeep,

On Wednesday 05 Sep 2018 at 17:38:11 (+0100), Sudeep Holla wrote:
> @@ -166,7 +166,12 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
>  					le32_to_cpu(attr->sustained_freq_khz);
>  		dom_info->sustained_perf_level =
>  					le32_to_cpu(attr->sustained_perf_level);
> -		dom_info->mult_factor =	(dom_info->sustained_freq_khz * 1000) /
> +		if (!dom_info->sustained_freq_khz ||
> +		    !dom_info->sustained_perf_level)
> +			dom_info->mult_factor =	1;

I'm sorry I missed that the first time I reviewed this patch, but after
discussing with Ionela, we found out that there is actually a case where
this could be a problem. If you have perf levels that are 1,2,3,4 (for
example), then with mult_factor=1 you'll register OPPs at 1Hz, 2Hz, 3Hz,
4Hz into PM_OPP. And that will be turned into 0 KHz for all of them at
the CPUFreq level when divided by 1000 in dev_pm_opp_init_cpufreq_table().

I guess a quick fix would be to have a default mult_factor of 1000 ...

What do you think ?

Thanks,
Quentin

  reply	other threads:[~2018-09-06 13:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 16:38 [PATCH] firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero Sudeep Holla
2018-09-05 16:38 ` Sudeep Holla
2018-09-06 13:17 ` Quentin Perret [this message]
2018-09-06 13:17   ` Quentin Perret
2018-09-06 14:38   ` Sudeep Holla
2018-09-06 14:38     ` Sudeep Holla
2018-09-06 15:10 ` [PATCH v2] " Sudeep Holla
2018-09-06 15:10   ` Sudeep Holla
2018-09-06 16:59   ` Olof Johansson
2018-09-06 16:59     ` Olof Johansson
2018-09-06 17:11     ` Sudeep Holla
2018-09-06 17:11       ` Sudeep Holla

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=20180906131752.ysubfiufocddpoey@queper01-lin \
    --to=quentin.perret@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.