[2.5.39] (3/5) CPUfreq i386 drivers
CPUFreq i386 drivers for 2.5.39:arch/i386/config.in Necessary config optionsarch/i386/kernel/cpu/Makefile allow for compilation of the CPUFreq subdirectoryarch/i386/kernel/cpu/cpufreq/Makefile Makefile for CPUFreq driversarch/i386/kernel/cpu/cpufreq/elanfreq.c CPUFreq driver for AMD Elan processorsarch/i386/kernel/cpu/cpufreq/longhaul.c CPUFreq driver for VIA Longhaul processorsarch/i386/kernel/cpu/cpufreq/longrun.c CPUFreq driver for Transmeta Crusoe processorsarch/i386/kernel/cpu/cpufreq/p4-clockmod.c CPUFreq driver for Pentium 4 Xeon processors (using clock modulation)arch/i386/kernel/cpu/cpufreq/powernow-k6.c CPUFreq driver for mobile AMD K6-2+ and mobile AMD K6-3+ processorsarch/i386/kernel/cpu/cpufreq/speedstep.c CPUFreq drivers for ICH2-M and ICH3-M chipsets and Intel Pentium 3-M and 4-M processors.
arch/i386/config.in +12 -0
@@ -190,6 +190,18 @@ dep_bool 'Check for non-fatal errors on Athlon/Duron' CONFIG_X86_MCE_NONFATAL $CONFIG_X86_MCE dep_bool 'check for P4 thermal throttling interrupt.' CONFIG_X86_MCE_P4THERMAL $CONFIG_X86_MCE $CONFIG_X86_UP_APIC +bool 'CPU Frequency scaling' CONFIG_CPU_FREQ +if [ "$CONFIG_CPU_FREQ" = "y" ]; then + define_bool CONFIG_CPU_FREQ_26_API y + tristate ' AMD Mobile K6-2/K6-3 PowerNow!' CONFIG_X86_POWERNOW_K6 + if [ "$CONFIG_MELAN" = "y" ]; then + tristate ' AMD Elan' CONFIG_ELAN_CPUFREQ + fi + tristate ' VIA Cyrix III Longhaul' CONFIG_X86_LONGHAUL + tristate ' Intel Speedstep' CONFIG_X86_SPEEDSTEP + tristate ' Intel Pentium 4 clock modulation' CONFIG_X86_P4_CLOCKMOD + tristate ' Transmeta LongRun' CONFIG_X86_LONGRUN +fi tristate 'Toshiba Laptop support' CONFIG_TOSHIBA tristate 'Dell laptop support' CONFIG_I8K
arch/i386/kernel/cpu/Makefile +2 -1
@@ -13,6 +13,7 @@ obj-y += nexgen.o obj-y += umc.o -obj-$(CONFIG_MTRR) += mtrr/ +obj-$(CONFIG_MTRR) += mtrr/ +obj-$(CONFIG_CPU_FREQ) += cpufreq/ include $(TOPDIR)/Rules.make
arch/i386/kernel/cpu/cpufreq/Makefile +8 -0
@@ -0,0 +1,8 @@ +obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o +obj-$(CONFIG_X86_LONGHAUL) += longhaul.o +obj-$(CONFIG_X86_SPEEDSTEP) += speedstep.o +obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o +obj-$(CONFIG_ELAN_CPUFREQ) += elanfreq.o +obj-$(CONFIG_X86_LONGRUN) += longrun.o + +include $(TOPDIR)/Rules.make
arch/i386/kernel/cpu/cpufreq/elanfreq.c +336 -0
336 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/longhaul.c +820 -0
820 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/longrun.c +283 -0
283 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +285 -0
285 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/powernow-k6.c +294 -0
294 lines not on this page · raw message
arch/i386/kernel/cpu/cpufreq/speedstep.c +702 -0
702 lines not on this page · raw message
This add-on patch is needed to abort on Dell Inspiron 8000 / 8100 which would lock up during speedstep.c and to resolve an oops (thanks to Hu Gang for reporting this)
Dominik
arch/i386/kernel/cpu/cpufreq/speedstep.c renamed from arch/i386/kernel/cpu/cpufreq/speedstep.c.original +36 -7
@@ -288,9 +288,32 @@PCI_ANY_ID ,PCI_ANY_ID , NULL); -if (speedstep_chipset_dev) -return SPEEDSTEP_CHIPSET_ICH2M ; +if (speedstep_chipset_dev) { +/* speedstep.c causes lockups on Dell Inspirons 8000 and +* 8100 which use a pretty old revision of the 82815 +* host brige. Abort on these systems. +*/ +static struct pci_dev *hostbridge; +u8 rev =0 ; + + hostbridge =pci_find_subsys (PCI_VENDOR_ID_INTEL , +PCI_DEVICE_ID_INTEL_82815_MC , +PCI_ANY_ID , +PCI_ANY_ID , +NULL ); + +if (!hostbridge) +return SPEEDSTEP_CHIPSET_ICH2M ; + +pci_read_config_byte (hostbridge,PCI_REVISION_ID , &rev); +if (rev <5 ) { +dprintk (KERN_INFO "cpufreq: hostbrige does not support speedstep\n" ); + speedstep_chipset_dev =NULL ; +return 0 ; + } +return SPEEDSTEP_CHIPSET_ICH2M ; + }return 0 ; }
@@ -504,6 +527,7 @@static int speedstep_detect_speeds (void ) {unsigned int state; +unsigned int low =0 , high =0 ;int i, result;for (i=0 ; i<2 ; i++) {
@@ -517,29 +541,32 @@switch (speedstep_processor) {case SPEEDSTEP_PROCESSOR_PIII_C :case SPEEDSTEP_PROCESSOR_PIII_T : - speedstep_low_freq =pentium3_get_frequency (); + low =pentium3_get_frequency ();break ;case SPEEDSTEP_PROCESSOR_P4M : - speedstep_low_freq =pentium4_get_frequency (); + low =pentium4_get_frequency (); }speedstep_set_state (SPEEDSTEP_HIGH ); }else {switch (speedstep_processor) {case SPEEDSTEP_PROCESSOR_PIII_C :case SPEEDSTEP_PROCESSOR_PIII_T : - speedstep_high_freq =pentium3_get_frequency (); + high =pentium3_get_frequency ();break ;case SPEEDSTEP_PROCESSOR_P4M : - speedstep_high_freq =pentium4_get_frequency (); + high =pentium4_get_frequency (); }speedstep_set_state (SPEEDSTEP_LOW ); } -if (!speedstep_low_freq || !speedstep_high_freq || +if (!low || !high || (speedstep_low_freq == speedstep_high_freq))return -EIO ; } + speedstep_low_freq = low; + speedstep_high_freq = high; +return 0 ; }
@@ -632,6 +659,8 @@return result;/* detect low and high frequency */ + speedstep_low_freq =100000 ; + speedstep_high_freq =200000 ; result =speedstep_detect_speeds ();if (result)return result;
arch/i386/kernel/cpu/cpufreq/speedstep.c line 564
Quoted 4 lines
arch/i386/kernel/cpu/cpufreq/speedstep.c renamed from arch/i386/kernel/cpu/cpufreq/speedstep.c.original +1
-1-if (!speedstep_low_freq || !speedstep_high_freq || +if (!low || !high || (speedstep_low_freq == speedstep_high_freq))return -EIO ;
This is still obviously broken.
First time through the loop, high and low are 0, one of the two of them gets set and the other is still 0. This !low || !high test is still within the loop so it will drop out with -EIO. I'd been using cpufreq under 2.4 for a while and with the recent updates (profile api), speedstep hasn't started up because of this, or because it was sending bad data into the notifier chains. Your patch here passes bogus data into the notifier chains, which could be bad imho.
If I fix the init by moving the !low || !high test below the loop, and prevent bad data from being passed into the notifier chains, I start getting memory corruption being detected by slab poisioning. This causes an oops during boot and also shortly after load if speedstep is modular.
Also, the irq locking in speedstep.c is rather screwy and redundant in places:
/* Disable IRQs */local_irq_save(flags);local_irq_disable();
. . .
/* Enable IRQs */local_irq_enable();local_irq_restore(flags);
-- Gerald
Quoted 6 lines · Dominik Brodowski
This add-on patch is needed to abort on Dell Inspiron 8000 / 8100 which would lock up during
speedstep.cand to resolve an oops (thanks to Hu Gang for reporting this)Dominik
Wait a minute...
Do I understand you and your patch right?
Dell sells a machine with a Pentium III Mobile CPU with Speedstep technology, and now you tell us that it won't work? Ever? Does this mean that a lot of people (including me) bought a very advanced and expensive piece of trash? Then it's about time that I contact Dell, because they screwed me.
Does Speedstep work on this machine with Windows/XP?
(I never checked, removed it first thing after unpacking the machine.)
Regards,
Toon.
Signature · 4 lines
/"\ | \ / ASCII RIBBON CAMPAIGN | "Who is this General Failure, and X AGAINST HTML MAIL | what is he doing on my harddisk?" / \
Quoted 8 lines · Toon van der Pas
Quoted 6 lines · Dominik Brodowski
This add-on patch is needed to abort on Dell Inspiron 8000 / 8100 which would lock up during
speedstep.cand to resolve an oops (thanks to Hu Gang for reporting this)Dominik
Quoted 7 lines
Wait a minute...
Do I understand you and your patch right?
Dell sells a machine with a Pentium III Mobile CPU with Speedstep technology, and now you tell us that it won't work? Ever? Does this mean that a lot of people (including me) bought a very advanced and expensive piece of trash? Then it's about time that I contact Dell, because they screwed me.
I've been contacted by two Dell Inspiron 8100 users who reported deadlocks when using any cpufreq version on their systems. The reason is that Dell doesn't use the (documented) interface in the ICH2-M southbridge, but (proabably) the ISSCL (Intel SpeedStep Control Logic)-Interface also used on 440?X chipsets. Unfortunately, this interface is not documented - Intel even _removes_ parts of documentation avaialable to the public that could lead to reverse-engineering of the ISSCL-Interface (440 MX Platform Design Guide). So, a "legacy" speedstep driver for 440?X chipsets or Dell Inspiron 8000/8100s is unlikely, at least for the moment.
However, you might have another chance: by using ACPI. The latest ACPI releases for 2.4. as well as the 2.5. tree offers "P-State" support. So if your BIOS' ACPI-tables make these P-States available, you _can_ use speedstep on this notebook. For details on ACPI P-States, please take a look at http://www.brodo.de/english/pub/acpi/proc/processor.html
Quoted 2 lines
Does Speedstep work on this machine with Windows/XP?
(I never checked, removed it first thing after unpacking the machine.)
AFAICT, it does work on the 8100 but not on the 8000.
BTW, just to set things clear: The only computer I own only uses the 440?X / ISSCL-Interface, so I sit in the same boat as you. By developing the ICH2-M/ICH3-M driver I had hoped to find ways to reverse-engineer the "old" speedstep interface; so far I have been unsuccessful, though.
Dominik
Quoted 10 lines · Gerald Britton
arch/i386/kernel/cpu/cpufreq/speedstep.c line 564
Quoted 4 lines
arch/i386/kernel/cpu/cpufreq/speedstep.c renamed from arch/i386/kernel/cpu/cpufreq/speedstep.c.original +1
-1-if (!speedstep_low_freq || !speedstep_high_freq || +if (!low || !high || (speedstep_low_freq == speedstep_high_freq))return -EIO ;This is still obviously broken.
First time through the loop, high and low are 0, one of the two of them gets set and the other is still 0. This !low || !high test is still within the loop so it will drop out with
-EIO.
Oh, thanks for pointing this out. I'll fix it for the next realease.
Quoted 4 lines
I'd been using cpufreq under 2.4 for a while
and with the recent updates (profile api), speedstep hasn't started up because of this, or because it was sending bad data into the notifier chains. Your patch here passes bogus data into the notifier chains, which could be bad imho.
Well, so far the only x86 notifier is the one in arch/i386/kernel/time.c. But yes, you're right, it's bad; and so I'll add a workaround for this, too.
Quoted 3 lines
If I fix the init by moving the !low || !high test below the loop, and prevent bad data from being passed into the notifier chains, I start getting memory corruption being detected by slab poisioning.
Any idea why this is happening??? The only dynamically allocated struct is struct cpfureq_driver driver; and it is only kfree'd in speedstep_exit...
Quoted 7 lines
/* Disable IRQs */
local_irq_save(flags);local_irq_disable();
. . .
/* Enable IRQs */local_irq_enable();local_irq_restore(flags);
Thanks. Fixed.
BTW, unfortunately I can't test speedstep.c locally - my notebook has the old 440?X ISSCL speedstep interface which is undocumented. So I'm really glad whenever others test speedstep.c. Many thanks,
Dominik
Quoted 5 lines · Dominik Brodowski
Quoted 3 lines
If I fix the init by moving the !low || !high test below the loop, and prevent bad data from being passed into the notifier chains, I start getting memory corruption being detected by slab poisioning.
Any idea why this is happening??? The only dynamically allocated struct is struct
cpfureq_driverdriver; and it is only kfree'd inspeedstep_exit...
I think I found the problem: it should be GFP_ATOMIC and not GFP_KERNEL in the allocation of struct cpufreq_driver. Will be fixed in the next release.
Dominik
Quoted 25 lines · Dominik Brodowski
Quoted 6 lines · Toon van der Pas
Quoted 4 lines · Dominik Brodowski
This add-on patch is needed to abort on Dell Inspiron 8000 / 8100 which would lock up during
speedstep.cand to resolve an oops (thanks to Hu Gang for reporting this)Quoted 7 lines
Wait a minute...
Do I understand you and your patch right?
Dell sells a machine with a Pentium III Mobile CPU with Speedstep technology, and now you tell us that it won't work? Ever? Does this mean that a lot of people (including me) bought a very advanced and expensive piece of trash? Then it's about time that I contact Dell, because they screwed me.I've been contacted by two Dell Inspiron 8100 users who reported deadlocks when using any cpufreq version on their systems. The reason is that Dell doesn't use the (documented) interface in the ICH2-M southbridge, but (proabably) the ISSCL (Intel SpeedStep Control Logic)-Interface also used on 440?X chipsets. Unfortunately, this interface is not documented - Intel even _removes_ parts of documentation avaialable to the public that could lead to reverse-engineering of the ISSCL-Interface (440 MX Platform Design Guide). So, a "legacy" speedstep driver for 440?X chipsets or Dell Inspiron 8000/8100s is unlikely, at least for the moment.
Quoted 5 lines
However, you might have another chance: by using ACPI. The latest ACPI releases for 2.4. as well as the 2.5. tree offers "P-State" support. So if your BIOS' ACPI-tables make these P-States available, you _can_ use speedstep on this notebook. For details on ACPI P-States, please take a look at http://www.brodo.de/english/pub/acpi/proc/processor.html
First of all, thanks for your elaborate reply.
It cleared up a lot of things for me.
According to your patch the first accaptable version is 5 while the version of thehost bridge op my Inspiron 8100 appears to be 4, so I'm definitely hit by INTEL's saddening policy. :-(
00:00.0 Host bridge: Intel Corporation 82815 815 Chipset Host Bridge and Memory Controller Hub (rev 04)
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR-
Latency: 0
Region 0: Memory at e8000000 (32-bit, prefetchable) [size=64M]
Capabilities: [88] #09 [e104]
Capabilities: [a0] AGP version 2.0
Status: RQ=31 SBA+ 64bit- FW- Rate=x1,x2
Command: RQ=0 SBA+ AGP+ 64bit- FW- Rate=x1But my current home-baked 2.4.18 kernel with a fairly old acpi-version already appears to support the acpi P-state support you mention. It seems to work. No throttling support though. I'm less than thrilled by the power management support of this laptop and the SpeedStep policy of INTEL. (yes, it's more of a (marketing) policy than a technology, in my opinion)
[toon@roach toon]$ uname -a
Linux roach.hobby.nl 2.4.18-rc4-rmap12h-acpi20020503-pciirq.17.acpi #2 do mei 9 21:21:22 GMT+1 2002 i686 unknown [root@roach toon]# cat /proc/acpi/processor/CPU0/performance
state count: 2
active state: P0
states:
*P0: 1000 Mhz, 15800 mW, 500 uS
P1: 733 Mhz, 12500 mW, 500 uSRegards,
Toon.
Signature · 4 lines
/"\ | \ / ASCII RIBBON CAMPAIGN | "Who is this General Failure, and X AGAINST HTML MAIL | what is he doing on my harddisk?" / \
Quoted 2 lines · Dominik Brodowski
I think I found the problem: it should be
GFP_ATOMICand notGFP_KERNELin the allocation of structcpufreq_driver. Will be fixed in the next release.
Nope. That should be fine, it's in a process context and not holding any locks, so GFP_KERNEL should be fine. I found the bug though:
-driver->policy = (struct cpufreq_policy *) (driver + sizeof(struct cpufreq_driver)); +driver->policy = (struct cpufreq_policy *) (driver + 1);
Remember your pointer arithmetic.
I was also thinking about the quirkyness with the init process and safety with other code. I'm currently running with a modified version adding a "notify" argument to speedstep_set_state() so that notifiers which is 0 during init so that the notifiers do not get run. We're going to be flapping the speed here without notifying anything, so i disabled interrupts for the entire detection process. It appears to be working reasonably well. Patch below (also includes some cleaned up irq locking and the timer.c fix).
Also, the notifier in timer.c is wrong. it updates the per-cpu loops_per_jiffy with the global loops_per_jiffy value (which may have already been scaled).
Also.. these adjusted values have rounding errors...
cpu MHz : 1132.403
cpu MHz : 732.731
cpu MHz : 1132.402
cpu MHz : 732.730
cpu MHz : 1132.400
cpu MHz : 732.729
cpu MHz : 1132.399
There probably isn't a lot that can be done about these unfortunately, but they won't necessarily converge to a stable value so things may eventually start to fail.
-- Gerald
arch/i386/kernel/speedstep.c renamed from arch/i386/kernel/speedstep.c.old +33 -31
@@ -91,6 +91,7 @@*/ static int speedstep_get_state (unsigned int *state) { +unsigned long flags;u32 pmbase;u8 value;
@@ -110,9 +111,9 @@return -EIO ;/* read state */ -local_irq_disable (); +local_irq_save (flags); value =inb (pmbase +0x50 ); -local_irq_enable (); +local_irq_restore (flags);dprintk (KERN_DEBUG "cpufreq: read at pmbase 0x%x + 0x50 returned 0x%x\n" , pmbase, value);
@@ -132,7 +133,7 @@* * Tries to change the SpeedStep state. */ -static void speedstep_set_state (unsigned int state) +static void speedstep_set_state (unsigned int state,int notify) {u32 pmbase;u8 pm2_blk;
@@ -154,7 +155,8 @@ freqs.new = (state ==SPEEDSTEP_HIGH ) ? speedstep_high_freq : speedstep_low_freq; freqs.cpu =CPUFREQ_ALL_CPUS ;/* speedstep.c is UP only driver */ -cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); +if (notify) +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE );switch (speedstep_chipset) {case SPEEDSTEP_CHIPSET_ICH2M :
@@ -173,10 +175,11 @@return ; } +/* Disable IRQs */ +local_irq_save (flags); +/* read state */ -local_irq_disable (); value =inb (pmbase +0x50 ); -local_irq_enable ();dprintk (KERN_DEBUG "cpufreq: read at pmbase 0x%x + 0x50 returned 0x%x\n" , pmbase, value);
@@ -186,10 +189,6 @@dprintk (KERN_DEBUG "cpufreq: writing 0x%x to pmbase 0x%x + 0x50\n" , value, pmbase); -/* Disable IRQs */ -local_irq_save (flags); -local_irq_disable (); -/* Disable bus master arbitration */ pm2_blk =inb (pmbase +0x20 ); pm2_blk |=0x01 ;
@@ -202,14 +201,11 @@ pm2_blk &=0xfe ;outb (pm2_blk, (pmbase +0x20 )); -/* Enable IRQs */ -local_irq_enable (); -local_irq_restore (flags); -/* check if transition was sucessful */ -local_irq_disable (); value =inb (pmbase +0x50 ); -local_irq_enable (); + +/* Enable IRQs */ +local_irq_restore (flags);dprintk (KERN_DEBUG "cpufreq: read at pmbase 0x%x + 0x50 returned 0x%x\n" , pmbase, value);
@@ -223,7 +219,8 @@printk (KERN_ERR "cpufreq: setting CPU frequency on this chipset unsupported.\n" ); } -cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE ); +if (notify) +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );return ; }
@@ -291,7 +288,6 @@if (speedstep_chipset_dev)return SPEEDSTEP_CHIPSET_ICH2M ; -return 0 ; }
@@ -503,9 +499,13 @@*/ static int speedstep_detect_speeds (void ) { +unsigned long flags;unsigned int state;int i, result; - + +/* Disable irqs for entire detection process */ +local_irq_save (flags); +for (i=0 ; i<2 ; i++) {/* read the current state */ result =speedstep_get_state (&state);
@@ -522,7 +522,7 @@case SPEEDSTEP_PROCESSOR_P4M : speedstep_low_freq =pentium4_get_frequency (); } -speedstep_set_state (SPEEDSTEP_HIGH ); +speedstep_set_state (SPEEDSTEP_HIGH ,0 ); }else {switch (speedstep_processor) {case SPEEDSTEP_PROCESSOR_PIII_C :
@@ -532,14 +532,16 @@case SPEEDSTEP_PROCESSOR_P4M : speedstep_high_freq =pentium4_get_frequency (); } -speedstep_set_state (SPEEDSTEP_LOW ); +speedstep_set_state (SPEEDSTEP_LOW ,0 ); } - -if (!speedstep_low_freq || !speedstep_high_freq || - (speedstep_low_freq == speedstep_high_freq)) -return -EIO ; } +local_irq_restore (flags); + +if (!speedstep_low_freq || !speedstep_high_freq || + (speedstep_low_freq == speedstep_high_freq)) +return -EIO ; +return 0 ; }
@@ -556,16 +558,16 @@return ;if (policy->min > speedstep_low_freq) -speedstep_set_state (SPEEDSTEP_HIGH ); +speedstep_set_state (SPEEDSTEP_HIGH ,1 );else {if (policy->max < speedstep_high_freq) -speedstep_set_state (SPEEDSTEP_LOW ); +speedstep_set_state (SPEEDSTEP_LOW ,1 );else {/* both frequency states are allowed */ if (policy->policy ==CPUFREQ_POLICY_POWERSAVE ) -speedstep_set_state (SPEEDSTEP_LOW ); +speedstep_set_state (SPEEDSTEP_LOW ,1 );else -speedstep_set_state (SPEEDSTEP_HIGH ); +speedstep_set_state (SPEEDSTEP_HIGH ,1 ); } } }
@@ -653,8 +655,8 @@if (!driver)return -ENOMEM ; - driver->policy = (struct cpufreq_policy *) (driver +sizeof (struct cpufreq_driver )); - + driver->policy = (struct cpufreq_policy *) (driver +1 ); +#ifdef CONFIG_CPU_FREQ_24_API driver->cpu_min_freq = speedstep_low_freq; driver->cpu_cur_freq[0 ] = speed;
arch/i386/kernel/time.c renamed from arch/i386/kernel/time.c.old +2 -2
@@ -659,7 +659,7 @@ }for (i=0 ; i<NR_CPUS ; i++)if ((freq->cpu ==CPUFREQ_ALL_CPUS ) || (freq->cpu == i)) - cpu_data[i].loops_per_jiffy =cpufreq_scale (loops_per_jiffy, freq->old, freq->new); + cpu_data[i].loops_per_jiffy =cpufreq_scale (cpu_data[i].loops_per_jiffy, freq->old, freq->new);break ;case CPUFREQ_POSTCHANGE :
@@ -670,7 +670,7 @@ }for (i=0 ; i<NR_CPUS ; i++)if ((freq->cpu ==CPUFREQ_ALL_CPUS ) || (freq->cpu == i)) - cpu_data[i].loops_per_jiffy =cpufreq_scale (loops_per_jiffy, freq->old, freq->new); + cpu_data[i].loops_per_jiffy =cpufreq_scale (cpu_data[i].loops_per_jiffy, freq->old, freq->new);break ; }
Quoted 11 lines · Gerald Britton
Quoted 2 lines · Dominik Brodowski
I think I found the problem: it should be
GFP_ATOMICand notGFP_KERNELin the allocation of structcpufreq_driver. Will be fixed in the next release.Nope. That should be fine, it's in a process context and not holding any locks, so
GFP_KERNELshould be fine. I found the bug though:arch/i386/kernel/speedstep.c renamed from arch/i386/kernel/speedstep.c.old +1
-1-driver->policy = (struct cpufreq_policy *) (driver +sizeof (struct cpufreq_driver )); +driver->policy = (struct cpufreq_policy *) (driver +1 );Remember your pointer arithmetic.
yes, you're right. I've just merged your patch into CVS, and I'll send a patch to Linus really soon.
<snip>
Quoted 4 lines
[rounding]
There probably isn't a lot that can be done about these unfortunately, but they won't necessarily converge to a stable value so things may eventually start to fail.
Yes, that's a problem; but as cpufreq doesn't change speed dynamically yet (and thus the number of transitions is somewhat limited) it shouldn't cause too much trouble _yet_. But I'll try to think of a better solution _soon_.
Dominik
Quoted 4 lines · Gerald Britton
Quoted 2 lines · Dominik Brodowski
I think I found the problem: it should be
GFP_ATOMICand notGFP_KERNELin the allocation of structcpufreq_driver. Will be fixed in the next release.
Quoted 8 lines
Nope. That should be fine, it's in a process context and not holding any locks, so
GFP_KERNELshould be fine. I found the bug though:-driver->policy = (struct
cpufreq_policy*) (driver +sizeof(struct cpufreq_dri ver));
+driver->policy = (structcpufreq_policy*) (driver + 1);Remember your pointer arithmetic.
Perhaps you should create a local variable of the right type:
struct cpufreq_policy *local_var = (struct cpufreq_policy *)driver; driver->policy = &local_var[1];
(gcc should be smart enough to loose it)
[In any case, making this part of driver point at itself looks wrong to me...]
Signature · 4 lines
Dr. Horst H. von Brand User #22616 counter.li.org Departamento de Informatica Fono: +56 32 654431 Universidad Tecnica Federico Santa Maria +56 32 654239 Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
Quoted 7 lines
Quoted 4 lines
[rounding]
There probably isn't a lot that can be done about these unfortunately, but they won't necessarily converge to a stable value so things may eventually start to fail.Yes, that's a problem; but as cpufreq doesn't change speed dynamically yet (and thus the number of transitions is somewhat limited) it shouldn't cause too much trouble _yet_. But I'll try to think of a better solution _soon_.
One thought here might be.. for each variable which needs to be scaled, save off the boot value and boot frequency and always scale from that value so that we don't accumulate errors. Fairly simple implementation (i doubt there are very many things which will need scaling, so it doesn't bloat much). simply do something like this:
static unsigned int orig_freq;
statid unsigned long orig_scalable;
...
if (type == CPUFREQ_PRECHANGE) {
if (!orig_freq) {
orig_freq = freqs->old;
orig_scalable = scalable;
}
if (scale_on_pre)
scalable = cpufreq_scale(orig_scalable, orig_freq, freqs->new);
} else if (type == CPUFREQ_POSTCHANGE) {
BUG_ON(!orig_freq);
if (scale_on_post)
scalable = cpufreq_scale(orig_scalable, orig_freq, freqs->new);
}It seems to be working ok on my system adding saved boot values for loops_per_jiffy in cpufreq.c and cpu_khz, fast_gettimeoffset_quotient, and the per cpu loops_per_jiffy values in time.c.
-- Gerald