hwpstate{_amd,intel}(4): Move common knobs to a separate file

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:          3e6e4e4a0d ("hwpstate: add CPPC support for pstate driver on AMD")
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D54528
This commit is contained in:
Olivier Certner
2026-02-06 11:58:07 +01:00
parent 1a446f765d
commit 8043295875
6 changed files with 41 additions and 15 deletions
+1
View File
@@ -342,6 +342,7 @@ x86/acpica/srat.c optional acpi
x86/bios/vpd.c optional vpd
x86/cpufreq/est.c optional cpufreq
x86/cpufreq/hwpstate_amd.c optional cpufreq
x86/cpufreq/hwpstate_common.c optional cpufreq
x86/cpufreq/hwpstate_intel.c optional cpufreq
x86/cpufreq/p4tcc.c optional cpufreq
x86/cpufreq/powernow.c optional cpufreq
+2 -1
View File
@@ -9,7 +9,8 @@ SRCS+= bus_if.h cpufreq_if.h device_if.h pci_if.h
.PATH: ${SRCTOP}/sys/x86/cpufreq
SRCS+= acpi_if.h opt_acpi.h
SRCS+= est.c hwpstate_amd.c p4tcc.c powernow.c hwpstate_intel.c
SRCS+= est.c p4tcc.c powernow.c
SRCS+= hwpstate_amd.c hwpstate_common.c hwpstate_intel.c
.endif
.if ${MACHINE} == "i386"
+2 -9
View File
@@ -68,6 +68,8 @@
#include <dev/acpica/acpivar.h>
#include <x86/cpufreq/hwpstate_common.h>
#include "acpi_if.h"
#include "cpufreq_if.h"
@@ -162,10 +164,6 @@ static int hwpstate_get_info_from_acpi_perf(device_t dev, device_t perf_dev);
static int hwpstate_get_info_from_msr(device_t dev);
static int hwpstate_goto_pstate(device_t dev, int pstate_id);
static int hwpstate_verbose;
SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN,
&hwpstate_verbose, 0, "Debug hwpstate");
static int hwpstate_verify;
SYSCTL_INT(_debug, OID_AUTO, hwpstate_verify, CTLFLAG_RWTUN,
&hwpstate_verify, 0, "Verify P-state after setting");
@@ -176,11 +174,6 @@ SYSCTL_BOOL(_debug, OID_AUTO, hwpstate_pstate_limit, CTLFLAG_RWTUN,
"If enabled (1), limit administrative control of P-states to the value in "
"CurPstateLimit");
static bool hwpstate_pkg_ctrl_enable = true;
SYSCTL_BOOL(_machdep, OID_AUTO, hwpstate_pkg_ctrl, CTLFLAG_RDTUN,
&hwpstate_pkg_ctrl_enable, 0,
"Set 1 (default) to enable package-level control, 0 to disable");
static bool hwpstate_amd_cppc_enable = true;
SYSCTL_BOOL(_machdep, OID_AUTO, hwpstate_amd_cppc_enable, CTLFLAG_RDTUN,
&hwpstate_amd_cppc_enable, 0,
+22
View File
@@ -0,0 +1,22 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2026 The FreeBSD Foundation
*
* This software was developed by Olivier Certner <olce@FreeBSD.org> at Kumacom
* SARL under sponsorship from the FreeBSD Foundation.
*/
#include <sys/sysctl.h>
#include <x86/cpufreq/hwpstate_common.h>
int hwpstate_verbose;
SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN,
&hwpstate_verbose, 0, "Debug hwpstate");
bool hwpstate_pkg_ctrl_enable = true;
SYSCTL_BOOL(_machdep, OID_AUTO, hwpstate_pkg_ctrl, CTLFLAG_RDTUN,
&hwpstate_pkg_ctrl_enable, 0,
"Set 1 (default) to enable package-level control, 0 to disable");
+13
View File
@@ -0,0 +1,13 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2026 The FreeBSD Foundation
*
* This software was developed by Olivier Certner <olce@FreeBSD.org> at Kumacom
* SARL under sponsorship from the FreeBSD Foundation.
*/
/* Stuff common to hwpstate_amd(4) and hwpstate_intel(4). */
extern int hwpstate_verbose;
extern bool hwpstate_pkg_ctrl_enable;
+1 -5
View File
@@ -48,6 +48,7 @@
#include <dev/acpica/acpivar.h>
#include <x86/cpufreq/hwpstate_common.h>
#include <x86/cpufreq/hwpstate_intel_internal.h>
#include "acpi_if.h"
@@ -108,11 +109,6 @@ static driver_t hwpstate_intel_driver = {
DRIVER_MODULE(hwpstate_intel, cpu, hwpstate_intel_driver, NULL, NULL);
MODULE_VERSION(hwpstate_intel, 1);
static bool hwpstate_pkg_ctrl_enable = true;
SYSCTL_BOOL(_machdep, OID_AUTO, hwpstate_pkg_ctrl, CTLFLAG_RDTUN,
&hwpstate_pkg_ctrl_enable, 0,
"Set 1 (default) to enable package-level control, 0 to disable");
static int
intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
{