Skip to content

Commit 8e3c98d

Browse files
committed
firmware: arm_scmi: Fix frequency truncation by promoting multiplier 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]>
1 parent b85ea95 commit 8e3c98d

File tree

1 file changed

+3
-3
lines changed
  • drivers/firmware/arm_scmi

1 file changed

+3
-3
lines changed

drivers/firmware/arm_scmi/perf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct perf_dom_info {
152152
u32 opp_count;
153153
u32 sustained_freq_khz;
154154
u32 sustained_perf_level;
155-
u32 mult_factor;
155+
unsigned long mult_factor;
156156
struct scmi_perf_domain_info info;
157157
struct scmi_opp opp[MAX_OPPS];
158158
struct scmi_fc_info *fc_info;
@@ -273,8 +273,8 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
273273
dom_info->mult_factor = 1000;
274274
else
275275
dom_info->mult_factor =
276-
(dom_info->sustained_freq_khz * 1000) /
277-
dom_info->sustained_perf_level;
276+
(dom_info->sustained_freq_khz * 1000UL)
277+
/ dom_info->sustained_perf_level;
278278
strscpy(dom_info->info.name, attr->name,
279279
SCMI_SHORT_NAME_MAX_SIZE);
280280
}

0 commit comments

Comments
 (0)