Date: Fri, 06 Feb 2026 16:29:19 +0000 From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 461bac05a145 - main - hwpstate_amd(4): Rename EPP handler, convert to unsigned int Message-ID: <698616df.1e8c0.10f4dd35@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=461bac05a1454e8a1656cc35f1308cbd6b374f51 commit 461bac05a1454e8a1656cc35f1308cbd6b374f51 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2026-01-29 14:06:08 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2026-02-06 16:27:32 +0000 hwpstate_amd(4): Rename EPP handler, convert to unsigned int '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 --- sys/x86/cpufreq/hwpstate_amd.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c index c31bde247aaa..d0eccf0d3eaa 100644 --- a/sys/x86/cpufreq/hwpstate_amd.c +++ b/sys/x86/cpufreq/hwpstate_amd.c @@ -316,7 +316,7 @@ out: } static void -sysctl_epp_select_per_core(device_t hwp_device, uint32_t val) +set_epp(device_t hwp_device, u_int val) { struct hwpstate_softc *sc; @@ -331,15 +331,15 @@ sysctl_epp_select_per_core(device_t hwp_device, uint32_t val) } static int -sysctl_epp_select(SYSCTL_HANDLER_ARGS) +sysctl_epp_handler(SYSCTL_HANDLER_ARGS) { device_t dev, hwp_dev; devclass_t dc; struct hwpstate_softc *sc; - const uint32_t max_energy_perf = + const u_int max_epp = BITS_VALUE(AMD_CPPC_REQUEST_EPP_BITS, (uint64_t)-1); - uint32_t val; - int ret = 0; + u_int val; + int error = 0; int cpu; dev = oidp->oid_arg1; @@ -349,29 +349,27 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS) check_cppc_enabled(sc, __func__); val = BITS_VALUE(AMD_CPPC_REQUEST_EPP_BITS, sc->req) * 100 / - max_energy_perf; - ret = sysctl_handle_int(oidp, &val, 0, req); - if (ret != 0 || req->newptr == NULL) + max_epp; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) goto end; if (val > 100) { - ret = EINVAL; + error = EINVAL; goto end; } - val = (val * max_energy_perf) / 100; + val = (val * max_epp) / 100; if (hwpstate_pkg_ctrl_enable) { dc = devclass_find(HWP_AMD_CLASSNAME); - KASSERT(dc != NULL, - (HWP_AMD_CLASSNAME ": devclass cannot be null")); CPU_FOREACH(cpu) { hwp_dev = devclass_get_device(dc, cpu); - sysctl_epp_select_per_core(hwp_dev, val); + set_epp(hwp_dev, val); } } else - sysctl_epp_select_per_core(dev, val); + set_epp(dev, val); end: - return (ret); + return (error); } static driver_t hwpstate_driver = { @@ -786,8 +784,8 @@ hwpstate_attach(device_t dev) SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, - "epp", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, dev, 0, - sysctl_epp_select, "I", + "epp", CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, dev, 0, + sysctl_epp_handler, "IU", "Efficiency/Performance Preference " "(range from 0, most performant, through 100, most efficient)"); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?698616df.1e8c0.10f4dd35>
