* [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation
@ 2026-08-27 8:13 Gopikrishna Garmidi
2026-08-28 11:38 ` Konrad Dybcio
2026-08-31 17:53 ` Bjorn Andersson
0 siblings, 2 replies; 3+ messages in thread
From: Gopikrishna Garmidi @ 2026-08-27 8:13 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Pankaj Patil
Cc: Konrad Dybcio, Sibi Sankar, Rajendra Nayak, linux-arm-msm,
linux-kernel, Gopikrishna Garmidi
The DDR frequency in SMEM is reported in kHz and converted to Hz by
multiplying it by 1000. Since the SMEM frequency value is a u32, using
an unsuffixed integer constant causes the multiplication to be performed
with 32-bit arithmetic.
This overflows for DDR frequencies above 4294967 kHz, resulting in an
incorrect frequency being reported through the SMEM DRAM interface.
Use an unsigned long constant for the multiplication so the calculation
is performed with 64-bit arithmetic on the supported Qualcomm platforms.
Apply the fix consistently to the v3, v3.1, v4, v5, and v7 SMEM parsers.
Fixes: 1d234eeafc56 ("soc: qcom: smem: Expose DDR data from SMEM")
Signed-off-by: Gopikrishna Garmidi <gopikrishna.garmidi@oss.qualcomm.com>
---
drivers/soc/qcom/smem_dramc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/soc/qcom/smem_dramc.c b/drivers/soc/qcom/smem_dramc.c
index 63ebe7f6db59..9612230a03be 100644
--- a/drivers/soc/qcom/smem_dramc.c
+++ b/drivers/soc/qcom/smem_dramc.c
@@ -219,7 +219,7 @@ static void smem_dram_parse_v3_data(struct smem_dram *dram, void *data)
if (freq_entry->freq_khz && freq_entry->enabled) {
u32 freq_khz = le32_to_cpu(freq_entry->freq_khz);
- dram->frequencies[dram->num_frequencies++] = 1000 * freq_khz;
+ dram->frequencies[dram->num_frequencies++] = 1000UL * freq_khz;
}
}
}
@@ -232,7 +232,7 @@ static void smem_dram_parse_v3_14freqs_data(struct smem_dram *dram, void *data)
struct ddr_freq_table *freq_entry = &details->ddr_freq_tbl.ddr_freq[i];
if (freq_entry->freq_khz && freq_entry->enabled)
- dram->frequencies[dram->num_frequencies++] = 1000 * freq_entry->freq_khz;
+ dram->frequencies[dram->num_frequencies++] = 1000UL * freq_entry->freq_khz;
}
}
@@ -248,7 +248,7 @@ static void smem_dram_parse_v4_data(struct smem_dram *dram, void *data)
if (freq_entry->freq_khz && freq_entry->enabled) {
u32 freq_khz = le32_to_cpu(freq_entry->freq_khz);
- dram->frequencies[dram->num_frequencies++] = 1000 * freq_khz;
+ dram->frequencies[dram->num_frequencies++] = 1000UL * freq_khz;
}
}
}
@@ -265,7 +265,7 @@ static void smem_dram_parse_v5_data(struct smem_dram *dram, void *data)
if (freq_entry->freq_khz && freq_entry->enabled) {
u32 freq_khz = le32_to_cpu(freq_entry->freq_khz);
- dram->frequencies[dram->num_frequencies++] = 1000 * freq_khz;
+ dram->frequencies[dram->num_frequencies++] = 1000UL * freq_khz;
}
}
}
@@ -282,7 +282,7 @@ static void smem_dram_parse_v7_data(struct smem_dram *dram, void *data)
if (freq_entry->freq_khz && freq_entry->enabled) {
u32 freq_khz = le32_to_cpu(freq_entry->freq_khz);
- dram->frequencies[dram->num_frequencies++] = 1000 * freq_khz;
+ dram->frequencies[dram->num_frequencies++] = 1000UL * freq_khz;
}
}
}
---
base-commit: f82a5da2f04960df9fb57489992d03dd5e64ec6f
change-id: 20260826-glymur_dramc-55f6a0508ae0
Best regards,
--
Gopikrishna Garmidi <gopikrishna.garmidi@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation
2026-08-27 8:13 [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation Gopikrishna Garmidi
@ 2026-08-28 11:38 ` Konrad Dybcio
2026-08-31 17:53 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2026-08-28 11:38 UTC (permalink / raw)
To: Gopikrishna Garmidi, Bjorn Andersson, Konrad Dybcio, Pankaj Patil
Cc: Sibi Sankar, Rajendra Nayak, linux-arm-msm, linux-kernel
On 8/27/26 10:13 AM, Gopikrishna Garmidi wrote:
> The DDR frequency in SMEM is reported in kHz and converted to Hz by
> multiplying it by 1000. Since the SMEM frequency value is a u32, using
> an unsuffixed integer constant causes the multiplication to be performed
> with 32-bit arithmetic.
>
> This overflows for DDR frequencies above 4294967 kHz, resulting in an
> incorrect frequency being reported through the SMEM DRAM interface.
>
> Use an unsigned long constant for the multiplication so the calculation
> is performed with 64-bit arithmetic on the supported Qualcomm platforms.
> Apply the fix consistently to the v3, v3.1, v4, v5, and v7 SMEM parsers.
>
> Fixes: 1d234eeafc56 ("soc: qcom: smem: Expose DDR data from SMEM")
> Signed-off-by: Gopikrishna Garmidi <gopikrishna.garmidi@oss.qualcomm.com>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation
2026-08-27 8:13 [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation Gopikrishna Garmidi
2026-08-28 11:38 ` Konrad Dybcio
@ 2026-08-31 17:53 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2026-08-31 17:53 UTC (permalink / raw)
To: Konrad Dybcio, Pankaj Patil, Gopikrishna Garmidi
Cc: Konrad Dybcio, Sibi Sankar, Rajendra Nayak, linux-arm-msm, linux-kernel
On Thu, 27 Aug 2026 01:13:17 -0700, Gopikrishna Garmidi wrote:
> The DDR frequency in SMEM is reported in kHz and converted to Hz by
> multiplying it by 1000. Since the SMEM frequency value is a u32, using
> an unsuffixed integer constant causes the multiplication to be performed
> with 32-bit arithmetic.
>
> This overflows for DDR frequencies above 4294967 kHz, resulting in an
> incorrect frequency being reported through the SMEM DRAM interface.
>
> [...]
Applied, thanks!
[1/1] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation
commit: 7bb5f186784074f2a91d83e191e305238be47103
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-31 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 8:13 [PATCH] soc: qcom: smem: fix 32-bit overflow in DDR frequency calculation Gopikrishna Garmidi
2026-08-28 11:38 ` Konrad Dybcio
2026-08-31 17:53 ` Bjorn Andersson
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®