]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cpufreq/amd-pstate: Fix the clamping of perf values
authorDhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Sat, 22 Feb 2025 03:32:22 +0000 (03:32 +0000)
committerMario Limonciello <mario.limonciello@amd.com>
Thu, 6 Mar 2025 19:01:17 +0000 (13:01 -0600)
commita1d1d8fb653532638cfb3ee0b7e67ebd5327a3d6
tree342a54e5dc9b109cd3d0d44261341a9f450972cd
parent3e93edc58a63cf816e6dc853da8e9b0201bd0298
cpufreq/amd-pstate: Fix the clamping of perf values

The clamping in freq_to_perf() is broken right now, as we first typecast
(read wraparound) the overflowing value into a u8 and then clamp it down.
So, use a u32 to store the >255 value in certain edge cases and then clamp
it down into a u8.

Also, use a "explicit typecast + clamp" instead of just a "clamp_t" as the
latter typecasts first and then clamps between the limits, which defeats
our purpose.

Fixes: 620136ced35a ("cpufreq/amd-pstate: Modularize perf<->freq conversion")
Signed-off-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20250222033221.554976-1-dhananjay.ugwekar@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
drivers/cpufreq/amd-pstate.c