Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Feb 2011 23:57:38 GMT
From:      Thomas Bach <bachth@uni-mainz.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/154474: [PATCH] cpupowerd cannot calculate FIDs from dev.cpu.x.freq_levels
Message-ID:  <201102022357.p12Nvc2x044881@red.freebsd.org>
Resent-Message-ID: <201102030000.p1300ROH082300@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         154474
>Category:       ports
>Synopsis:       [PATCH] cpupowerd cannot calculate FIDs from dev.cpu.x.freq_levels
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 03 00:00:26 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Bach
>Release:        8.2-PRERELEASE
>Organization:
>Environment:
# uname -a
FreeBSD taris.fritz.box 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Sun Jan 30 14:50:11 CET 2011     root@taris.fritz.box:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
cpupword tries to determine FIDs from the frequencies from dev.cpu.x.freq_levels
which reports wrong levels:

# sysctl dev.cpu.0.freq_levels
dev.cpu.0.freq_levels: 2500/50000 2400/46099 2200/38878 2000/32400 1800/26625 1575/23296 1350/19968 1125/16640 1000/12800 875/11200 750/9600 625/8000 500/6400 375/4800 250/3200 125/1600

to calculate the actual fid it executes:
# grep '\-\ 8' *
msr_amd.c:	*fid = (frequency/100) - 8;

Returning '-7' when coming to the frequency 125:
# /usr/local/sbin/cpupowerd -s
cpupowerd 0.2.1 written by Markus Strobl.
WARNING: This program could cause damage to your Hardware!
FID (-7) out of range!
Initialisation failed!


>How-To-Repeat:
Running 'cpupowerd -s' on an amd64

# cat /usr/compat/linux/proc/cpuinfo 
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 1
model name	: AMD Athlon(tm) Dual Core Processor 4850e
stepping	: 2
processor	: 1
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 1
model name	: AMD Athlon(tm) Dual Core Processor 4850e
stepping	: 2
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 b19 mmx fxsr xmm sse2
cpu MHz		: 2506.52
bogomips	: 2506.52

(Yet I don't know how to extract the information with freebsd commands :P)
>Fix:
dev.powernow.0.freq_settings gives the right possible frequencies on my system/cpu.

So the quick fix is to change the line
snprintf(levels_sysctl, sizeof(levels_sysctl), "dev.cpu.%d.freq_levels", mastercpuid);

to
snprintf(levels_sysctl, sizeof(levels_sysctl), "dev.powernow.%d.freq_settings", mastercpuid);

# diff /tmp/cpu_bsd.c cpu_bsd.c
426c426
< 	snprintf(levels_sysctl, sizeof(levels_sysctl), "dev.powernow.%d.freq_settings", mastercpuid);
---
> 	snprintf(levels_sysctl, sizeof(levels_sysctl), "dev.cpu.%d.freq_levels", mastercpuid);

Anyway, having dev.cpu.0.freq_levels reporting the right frequencies would be much cleaner.

>Release-Note:
>Audit-Trail:
>Unformatted:



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