Re: [PATCH 2/3] firmware: arm_scmi: Fix freq/power truncation in the perf protocol

From: Sudeep Holla
Date: Thu Nov 30 2023 - 14:54:01 EST


On Thu, Nov 30, 2023 at 04:25:44PM +0000, Cristian Marussi wrote:
> On Thu, Nov 30, 2023 at 01:56:56PM +0000, Sudeep Holla wrote:
> > I started exactly with that, but when I completed the patch, there was no
> > explicit need for it, so dropped it again. I can bump mult_factor to be
> > u64 but do you see any other place that would need it apart from having
> > single statement that does multiplication and assignment ? I am exploiting
> > the conditional based on level_indexing_mode here but I agree it may help
> > in backporting if I make mult_factor u64.
> >
>
> Ah right
>
> freq *= dom->multi_fact;
>
> does the trick..but cannot this by itself (under unplausibl conds)
> overflow and does not fit into a u32 mult_factor ?
>
> dom_info->mult_factor =
> (dom_info->sustained_freq_khz * 1000UL)
> / dom_info->sustained_perf_level;

Agreed. Also thinking about backports, I think making it u64 is simple
fix. I will also thinking of splitting the changes so that fixes are
more appropriate. I will try to post something soonish.

--
Regards,
Sudeep