Page MenuHomeFreeBSD

cpufreq_dt: Find the closest frequency
ClosedPublic

Authored by manu on Sep 6 2023, 4:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 1:13 PM
Unknown Object (File)
Thu, Apr 25, 10:23 AM
Unknown Object (File)
Feb 18 2024, 5:54 AM
Unknown Object (File)
Jan 9 2024, 10:22 AM
Unknown Object (File)
Dec 23 2023, 12:19 PM
Unknown Object (File)
Dec 2 2023, 4:55 PM
Unknown Object (File)
Nov 22 2023, 11:51 AM
Unknown Object (File)
Nov 22 2023, 11:51 AM
Subscribers

Details

Summary

When building the frequencies table we convert the value in the DTS to
megahertz and loose precision. While it's not a problem for most of the
DTS it is when the expected frequency value is strict down to the hertz.
So it's either we don't truncate the value and have some ugly and long
values in the sysctls or we just find the closest frequency.
Do the latter.

Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

manu requested review of this revision.Sep 6 2023, 4:46 PM
andrew added inline comments.
sys/dev/cpufreq/cpufreq_dt.c
116

Why abs(freq)?

manu marked an inline comment as done.Sep 6 2023, 5:01 PM
mmel added inline comments.
sys/dev/cpufreq/cpufreq_dt.c
116

The abs() function uses an integer as an argument. I'm afraid we don't have an abs() function for uint64_t. Besides,
the result of subtracting two unsigned numbers is also an unsigned number.

Imho, We can convert these frequencies to int64_t without losing anything, and then use our own version of the 'abs_i64()' function.

manu marked an inline comment as done.
This revision is now accepted and ready to land.Sep 8 2023, 5:00 AM
This revision was automatically updated to reflect the committed changes.