Skip to content

Commit

Permalink
firmware: arm_scmi: Fix frequency truncation by promoting multiplier …
Browse files Browse the repository at this point in the history
…type

Fix the possible frequency truncation for all values equal to or greater
4GHz on 64bit machines by updating the multiplier 'mult_factor' to
'unsigned long' type. It is also possible that the multiplier itself can
be greater than or equal to 2^32. So we need to also fix the equation
computing the value of the multiplier.

Fixes: a9e3fbf ("firmware: arm_scmi: add initial support for performance protocol")
Reported-by: Sibi Sankar <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Cc: Cristian Marussi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sudeep Holla <[email protected]>
  • Loading branch information
sudeep-holla committed Dec 4, 2023
1 parent b85ea95 commit 8e3c98d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/firmware/arm_scmi/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct perf_dom_info {
u32 opp_count;
u32 sustained_freq_khz;
u32 sustained_perf_level;
u32 mult_factor;
unsigned long mult_factor;
struct scmi_perf_domain_info info;
struct scmi_opp opp[MAX_OPPS];
struct scmi_fc_info *fc_info;
Expand Down Expand Up @@ -273,8 +273,8 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
dom_info->mult_factor = 1000;
else
dom_info->mult_factor =
(dom_info->sustained_freq_khz * 1000) /
dom_info->sustained_perf_level;
(dom_info->sustained_freq_khz * 1000UL)
/ dom_info->sustained_perf_level;
strscpy(dom_info->info.name, attr->name,
SCMI_SHORT_NAME_MAX_SIZE);
}
Expand Down

0 comments on commit 8e3c98d

Please sign in to comment.