Page MenuHomeFreeBSD

cpufreq_dt: Find the closest frequency
ClosedPublic

Authored by manu on Sep 6 2023, 4:46 PM.
Tags
None
Referenced Files
F102168994: D41762.diff
Fri, Nov 8, 11:23 AM
Unknown Object (File)
Wed, Oct 23, 8:54 AM
Unknown Object (File)
Wed, Oct 23, 8:53 AM
Unknown Object (File)
Wed, Oct 23, 8:53 AM
Unknown Object (File)
Wed, Oct 23, 8:53 AM
Unknown Object (File)
Wed, Oct 23, 8:52 AM
Unknown Object (File)
Wed, Oct 23, 8:46 AM
Unknown Object (File)
Sep 21 2024, 4:20 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 53486
Build 50377: arc lint + arc unit

Event Timeline

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

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
120

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.