PHC on Ubuntu 9.04

Inform yourself about whats going on with PHC. [READONLY]
User avatar
DavidG
Posts: 180
Joined: Fri 18. Jul 2008, 11:25
Contact:

Re: PHC on Ubuntu 9.04

Post by DavidG » Mon 13. Jul 2009, 13:29

FWIW, the Ubuntu Linux-PHC kernel now contains the phc-k8 patch as well. The driver is compiled as module so can still be overriden by a newer/older version of the driver in the future...
A bank is a place where they lend you an umbrella in fair weather and ask for it back when it begins to rain -- R. Frost

Maya
Posts: 4
Joined: Sun 5. Jul 2009, 20:03

Re: PHC on Ubuntu 9.04

Post by Maya » Wed 15. Jul 2009, 01:42

Hallo,
i have some trouble with the new ppa kernel. I have a 1,73GHz centrino in my notebook and I've been using your paches quite successful for a long time. I recently updated to the 2.6.28-13 kernel from your PPA but now the undervolting is not working anymore. I get the usual error message

Code: Select all

Maya:~$ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls 
cat: /sys/devices/system/cpu/cpu0/cpufreq/phc_controls: No such file or directory
But I can't load the phc-intel module manually, I get the following error:

Code: Select all

Maya:~$ sudo modprobe phc-intel
FATAL: Error inserting phc_intel (/lib/modules/2.6.28-13-generic/extra/phc-intel.ko): Device or resource busy
There is no suspicious module loaded which blocks the device, I think. My lsmod output is

Code: Select all

Maya:~$ lsmod
Module                  Size  Used by
isofs                  39844  0 
udf                    87716  0 
crc_itu_t              10112  1 udf
michael_mic            10496  2 
arc4                    9856  2 
ecb                    10752  2 
ieee80211_crypt_tkip    16896  1 
ieee80211_crypt_ccmp    13440  1 
lrw                    11392  1 
gf128mul               16640  1 lrw
binfmt_misc            16776  1 
ppdev                  15620  0 
radeon                342816  2 
drm                    96296  3 radeon
input_polldev          11912  0 
sbp2                   30476  0 
lp                     17156  0 
parport                42220  2 ppdev,lp
joydev                 18368  0 
snd_intel8x0           37532  3 
snd_ac97_codec        112292  1 snd_intel8x0
ac97_bus                9856  1 snd_ac97_codec
snd_pcm_oss            46336  0 
snd_mixer_oss          22656  1 snd_pcm_oss
snd_pcm                82948  3 snd_intel8x0,snd_ac97_codec,snd_pcm_oss
snd_seq_dummy          10756  0 
pcmcia                 44748  0 
snd_seq_oss            37760  0 
snd_seq_midi           14336  0 
snd_rawmidi            29696  1 snd_seq_midi
snd_seq_midi_event     15104  2 snd_seq_oss,snd_seq_midi
snd_seq                56880  7 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_timer              29704  2 snd_pcm,snd_seq
snd_seq_device         14988  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
iTCO_wdt               19108  0 
iTCO_vendor_support    11652  1 iTCO_wdt
snd                    62628  17 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
soundcore              15200  1 snd
psmouse                61972  0 
intel_agp              34108  0 
yenta_socket           32396  1 
rsrc_nonstatic         19328  1 yenta_socket
snd_page_alloc         16904  2 snd_intel8x0,snd_pcm
pcspkr                 10496  0 
serio_raw              13316  0 
agpgart                42696  2 drm,intel_agp
ipw2200               150984  0 
sdhci_pci              15232  0 
sdhci                  23940  1 sdhci_pci
pcmcia_core            43540  3 pcmcia,yenta_socket,rsrc_nonstatic
video                  25360  0 
ieee80211              38344  1 ipw2200
ieee80211_crypt        13444  3 ieee80211_crypt_tkip,ieee80211_crypt_ccmp,ieee80211
output                 11008  1 video
usbhid                 42336  0 
ohci1394               38576  0 
ieee1394               94660  2 sbp2,ohci1394
tg3                   131204  0 
fbcon                  46112  0 
tileblit               10752  1 fbcon
font                   16384  1 fbcon
bitblit                13824  1 fbcon
softcursor              9984  1 bitblit
sha256_generic         20352  0 
dm_crypt               20996  1 
aes_i586               15744  2 
aes_generic            35880  1 aes_i586
The acpi-cpufreq can't be loaded, too. I get the same error. With the 2.6.28-11 phc kernel everything works without a problem... Thanks for your help and the good patches!

