aboutsummaryrefslogtreecommitdiff
path: root/sys/x86/cpufreq
Commit message (Collapse)AuthorAgeFilesLines
* hwpstate_amd(4): Fix punctuation in 'desired_performance' knob's descriptionOlivier Certner2 days1-1/+1
| | | | | | | | To be consistent with that of the others. No functional change. Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): CPPC: Switch the default to maximum performanceOlivier Certner2 days1-8/+10
| | | | | | | | | Set controls to maximum performance to avoid regressions now that CPPC is activated by default and to match what the P-state support does. Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55253
* hwpstate_amd(4): CPPC: Allow attaching even if CAPABILITY_1 cannot be readOlivier Certner2 days1-17/+28
| | | | | | | | | If that MSR cannot be read, we fallback to defaults specified by the ACPI specification, as we are already doing when the minimum and maximum values in there look bogus. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55252
* hwpstate_amd(4): Consistency of cached CPPC_REQUEST valueOlivier Certner2 days1-31/+108
| | | | | | | | | | | | | | | | | | | | | | | | | If writing to the CPPC_REQUEST MSR fails, make sure we do not set the softc's 'cppc.request' field to the intended new value. Both set_cppc_request_cb() and enable_cppc_cb() were changed to this effect. In case enable_cppc_cb() could not read CPPC_REQUEST, mark that through a new softc flag, HWPFL_CPPC_REQUEST_NOT_READ, so that we do not keep and use a wrong value when the content of CPPC_REQUEST is read/written through sysctl(9) knobs, but instead retry reading the MSR (this is the purpose of the new get_cppc_request() sub-function). When setting CPPC_REQUEST has failed, distinguish the case where it could not be read at all from the case where it could not be written, by respectively returning EIO and EOPNOTSUPP in these cases. The previous return value of EFAULT was confusing as sysctl(3) documents it as happening if the passed arguments are invalid. While here, add some herald comment before sysctl_cppc_dump_handler() clarifying that the intent of this function is to always query the hardware directly, bypassing any cached value in the softc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55251
* hwpstate_amd(4): Move 'struct get_cppc_regs_data' & co. closer to useOlivier Certner11 days1-22/+22
| | | | | | No functional change (intended). Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Rename '*set_autonomous_hwp*()' => 'enable_cppc*()'Olivier Certner11 days1-4/+4
| | | | | | | | | | This is to better reflect that we are really enabling CPPC in these functions and because we are likely to stop activating CPPC autonomous mode by default in the near future. No functional change (intended). Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Rename PSTATE_CPPC internal flagOlivier Certner11 days1-18/+16
| | | | | | | | While here, also rename check_cppc_enabled() => check_cppc_in_use(). No functional change (intended). Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Style: Align 'machdep.hwpstate_amd_cppc_enable'Olivier Certner11 days1-1/+1
| | | | | | | | Align it like the rest. No functional change (intended). Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Update copyrightOlivier Certner11 days1-0/+5
| | | | Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Style: Sort headersOlivier Certner11 days1-4/+5
| | | | | | And separate includes from the rest with an additional newline. Sponsored by: The FreeBSD Foundation
* hwpstate_amd(4): Add knobs to get/set all fields of CPPC_REQUESTOlivier Certner11 days1-12/+42
| | | | | | | | | | | | | | This will allow experimentations and finer-grained tuning to the full extent allowed by the hardware, which is especially important given that the spec leaves to hardware implementors an important leeway in interpreting CPPC's numeric parameters, causing the same settings to have different effects on different CPU models. PR: 292615 Reviewed by: aokblast (older version) Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55010
* hwpstate_amd(4): 'epp' sysctl leaf to operate on real EPP hardware valuesOlivier Certner11 days1-13/+8
| | | | | | | | | | | | | | | | | | | | We were using percents, for compatibility with hwpstate_intel(4), but this looses granularity that might be important in some scenarios or with specific CPU models. For consistency, hwpstate_intel(4) should be changed accordingly, at the expense of breaking compatibility. For release notes: Introduction of hwpstate_amd(4) deserves a release note, even if the original commit was not tagged. Functionality introduced by recent commits tagged with "Relnotes" should be mentioned along that one. PR: 292615 Reviewed by: aokblast Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55009
* hwpstate_amd(4): Factor out setting the CPPC_REQUEST registerOlivier Certner11 days1-25/+69
| | | | | | | | | | | | In preparation for creating other knobs to tweak values in this register beyond just the EPP (Efficiency/Performance Preference). While here, add a herald comment before the softc structure indicating how we achieve atomicity when modifying the softc. Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55008
* hwpstate_amd(4): Sane defaults for min/max perf on insane capabilitiesOlivier Certner11 days1-4/+23
| | | | | | | | | | | | | | | | | | | If the CPPC_CAPABILITY_1 register stays at its reset value (0) even after enabling CPPC, as observed in the field (see the referenced PR below), use sane min/max performance limits as hinted by the ACPI spec, i.e., all 0s for the minimum value and all 1s for the maximum one. While here, let's cope upfront with some more insane situations, where the minimum value would be greater than the maximum one, but also if they would be equal which does not seem to make sense at all in the CPPC frame (and, anyway, in this case, the actual minimum and maximum values we program should have no effect at all). That last case actually also covers the one exposed in the previous paragraph. PR: 292615 Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55007
* hwpstate_amd(4): attach(): More diagnostic on CPPC enableOlivier Certner11 days1-49/+84
| | | | | | | | | | | | | | | | | | | | | When the 'debug.hwpstate_verbose' tunable/sysctl knob is set, dump the initial content of the CPPC_CAPABILITY_1 and CPPC_REQUEST registers. If, after enabling CPPC, reading/writing some MSR fails during the attach sequence, print a diagnostic. However, once CPPC is enabled, we cannot go back (disabling it is impossible), so we'll attach even if fiddling with other MSRs failed. While here, move diagnostic printing on attach out of the callback that is executed on (potentially) another CPU and with interrupts disabled, putting it into the attach routine itself. While here, fix format for printing the CPU ID. PR: 292615 Reviewed by: aokblast (older version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55006
* hwpstate_amd(4): Register dump: Fine-grained error reportingOlivier Certner11 days1-40/+72
| | | | | | | | | | | | | | | | | | If some of the registers cannot be read, report that but continue trying reading the others. This also has the side benefit of simplifying code. While here, use sbuf_new_for_sysctl(), and rename 'res' and 'ret', which are to contain error values, to 'error'. While here, remove the test on getting the per-cpu structure, as if it is not present we would have already crashed on device attach. While here, fix format for printing the CPU ID. PR: 292615 Reviewed by: aokblast (older version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55005
* hwpstate_amd(4): Revamp the softcOlivier Certner2026-02-061-15/+22
| | | | | | | | | | | | | | | | | | As the new CPPC and old P-states modes are exclusive, put their respective data in a union. Rename the field containing the content of the CPPC_REQUEST register. It it now to be accessed using 'cppc.request'. Use an 'unsigned int' instead of 'uint32_t' for 'flags'. This is an internal field whose width could be changed at will. We only have one flag at the moment. No functional change intended. Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55004
* hwpstate_amd(4): attach(): Fix styleOlivier Certner2026-02-061-2/+2
| | | | | | | | No functional change intended. Reviewed by: aokblast, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55003
* hwpstate_amd(4): Rename EPP handler, convert to unsigned intOlivier Certner2026-02-061-17/+15
| | | | | | | | | | | | | | | 'val' is supposed to be the storage for a sysctl knob of an 'unsigned int', so consistently don't specify its width. While here, rename variables in the handler. The new names feel clearer, and the 'ret' => 'error' rename is to be more in line with our tradition. No functional change intended. Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55002
* hwpstate_amd(4): Assert PSTATE_CPPC is on in corresponding sysctl handlersOlivier Certner2026-02-061-3/+12
| | | | | | | No functional change intended. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55001
* hwpstate_amd(4): Rename register dump sysctl handlerOlivier Certner2026-02-061-14/+13
| | | | | | | | | | | | | | | | While here, rename the callback function and structure to a more immediately informative name. While here, remove a superfluous cast and rename the variable containing the callback data to just 'data' instead of 'req' which can be confusing (because of CPPC_REQUEST but also the fact that 'req' is a parameter of sysctl handlers). No functional change intended. Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55000
* hwpstate_amd(4): Factor out printing CPPC registers, fix CPPC_REQUEST'sOlivier Certner2026-02-061-22/+43
| | | | | | | | | | | | | | | | | | | | Factor out these printing, so they can be called from other places than just the register dump handler. This also makes surrounding code clearer. Fix inverted printing of minimum and maximum performance. For better diagnostic, print the full raw content of each register before printing the value of fields we know about. As fields are printed in decimal, remove 0-padding, which could give the impression that the numbers are printed in octal or hexadecimal. While here, remove superfluous blank lines when printing (we use TABs for the different registers' fields). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54999
* hwpstate{_amd,intel}(4): Move common knobs to a separate fileOlivier Certner2026-02-064-14/+38
| | | | | | | | | | | | | | | | | | | Reason for doing this right now is to resolve the conflict on 'machdep.hwpstate_pkg_ctrl' between the Intel and AMD drivers, even though I expect to remove it for hwpstate_amd(4) at some point. More generally, this is going to be useful for some future code factorization. Also, the 'debug.hwpstate_verbose' knob was moved there, as we'll likely want to use it for the Intel driver as well (which is currently not the case). Note for MFC: Will be partial, since `hwpstate_amd(4)` does not support CPPC in stable/15 nor stable/14. Reviewed by: emaste Fixes: 3e6e4e4a0d42 ("hwpstate: add CPPC support for pstate driver on AMD") MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D54528
* hwpstate_amd(4): Rename CPPC register macrosOlivier Certner2026-02-031-14/+14
| | | | | | | | | | | | | To be closer to AMD's official terminology, except for the "Lowest Non-Linear Performance" field which we label as 'EFFICIENT_PERF' closer to Intel's ("Most Efficient Performance"), and to clear possible confusion. No functional change (intended). Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54998
* hwpstate_amd(4): Fix BITS_WITH_VALUE()/SET_BITS_VALUE() to obey the maskOlivier Certner2026-02-031-3/+5
| | | | | | | | | While here, rename an argument of BITS_VALUE() to be consistent with the other macros. Reviewed by: aokblast Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54997
* hwpstate: Add CPPC enable tunableCy Schubert2026-01-221-1/+7
| | | | | | | | | | | | | | | | | | The Framework 13 runs very hot the maximum frequency is possible. By disabling CPPC (reverting to Cool`n'Quiet 2.0) we can use powerd to limit the CPU frequency to 2200, thereby reducing the CPU temperature. Some systems may run slower with CPPC enabled. See PR/292615 for that bug. Those experiencing either of these issues may add the following to their loader.conf or device.hints to disable CPPC: machdep.hwpstate_amd_cppc_enable="0" PR: 292615 Reviewed by: lwhsu, olce Differential revision: https://reviews.freebsd.org/D54803
* hwpstate_amd: Use ipi instead of sched_bind + thread_lockShengYi Hung2026-01-161-67/+79
| | | | | | | Reviewed by: olce Approved by: markj (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D54505
* hwpstate_amd: Fix compile errorShengYi Hung2026-01-031-1/+1
| | | | | | | | | Add parentheses between OR and AND operator to pass the compiler check. Approved by: lwhsu (mentor) Fixes: 3e6e4e4a0d42 ("hwpstate: add CPPC support for pstate driver on AMD") MFC aftert: 2 weeks Differential Revision: https://reviews.freebsd.org/D54465
* hwpstate: add CPPC support for pstate driver on AMDShengYi Hung2026-01-031-25/+336
| | | | | | | | | | | | | | | | | | | | | | | | | Implement CPPC interface for AMD Pstate Driver. This feature is only enabled when the CPUID shows it support CPPC. The CPPC is implemneted by the following steps: 1. Write MSR to enable it. 2. Read capability registert which indicates binary value of levels about lowest, best energy efficient, guarantee, and max performance. 3. Write request register with epp in energy balanced mode. And let CPU and firmware to enter autonomous mode. Also, create a sysctl handler to allow userspace to change epp value. In intel's hwpstate, The epp value can be in package level and core level. However, in AMD's one, there is only core level. Thus, to sync with the intel's code, we implement package level control in software and provide another sysctl (machdep.hwpstate_pkg_ctrl) to control it. Reviewed by: olce, khng Approved by: lwhsu (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49587
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-216-13/+19
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* hwpstate_amd: add amd pstate for zen5SHENGYI HONG2025-01-161-16/+46
| | | | | | Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47985
* hwpstate_amd: add amd pstate for zen4SHENGYI HONG2025-01-161-0/+1
| | | | | | | | Co-authored-by: Daniel Schaefer <dhs@frame.work> Reviewed by: markj MFC after: 2 weeks Sponsored by: Framework Computer Inc Differential Revision: https://reviews.freebsd.org/D48461
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-276-6/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-166-12/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* hwpstate_amd: calculate power if P-state info comes from MSRJohannes Totz2023-06-121-4/+28
| | | | | | Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D40140
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-127-7/+7
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* cpufreq: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-066-13/+7
|
* powernow(4): Fix unused variable warnings by using the variables.John Baldwin2022-04-061-2/+2
|
* x86: Remove CTLFLAG_NEEDGIANT from sysctls.Alexander Motin2021-12-261-2/+2
| | | | MFC after: 2 weeks
* smist: Remove unneeded Giant from bus_dma_tag_create().Alexander Motin2021-12-101-2/+1
| | | | | | bus_dmamap_load() call uses BUS_DMA_NOWAIT. MFC after: 2 weeks
* modules: increase MAXMODNAME and provide backward compatBjoern A. Zeeb2021-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | With various firmware files used by graphics and wireless drivers we are exceeding the current 32 character module name (file path in kldxref) length. In order to overcome this issue bump it to the maximum path length for the next version. To be able to MFC provide backward compat support for another version of the struct as the offsets for the second half change due to the array size increase. MAXMODNAME being defined to MAXPATHLEN needs param.h to be included first. With only 7 modules (or LinuxKPI module.h) not doing that adjust them rather than including param.h in module.h [1]. Reported by: Greg V (greg unrelenting.technology) Sponsored by: The FreeBSD Foundation Suggested by: imp [1] MFC after: 10 days Reviewed by: imp (and others to different level) Differential Revision: https://reviews.freebsd.org/D32383
* Make CPU children explicitly share parent unit numbers.Alexander Motin2021-09-256-10/+12
| | | | | | Before this device unit number match was coincidental and broke if I disabled some CPU device(s). Aside of cosmetics, for some drivers (may be considered broken) it caused talking to wrong CPUs.
* hwpstate_intel: don't unconditionally print the error messageYuri Pankov2020-11-291-2/+4
| | | | | | | | | | | Actually check the wrmsr_safe() return value when setting autonomous HWP for package. PR: 245582 Differential Revision: https://reviews.freebsd.org/D24744 Notes: svn path=/head/; revision=368140
* x86: clean up empty lines in .c and .h filesMateusz Guzik2020-09-015-8/+1
| | | | Notes: svn path=/head/; revision=365079
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-2/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* hwpstate_intel(4): Save admin-set EPP/EPB and restore after suspendConrad Meyer2020-02-011-21/+39
| | | | Notes: svn path=/head/; revision=357381
* hwpstate_intel(4): Print failure message only on failureConrad Meyer2020-02-011-2/+4
| | | | | | | X-MFC-With: r357379 Notes: svn path=/head/; revision=357380
* hwpstate_intel(4): Detect and support PKG variantConrad Meyer2020-02-011-10/+53
| | | | | | | | | If package-level control is present, we default to using it. Per-core software control may be enabled by setting the machdep.hwpstate_pkg_ctrl tunable to "0" in loader.conf(5). Notes: svn path=/head/; revision=357379
* hwpstate_intel(4): Add fallback EPP using PERF_BIAS MSRConrad Meyer2020-02-011-10/+55
| | | | | | | | | | Per Intel SDM (Vol 3b Part 2), if HWP indicates EPP (energy-performance preference) is not supported, the hardware instead uses the ENERGY_PERF_BIAS MSR. In the epp sysctl handler, fall back to that MSR if HWP does not support EPP and CPUID indicates the ENERGY_PERF_BIAS MSR is supported. Notes: svn path=/head/; revision=357378