From nobody@FreeBSD.org  Tue Apr 17 10:03:52 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A7024106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Apr 2012 10:03:52 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 7914D8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Apr 2012 10:03:52 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q3HA3qIb098348
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Apr 2012 10:03:52 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q3HA3qW6098331;
	Tue, 17 Apr 2012 10:03:52 GMT
	(envelope-from nobody)
Message-Id: <201204171003.q3HA3qW6098331@red.freebsd.org>
Date: Tue, 17 Apr 2012 10:03:52 GMT
From: Jens Link <jens.link@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hwpstate0: set freq failed with AMD FX(tm)-8120 Eight-Core Processor
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         167018
>Category:       kern
>Synopsis:       [hwpmc] [patch] hwpstate0: set freq failed with AMD FX(tm)-8120 Eight-Core Processor
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 17 10:10:01 UTC 2012
>Closed-Date:    Wed Nov 06 23:31:01 UTC 2013
>Last-Modified:  Thu Dec  5 18:00:00 UTC 2013
>Originator:     Jens Link
>Release:        FreeBSD 9.0-STABLE
>Organization:
privat
>Environment:
FreeBSD honk.mylink-net.de 9.0-STABLE FreeBSD 9.0-STABLE #6: Thu Apr 12 19:03:51 CEST 2012     root@honk.mylink-net.de:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
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

>Fix:


>Release-Note:
>Audit-Trail:

From: Jens Link <jens.link@gmx.de>
To: bug-followup@FreeBSD.org, jens.link@gmx.de
Cc:  
Subject: Re: kern/167018: [hwpmc] hwpstate0: set freq failed with AMD FX(tm)-8120
 Eight-Core Processor
Date: Mon, 04 Jun 2012 11:26:12 +0200

 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.

From: Bengt Ahlgren <bengta@sics.se>
To: bug-followup@FreeBSD.org, jens.link@gmx.de
Cc: avg@FreeBSD.org
Subject: Re: kern/167018: [hwpmc] [patch] hwpstate0: set freq failed with AMD FX(tm)-8120 Eight-Core Processor
Date: Tue, 09 Apr 2013 15:17:58 +0200

 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
Responsible-Changed-From-To: freebsd-bugs->hiren 
Responsible-Changed-By: hiren 
Responsible-Changed-When: Mon May 6 20:12:49 UTC 2013 
Responsible-Changed-Why:  
Will talk to avg@ and get closure on this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167018 

From: r4721@tormail.org
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/167018: [hwpmc] [patch] hwpstate0: set freq failed with AMD
 FX(tm)-8120 Eight-Core Processor
Date: Mon, 6 May 2013 21:13:41 -0000

 ------=_20130506211341_11950
 Content-Type: text/plain; charset="iso-8859-1"
 Content-Transfer-Encoding: 8bit
 
 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.
 ------=_20130506211341_11950
 Content-Type: text/plain; name="hwpstate.txt"
 Content-Transfer-Encoding: 8bit
 Content-Disposition: attachment; filename="hwpstate.txt"
 
 Index: sys/x86/cpufreq/hwpstate.c
 ===================================================================
 --- sys/x86/cpufreq/hwpstate.c	(revision 250078)
 +++ sys/x86/cpufreq/hwpstate.c	(working copy)
 @@ -184,16 +184,21 @@
  			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) {
 ------=_20130506211341_11950--
 
 
Responsible-Changed-From-To: hiren->freebsd-bugs 
Responsible-Changed-By: hiren 
Responsible-Changed-When: Wed Oct 30 17:57:01 UTC 2013 
Responsible-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=167018 

From: hiren panchasara <hiren@FreeBSD.org>
To: bug-followup@FreeBSD.org, jens.link@gmx.de
Cc:  
Subject: Re: kern/167018: [hwpmc] [patch] hwpstate0: set freq failed with AMD
 FX(tm)-8120 Eight-Core Processor
Date: Wed, 30 Oct 2013 10:56:02 -0700

 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.
State-Changed-From-To: open->closed 
State-Changed-By: sbruno 
State-Changed-When: Wed Nov 6 23:29:55 UTC 2013 
State-Changed-Why:  
Patches from avg@ applied to resolve this P/R 
http://lists.freebsd.org/pipermail/freebsd-stable/2012-May/067758.html 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167018 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/167018: commit references a PR
Date: Wed,  6 Nov 2013 23:29:37 +0000 (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"
 

From: Kubilay Kocak <koobs.freebsd@gmail.com>
To: bug-followup@FreeBSD.org, jens.link@gmx.de
Cc: sbruno@freebsd.org, Adrian Chadd <adrian@freebsd.org>
Subject: Re: kern/167018: [hwpmc] [patch] hwpstate0: set freq failed with
 AMD FX(tm)-8120 Eight-Core Processor
Date: Fri, 06 Dec 2013 01:17:48 +1100

 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
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/167018: commit references a PR
Date: Thu,  5 Dec 2013 17:57:58 +0000 (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"
 
>Unformatted:
