Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Feb 2020 19:45:28 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357376 - head/sys/x86/cpufreq
Message-ID:  <202002011945.011JjSBY021398@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Sat Feb  1 19:45:27 2020
New Revision: 357376
URL: https://svnweb.freebsd.org/changeset/base/357376

Log:
  hwpstate_intel(4): Error check epp sysctl & bail if HW does not support feature

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==============================================================================
--- head/sys/x86/cpufreq/hwpstate_intel.c	Sat Feb  1 19:40:11 2020	(r357375)
+++ head/sys/x86/cpufreq/hwpstate_intel.c	Sat Feb  1 19:45:27 2020	(r357376)
@@ -218,6 +218,7 @@ raw_to_percent(int x)
 static int
 sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 {
+	struct hwp_softc *sc;
 	device_t dev;
 	struct pcpu *pc;
 	uint64_t requested;
@@ -225,6 +226,10 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 	int ret;
 
 	dev = oidp->oid_arg1;
+	sc = device_get_softc(dev);
+	if (!sc->hwp_pref_ctrl)
+		return (ENODEV);
+
 	pc = cpu_get_pcpu(dev);
 	if (pc == NULL)
 		return (ENXIO);
@@ -233,7 +238,9 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 	sched_bind(curthread, pc->pc_cpuid);
 	thread_unlock(curthread);
 
-	rdmsr_safe(MSR_IA32_HWP_REQUEST, &requested);
+	ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, &requested);
+	if (ret)
+		goto out;
 	val = (requested & IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 24;
 	val = raw_to_percent(val);
 
@@ -253,7 +260,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 	requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
 	requested |= val << 24;
 
-	wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+	ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
 
 out:
 	thread_lock(curthread);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002011945.011JjSBY021398>