git: fa0512f7156d - main - hwpstate_amd(4): Assert PSTATE_CPPC is on in corresponding sysctl handlers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 06 Feb 2026 16:29:18 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=fa0512f7156d1851a7d498d42c32655e390399cf
commit fa0512f7156d1851a7d498d42c32655e390399cf
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-01-29 10:48:55 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-02-06 16:27:32 +0000
hwpstate_amd(4): Assert PSTATE_CPPC is on in corresponding sysctl handlers
No functional change intended.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55001
---
sys/x86/cpufreq/hwpstate_amd.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c
index 9e2d0fcbc8bb..c31bde247aaa 100644
--- a/sys/x86/cpufreq/hwpstate_amd.c
+++ b/sys/x86/cpufreq/hwpstate_amd.c
@@ -202,6 +202,13 @@ static device_method_t hwpstate_methods[] = {
{0, 0}
};
+static inline void
+check_cppc_enabled(const struct hwpstate_softc *const sc, const char *const func)
+{
+ KASSERT((sc->flags & PSTATE_CPPC) != 0, (HWP_AMD_CLASSNAME
+ ": %s() called but PSTATE_CPPC not set", func));
+}
+
struct get_cppc_regs_data {
uint64_t enable;
uint64_t caps;
@@ -270,8 +277,10 @@ sysctl_cppc_dump_handler(SYSCTL_HANDLER_ARGS)
int ret;
sc = (struct hwpstate_softc *)arg1;
- dev = sc->dev;
+ /* Sysctl knob does not exist if PSTATE_CPPC is not set. */
+ check_cppc_enabled(sc, __func__);
+ dev = sc->dev;
pc = cpu_get_pcpu(dev);
if (pc == NULL)
return (ENXIO);
@@ -336,8 +345,8 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
dev = oidp->oid_arg1;
sc = device_get_softc(dev);
- if (!(sc->flags & PSTATE_CPPC))
- return (ENODEV);
+ /* Sysctl knob does not exist if PSTATE_CPPC is not set. */
+ check_cppc_enabled(sc, __func__);
val = BITS_VALUE(AMD_CPPC_REQUEST_EPP_BITS, sc->req) * 100 /
max_energy_perf;