diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2026-01-29 10:48:55 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2026-02-06 16:27:32 +0000 |
| commit | fa0512f7156d1851a7d498d42c32655e390399cf (patch) | |
| tree | c61aae424f9df36add58f0b1370b710beef3d6a2 | |
| parent | e938d57e0a8852e956a16dd4fc041047fd1b2c35 (diff) | |
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
| -rw-r--r-- | sys/x86/cpufreq/hwpstate_amd.c | 15 |
1 files 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; |
