Bug 167018 - [hwpmc] [patch] hwpstate0: set freq failed with AMD FX(tm)-8120 Eight-Core Processor
Summary: [hwpmc] [patch] hwpstate0: set freq failed with AMD FX(tm)-8120 Eight-Core Pr...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-17 11:10 UTC by jens.link
Modified: 2013-12-05 18:00 UTC (History)
0 users

See Also:


Attachments
hwpstate.txt (853 bytes, text/plain)
2013-05-06 22:13 UTC, r4721@tormail.org
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jens.link 2012-04-17 11:10:01 UTC
When I start the powerd daemon I get a lot of kernel messages:

hwpstate0: set freq failed, err 6

The cpufreq works as I can seen in kernel messages with hwpmc.ko loaded:

hwpstate0: going to fetch info from acpi_perf
hwpstate0: <Cool`n'Quiet 2.0> on cpu0
hwpmc: TSC/1/64/0x20<REA> K8/4/48/0x1ff<INT,USR,SYS,EDG,THR,REA,WRI,INV,QUA>

and I get the sysctl variables:

dev.cpu.0.freq: 1400
dev.cpu.0.freq_levels: 3100/14210 2800/12250 2450/10718 2300/8677 2012/7592 1900/5431 1662/4752 1425/4073 1400/3558 1225/3113 1050/2668 875/2223 700/1779 525/1334 350/889 175/444

I also test to set "hint.acpi_throttle.0.disabled=1" in boot/loader.conf,
but this only reduce the frequency

dev.cpu.0.freq_levels: 3100/14210 2800/12250 2300/8677 1900/5431 1400/3558

that's exactly the same what 

dev.hwpstate.0.freq_settings: 3100/14210 2800/12250 2300/8677 1900/5431 1400/3558

have. But the error is still there. So I try "debug.hwpstate_verbose=1"
and get now

hwpstate0: setting P1-state on cpu0
hwpstate0: result  P0-state on cpu0
hwpstate0: error: loop is not enough.
hwpstate0: setting P1-state on cpu1
hwpstate0: result  P1-state on cpu1
hwpstate0: setting P1-state on cpu2
hwpstate0: result  P0-state on cpu2
hwpstate0: error: loop is not enough.
hwpstate0: setting P1-state on cpu3
hwpstate0: result  P1-state on cpu3
hwpstate0: setting P1-state on cpu4
hwpstate0: result  P0-state on cpu4
hwpstate0: error: loop is not enough.
hwpstate0: setting P1-state on cpu5
hwpstate0: result  P1-state on cpu5
hwpstate0: setting P1-state on cpu6
hwpstate0: result  P0-state on cpu6
hwpstate0: error: loop is not enough.
hwpstate0: setting P1-state on cpu7
hwpstate0: result  P1-state on cpu7
hwpstate0: set freq failed, err 6

and so on. Then I try to increase the loop in "src/sys/x86/cpufreq/hwpstate.c"
without success. I don't have any Idee now to fix. May something is missing
in the hwpmc code for the CPU or is this only a result from a buggy bios
with incomplete acpi cpu code? Can anybody confirm that the powerd is working
correctly with this CPU on an other Mainboard than the MSI 870A-G54 (FX)?

How-To-Repeat: Start powerd with an AMD 8 Core FX 8120 CPU
Comment 1 jens.link 2012-06-04 10:26:12 UTC
The patch from Andriy Gapon and Yamagi discussed at freebsd-stabe

http://lists.freebsd.org/pipermail/freebsd-stable/2012-May/067758.html

fix the problem for me now.
Comment 2 Bengt Ahlgren 2013-04-09 14:17:58 UTC
Andriy's patch
http://lists.freebsd.org/pipermail/freebsd-stable/2012-May/067758.html
fixes the issue for me as well on a DELL R515 with two AMD Opteron(tm)
4386 processors, with in total 16 cores.

Perhaps commit to head?

Bengt
Comment 3 Hiren Panchasara freebsd_committer 2013-05-06 21:12:49 UTC
Responsible Changed
From-To: freebsd-bugs->hiren

Will talk to avg@ and get closure on this one.
Comment 4 r4721@tormail.org 2013-05-06 22:13:41 UTC
this patch has been working to stop hwpstate0 errors on AMD A8-5500 4-core
cpu.

patch from list is being reposted here as attachment for easier download
for applying.
Comment 5 Hiren Panchasara freebsd_committer 2013-10-30 17:56:02 UTC
Firstly, sorry for holding on to this PR for so long.

I feel the patch is correct but I no longer have any AMD to test
myself. If someone feels strongly, he/she can go ahead and commit
this.

I will put this back in the queue.
Comment 6 Hiren Panchasara freebsd_committer 2013-10-30 17:57:01 UTC
Responsible Changed
From-To: hiren->freebsd-bugs
Comment 7 dfilter service freebsd_committer 2013-11-06 23:29:37 UTC
Author: sbruno
Date: Wed Nov  6 23:29:25 2013
New Revision: 257769
URL: http://svnweb.freebsd.org/changeset/base/257769

Log:
  Fix powerd/states on AMD cpus.  Resolves issues with system reporting:
  hwpstate0: set freq failed, err 6
  
  Tested on FX-8150 and others.
  
  PR:		167018
  Submitted by:	avg
  MFC after:	2 weeks

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

Modified: head/sys/x86/cpufreq/hwpstate.c
==============================================================================
--- head/sys/x86/cpufreq/hwpstate.c	Wed Nov  6 22:36:36 2013	(r257768)
+++ head/sys/x86/cpufreq/hwpstate.c	Wed Nov  6 23:29:25 2013	(r257769)
@@ -184,16 +184,21 @@ hwpstate_goto_pstate(device_t dev, int p
 			id, PCPU_GET(cpuid));
 		/* Go To Px-state */
 		wrmsr(MSR_AMD_10H_11H_CONTROL, id);
+	}
+	CPU_FOREACH(i) {
+		/* Bind to each cpu. */
+		thread_lock(curthread);
+		sched_bind(curthread, i);
+		thread_unlock(curthread);
 		/* wait loop (100*100 usec is enough ?) */
 		for(j = 0; j < 100; j++){
+			/* get the result. not assure msr=id */
 			msr = rdmsr(MSR_AMD_10H_11H_STATUS);
 			if(msr == id){
 				break;
 			}
 			DELAY(100);
 		}
-		/* get the result. not assure msr=id */
-		msr = rdmsr(MSR_AMD_10H_11H_STATUS);
 		HWPSTATE_DEBUG(dev, "result  P%d-state on cpu%d\n",
 		    (int)msr, PCPU_GET(cpuid));
 		if (msr != id) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 8 Sean Bruno freebsd_committer 2013-11-06 23:29:55 UTC
State Changed
From-To: open->closed

Patches from avg@ applied to resolve this P/R 
http://lists.freebsd.org/pipermail/freebsd-stable/2012-May/067758.html
Comment 9 koobs 2013-12-05 14:17:48 UTC
sbruno@ mentioned via IRC he has already sent a merge request for this
to re@, and as such doesn't require another PR to be opened [1]

Thanks Sean!

[1]
http://lists.freebsd.org/pipermail/freebsd-stable/2013-December/076107.html
Comment 10 dfilter service freebsd_committer 2013-12-05 17:57:58 UTC
Author: sbruno
Date: Thu Dec  5 17:57:51 2013
New Revision: 258994
URL: http://svnweb.freebsd.org/changeset/base/258994

Log:
  MFC r257769 to stable/10
  
  Fix powerd/states on AMD cpus.  Resolves issues with system reporting:
  hwpstate0: set freq failed, err 6
  
  Tested on FX-8150 and others.
  
  PR:		kern/167018
  Submitted by:	avg@
  Approved by:	re (gjb)

Modified:
  stable/10/sys/x86/cpufreq/hwpstate.c
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/x86/cpufreq/hwpstate.c
==============================================================================
--- stable/10/sys/x86/cpufreq/hwpstate.c	Thu Dec  5 17:50:18 2013	(r258993)
+++ stable/10/sys/x86/cpufreq/hwpstate.c	Thu Dec  5 17:57:51 2013	(r258994)
@@ -184,16 +184,21 @@ hwpstate_goto_pstate(device_t dev, int p
 			id, PCPU_GET(cpuid));
 		/* Go To Px-state */
 		wrmsr(MSR_AMD_10H_11H_CONTROL, id);
+	}
+	CPU_FOREACH(i) {
+		/* Bind to each cpu. */
+		thread_lock(curthread);
+		sched_bind(curthread, i);
+		thread_unlock(curthread);
 		/* wait loop (100*100 usec is enough ?) */
 		for(j = 0; j < 100; j++){
+			/* get the result. not assure msr=id */
 			msr = rdmsr(MSR_AMD_10H_11H_STATUS);
 			if(msr == id){
 				break;
 			}
 			DELAY(100);
 		}
-		/* get the result. not assure msr=id */
-		msr = rdmsr(MSR_AMD_10H_11H_STATUS);
 		HWPSTATE_DEBUG(dev, "result  P%d-state on cpu%d\n",
 		    (int)msr, PCPU_GET(cpuid));
 		if (msr != id) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"