User avatar
DavidG
Posts: 180
Joined: Fri 18. Jul 2008, 11:25
Contact:

Re: PHC on Ubuntu 9.04

Post by DavidG » Thu 16. Jul 2009, 20:47

I assumed the-fallen would react but he may be on holiday ;)

What is the output of:

Code: Select all

dpkg -l linux-image*|grep ^ii
Since you get "Device or resource busy" the cpu is already claimed for cpufreq usage. But the modules are not builtin in the phc kernel, so that's really weird...

Maya
Posts: 4
Joined: Sun 5. Jul 2009, 20:03

Re: PHC on Ubuntu 9.04

Post by Maya » Fri 17. Jul 2009, 09:45

Code: Select all

@Maya:~$ dpkg -l linux-image*|grep ^ii
ii  linux-image-2.6.27-14-generic              2.6.27-14.33                                               Linux kernel image for version 2.6.27 on x86
ii  linux-image-2.6.28-11-generic              2.6.28-11.43~undervolt1                                    Linux kernel image for version 2.6.28 on x86
ii  linux-image-2.6.28-13-generic              2.6.28-13.46~undervolt2                                    Linux kernel image for version 2.6.28 on x86
ii  linux-image-generic                        2.6.28.13.17                                               Generic Linux kernel image
It should be the undervolting kernel...

User avatar
DavidG
Posts: 180
Joined: Fri 18. Jul 2008, 11:25
Contact:

Re: PHC on Ubuntu 9.04

Post by DavidG » Fri 17. Jul 2009, 10:19

Maya wrote: It should be the undervolting kernel...
Yes it should... What is the uname -a output? Is there a "/sys/devices/system/cpu/cpu0/cpufreq" and if so what is in "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver"?
So perhaps the output of this could help:

Code: Select all

uname -a
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
.edit:I cannot check right now, but what does this output:

Code: Select all

grep -e SPEEDSTEP -e CPUFREQ /boot/config-2.6.28-13-generic
grep -e SPEEDSTEP -e CPUFREQ /boot/config-2.6.28-11-generic
A bank is a place where they lend you an umbrella in fair weather and ask for it back when it begins to rain -- R. Frost

Maya
Posts: 4
Joined: Sun 5. Jul 2009, 20:03

Re: PHC on Ubuntu 9.04

Post by Maya » Fri 17. Jul 2009, 15:35

Ok here are the outputs:

Code: Select all

Maya:~$ uname -a
Linux Maya 2.6.28-13-generic #46~undervolt2-Ubuntu SMP Sun Jul 12 01:19:08 UTC 2009 i686 GNU/Linux

Code: Select all

Maya:/sys/devices/system/cpu/cpu0/cpufreq$ ls
affected_cpus     cpuinfo_max_freq  ondemand      scaling_available_frequencies  scaling_cur_freq  scaling_governor  scaling_min_freq  stats cpuinfo_cur_freq  cpuinfo_min_freq  related_cpus  scaling_available_governors    scaling_driver    scaling_max_freq  scaling_setspeed

Code: Select all

@Maya:~$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
centrino

Code: Select all

@Maya:~$ grep -e SPEEDSTEP -e CPUFREQ /boot/config-2.6.28-13-generic
CONFIG_X86_ACPI_CPUFREQ=m
# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
CONFIG_X86_CPUFREQ_NFORCE2=y
CONFIG_X86_SPEEDSTEP_CENTRINO=y
CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
CONFIG_X86_SPEEDSTEP_ICH=y
CONFIG_X86_SPEEDSTEP_LIB=y
CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK=y
CONFIG_X86_SPEEDSTEP_SMI=y

Code: Select all

@Maya:~$ grep -e SPEEDSTEP -e CPUFREQ /boot/config-2.6.28-11-generic
CONFIG_X86_ACPI_CPUFREQ=y
# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
CONFIG_X86_CPUFREQ_NFORCE2=y
CONFIG_X86_SPEEDSTEP_CENTRINO=y
CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
CONFIG_X86_SPEEDSTEP_ICH=y
CONFIG_X86_SPEEDSTEP_LIB=y
CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK=y
CONFIG_X86_SPEEDSTEP_SMI=y
I hope this useful and thanks for your help so far.

