Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F166853362
D54528.id169067.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D54528.id169067.diff
View Options
diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c
--- a/sys/x86/cpufreq/hwpstate_amd.c
+++ b/sys/x86/cpufreq/hwpstate_amd.c
@@ -161,23 +161,9 @@
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");
-
static bool hwpstate_pstate_limit;
-SYSCTL_BOOL(_debug, OID_AUTO, hwpstate_pstate_limit, CTLFLAG_RWTUN,
- &hwpstate_pstate_limit, 0,
- "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 device_method_t hwpstate_methods[] = {
/* Device interface */
@@ -376,7 +362,44 @@
sizeof(struct hwpstate_softc),
};
-DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, 0, 0);
+static struct sysctl_ctx_list sysctl_ctx;
+
+static int
+hwpstate_modevent(struct module *mod, int what, void *arg __unused)
+{
+ if (cpu_vendor_id != CPU_VENDOR_AMD &&
+ cpu_vendor_id != CPU_VENDOR_HYGON)
+ return (0);
+
+ switch (what) {
+ case MOD_LOAD:
+ sysctl_ctx_init(&sysctl_ctx);
+ SYSCTL_ADD_INT(&sysctl_ctx, SYSCTL_CHILDREN(&sysctl___debug),
+ OID_AUTO, "hwpstate_verify", CTLFLAG_RWTUN,
+ &hwpstate_verify, 0, "Verify P-state after setting");
+ SYSCTL_ADD_INT(&sysctl_ctx, SYSCTL_CHILDREN(&sysctl___debug),
+ OID_AUTO, "hwpstate_verbose", CTLFLAG_RWTUN,
+ &hwpstate_verbose, 0, "Debug hwpstate");
+ SYSCTL_ADD_BOOL(&sysctl_ctx, SYSCTL_CHILDREN(&sysctl___debug),
+ OID_AUTO, "hwpstate_pstate_limit", CTLFLAG_RWTUN,
+ &hwpstate_pstate_limit, 0,
+ "If enabled (1), limit administrative control of P-states to the value in "
+ "CurPstateLimit");
+ SYSCTL_ADD_BOOL(&sysctl_ctx, SYSCTL_CHILDREN(&sysctl___machdep),
+ OID_AUTO, "hwpstate_pkg_ctrl", CTLFLAG_RDTUN,
+ &hwpstate_pkg_ctrl_enable, 0,
+ "Set 1 (default) to enable package-level control, 0 to disable");
+ break;
+ case MOD_UNLOAD:
+ case MOD_SHUTDOWN:
+ sysctl_ctx_free(&sysctl_ctx);
+ break;
+ }
+
+ return (0);
+}
+
+DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, hwpstate_modevent, 0);
static int
hwpstate_amd_iscale(int val, int div)
diff --git a/sys/x86/cpufreq/hwpstate_intel.c b/sys/x86/cpufreq/hwpstate_intel.c
--- a/sys/x86/cpufreq/hwpstate_intel.c
+++ b/sys/x86/cpufreq/hwpstate_intel.c
@@ -55,6 +55,8 @@
extern uint64_t tsc_freq;
+static bool hwpstate_pkg_ctrl_enable = true;
+
static int intel_hwpstate_probe(device_t dev);
static int intel_hwpstate_attach(device_t dev);
static int intel_hwpstate_detach(device_t dev);
@@ -105,13 +107,34 @@
sizeof(struct hwp_softc),
};
-DRIVER_MODULE(hwpstate_intel, cpu, hwpstate_intel_driver, NULL, NULL);
-MODULE_VERSION(hwpstate_intel, 1);
+static struct sysctl_ctx_list sysctl_ctx;
-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
+hwpstate_modevent(struct module *mod, int what, void *arg __unused)
+{
+ if (cpu_vendor_id != CPU_VENDOR_INTEL)
+ return (0);
+
+ switch (what) {
+ case MOD_LOAD:
+ sysctl_ctx_init(&sysctl_ctx);
+ SYSCTL_ADD_BOOL(&sysctl_ctx, SYSCTL_CHILDREN(&sysctl___machdep),
+ OID_AUTO, "hwpstate_pkg_ctrl", CTLFLAG_RDTUN,
+ &hwpstate_pkg_ctrl_enable, 0,
+ "Set 1 (default) to enable package-level control, 0 to disable");
+ break;
+ case MOD_UNLOAD:
+ case MOD_SHUTDOWN:
+ sysctl_ctx_free(&sysctl_ctx);
+ break;
+ }
+
+ return (0);
+}
+
+DRIVER_MODULE(hwpstate_intel, cpu, hwpstate_intel_driver, hwpstate_modevent,
+ NULL);
+MODULE_VERSION(hwpstate_intel, 1);
static int
intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 3:35 AM (12 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36883745
Default Alt Text
D54528.id169067.diff (4 KB)
Attached To
Mode
D54528: hwpstate{_amd,intel}(4): Move common knobs to a separate file
Attached
Detach File
Event Timeline
Log In to Comment