/edit: It doesn't change if I set CONFIG_X86_ACPI_CPUFREQ=y in the 28-13 config...

User avatar
DavidG
Posts: 180
Joined: Fri 18. Jul 2008, 11:25
Contact:

Re: PHC on Ubuntu 9.04

Post by DavidG » Fri 17. Jul 2009, 15:48

Thanks, that is most useful, apparently the speedstep-centrino module is still built-in. I've already contacted Raphael about it. So keep an eye on the repository...

raa
Posts: 2
Joined: Tue 21. Jul 2009, 19:07

Re: PHC on Ubuntu 9.04

Post by raa » Tue 21. Jul 2009, 19:24

Hi,

i uploaded a new patched Jaunty Kernel ( linux - 2.6.28-13.46~undervolt3 ) a few days ago. All cpufreq-modules are NOT build in.

Please post feedback.


Greetings
Raphael

Maya
Posts: 4
Joined: Sun 5. Jul 2009, 20:03

Re: PHC on Ubuntu 9.04

Post by Maya » Tue 21. Jul 2009, 22:22

Well, today I updated the kernel (btw. the system update window didn't pop up automatically but nevertheless...) and it worked out of the box without installing any patch or configure something!

Code: Select all

ii  linux-image-2.6.28-13-generic   2.6.28-13.46~undervolt3   Linux kernel image for version 2.6.28 on x86

@Maya:~$ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls 
13:22 10:10 8:5 6:1

@Maya:~$ lsmod | grep phc
phc_intel              19596  0 

@Maya:~$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
acpi-cpufreq
Again thank your all for your help and keep up the good work, you guys are the best!

jasmine
Posts: 7
Joined: Wed 5. Aug 2009, 20:49

Re: PHC on Ubuntu 9.04

Post by jasmine » Wed 5. Aug 2009, 21:55

Regarding the Howto, a few important additions that I felt compelled to add, to save others from having to go through so much trouble like I did (such as recompiling the kernel two or three times in a row):

1. Do not compile the kernel as root, this is a common mistake and will only give you grief later
If you extracted and compiled the kernel in /usr/src/linux-source-x.x.x as root, once your newly created debs are installed (linux-image and linux-headers), you'll notice you have a symlink in /lib/modules/x.x.x/build that points to /usr/src/linux-source-x.x.x instead of /usr/src/linux-headers-x.x.x as it should, which means that if your /usr/src/linux-source ever gets touched, you will be very screwed, cuz you'll have older modules built against a linux-source that has been tampered with, and newly compiled modules will either fail to load (after being compiled) or fail to compile at all...

So do it the proper "debian" way

1a. Add your user account to the "src" group

Code: Select all

$ sudo usermod -a -G src yourusername
That gives yourusername account priviliges to write files in /usr/src directory (the recommended way from debian manual, and what linux kernel developers recommend)

1b. Logout and login again to be recognized in the src group you just been added to

1c. As user, not as root, extract the sources, and make menuconfig (or xconfig if you so choose)

Code: Select all

$ cd /usr/src
$ tar xzf linux-source-x.x.x
$ cd linux-source-x.x.x
$ make menuconfig
See note #2 further below for notes on what needs to be built as modules!!! <- IMPORTANT

1d. Once you're done configuring your kernel, make the deb package with fakeroot make-kpkg (as your username, NOT ROOT) as follows:

Code: Select all

$ fakeroot make-kpkg --initrd --append-to-version=-phc1 --revision=1.0 kernel-image kernel-headers
After that's done, you'll see two files created in the top directory (/usr/src/) like so:

Code: Select all

jas@lappy:/usr/src/linux-source-2.6.30$ cd ..
jas@lappy:/usr/src$ ls *.deb
linux-headers-2.6.30-phc1_1.0_i386.deb  linux-image-2.6.30-phc1_1.0_i386.deb
1e. Out of precaution, I just DELETE OR RENAME /usr/src/linux-source-x.x.x just to MAKE SURE when I install/reinstall the debs, /lib/modules/x.x.x/build WILL NOT point to /usr/src/linux-source-x.x.x instead of /usr/src/linux-headers-x.x.x
example:

Code: Select all

jas@lappy:/usr/src/linux-source-2.6.30$ cd ..
jas@lappy:/usr/src$ mv linux-source-2.6.30 kernel-src-2.6.30
jas@lappy:/usr/src$ dpkg -i linux-*-2.6.30-phc1_1.0_i386.deb
That will install both linux-headers-2.6.30-phc1_1.0_i386.deb linux-image-2.6.30-phc1_1.0_i386.deb
And your /lib/modules/2.6.30-phc1/build symlink will automatically point CORRECTLY to /usr/src/linux-headers-2.6.30-phc1 and will save you a lot of headaches with compiling third-party modules later (such as nvidia, alsa-driver, madwifi-ng, etc..)

Code: Select all

jas@lappy:/usr/src$ ls -l /lib/modules/2.6.30-phc1/build
lrwxrwxrwx 1 root root 34 2009-08-02 21:59 /lib/modules/2.6.30-phc1/build -> /usr/src/linux-headers-2.6.30-phc1
2. In `make menuconfig` (or xconfig if you so chose) MAKE SURE you choose "CPU frequency translation statistics" as a MODULE... by default ubuntu generic kernel, it's compiled IN the kernel (=y) rather than a module... Also enable its sub-option "CPU frequency translation statistics details", so in menuconfig it should look like this:
<M> CPU frequency translation statistics
[ * ] CPU frequency translation statistics details
and in your /boot/config-`uname -r` it should look like this:

Code: Select all

CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
This is really necessay because when you install phc-k8 or phc-intel (via `make dkms_install`), it adds the following lines in your /etc/modules.conf file - in my case this is for phc-k8:

Code: Select all

install powernow-k8 /sbin/modprobe phc-k8 || { /sbin/modprobe --ignore-install powernow-k8; }
remove powernow-k8 /sbin/modprobe -r cpufreq_stats && { /sbin/modprobe --ignore-remove -r powernow-k8 ; }
remove phc-k8 /sbin/modprobe -r cpufreq_stats && { /sbin/modprobe --ignore-remove -r phc-k8 ; }
Which means that to remove phc-k8, you need to remove cpufreq-status module, which won't happen if you have it compiled in the kernel..

I also compiled everything else as modules, just in case (after 2 or 3 kernel compiles, stripped down config of kernel-2.6.30 from Ubuntu Kernel PPA, on Jaunty 9.04):
$ grep -i freq /boot/config-2.6.30-phc1
# CPU Frequency scaling
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_TABLE=m
# CONFIG_CPU_FREQ_DEBUG is not set
CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m
CONFIG_CPU_FREQ_GOV_ONDEMAND=m
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
# CPUFreq processor drivers
CONFIG_X86_ACPI_CPUFREQ=m
# CONFIG_X86_CPUFREQ_NFORCE2 is not set
I didn't really need to add "CONFIG_X86_ACPI_CPUFREQ" built because it's for intel processors, and as I only have an AMD K8, but I added it to the list just to give a more complete example that should work for both AMD & Intel users, but you only need one of them.
For AMD users, you add "powernow-k8" to /etc/modules
For Intel users, you add "acpi-cpufreq" to /etc/modules

That way, the appropriate module for your CPU will load on boot automatically, and if you have installed phc-k8 or phc-intel (`make dkms_install`), the module "install" option that it added automatically for you in /etc/modules.conf should load your phc-k8 or phc-intel module automatically instead, and if you uninstalled phc-k8 or phc-intel (for whatever reason), your normal powernow-k8 or acpi-cpufreq will still start automatically on boot, so you wont forget it... :)

If you built cpufreqstats as a module as recommended, and built all frequency governers as modules like me (I also compiled msr as a module, and also k8temp), you'll additionally need to add the following to your /etc/modules file so that they are loaded automatically for you at boot:
# Chip drivers
k8temp

# CPU Frequency Management
msr
cpufreq_userspace
cpufreq_ondemand
cpufreq_conservative
cpufreq_powersave
cpufreq_stats
powernow-k8
Of course if there are certain cpufreq governors that you never need to use, you can just ommit them from the list and save a few kilobytes of memory... :P
Hope this helps anyone

Cheers

Post Reply