Skip to contentSkip to conversation

powernow-k7: Userspace PST for Athlon XP-M on desktop boards

PATCH In review Harald Milz 4 participants 5 messages Jun 14, 2004 – Jun 15, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powernow-k7: Userspace PST for Athlon XP-M on desktop boards

Hi,

I finally managed to check all possible FIDs with my userspace PST patch.

To recollect, the goal is to enable FID switching for Athlon mobile CPUs on desktop boards with the powernow-k7 module. Most desktop boards don't support XP-M cpus and don't provide the appropriate PSTs. With this patch, you can set the appropriate values on the module command line, like:

insmod powernow-k7.o \
      mycpuid=0x7a0 myfsbspeed=133 mymaxfid=0x15 mystartvid=0xb mynumpstates=6
      myfids=0x15,0x00,0x0a,0x06,0x04,0x12 \
      myvids=0x0b,0x0d,0x13,0x13,0x13,0x13 

(The last line is useless on desktop boards because they don't support VID switching but you can use it on notebooks that do but have broken PSTs.)

Observations:

1. On my machine (Asus A7V8X w/ Athlon XP-M 2400+) the following multipliers can be toggled around just fine: 9.5 - 13.5. Lower multipliers will freeze the machine hard. I suspect it's because the voltage isn't appropriate for the lower multipliers - can somebody please deny or confirm this? (According to the BIOS, the actual core voltage is 1.58V or so.)

2. Higher multipliers up to 22.5 will not crash the machine but it appears that the actual multiplier stays at 13.5 which is the default for 1800 MHz. That's probably because the CPU tells us the maxfid in powernow_cpu_init(). So - no overclocking this way.

3. mymaxfid > 0x15 will prevent the module from loading - I'd have to dig into it to find out why. Since we can't overclock anyway this parameter is probably useless.

This is less than I expected but at least I can lower the core frequency to 70% of the maximum (1266 MHz nominal). Anything less will freeze the machine.

The ORIG file is from a SuSE 9.1 2.6.4 kernel.

Please have a look at it - flames and beer to me :-)

powernow-k7.c renamed from powernow-k7.c.ORIG +71 -1
@@ -85,6 +85,42 @@
 static unsigned int latency;
 static char have_a0;
 
+/*
+	PST hacking ... - hm
+*/
+static u32 mycpuid;
+static u8 myfsbspeed;
+static u8 mymaxfid;
+static u8 mystartvid;
+static u8 mynumpstates; /* max. 8 */
+static int myfids[8];
+static int myvids[8];
+
+MODULE_PARM (mycpuid, "i");
+MODULE_PARM (myfsbspeed, "i");
+MODULE_PARM (mymaxfid, "i");
+MODULE_PARM (mystartvid, "i");
+MODULE_PARM (mynumpstates, "i");
+/* 	
+	and an array of FID/VID  
+	for desktop boards, the VIDs will do nothing so if there's a
+	desktop voltage regulator we'll set them to startvid.
+	
+	module command line example: 
+
+	mycpuid=0x7a0 myfsbspeed=133 mymaxfid=0x15 mystartvid=0xb mynumpstates=6
+		myfids=0x15,0x00,0x0a,0x06,0x04,0x12
+		myvids=0x0b,0x0d,0x13,0x13,0x13,0x13
+
+	(see sample numbers from http://emeitner.f2o.org/nx9005/files/dmesg.txt)
+
+	Make sure the fid/vid pairs correspond! 
+*/
+MODULE_PARM (myfids, "1-8i");
+MODULE_PARM (myvids, "1-8i");
+
+
+
 
 static int check_powernow(void)
 {
@@ -269,6 +305,7 @@
 	unsigned char *p;
 	unsigned int etuple;
 	unsigned int ret;
+	u8 *t;
 
 	etuple = cpuid_eax(0x80000001);
 	etuple &= 0xf00;
@@ -309,8 +346,41 @@
 
 			pst = (struct pst_s *) p;
 
+/* 
+	here we can fake a PST according to our actual CPU ... 
+	best to take everything from the module command line instead of 
+	hardcoding everything.
+
+	Since we don't know the numpst of the faulty BIOS entry
+	we need to kmalloc a new PST entry with the required 
+	number of FID/VID pairs, and discard / disregard the rest. 
+	-> numpst = 1
+	and we will give him this one entry. 
+*/
+
+			if (mycpuid != 0) {
+				pst = kmalloc ((sizeof (struct pst_s) + (2 * mynumpstates)), GFP_KERNEL);
+				/* FIXME: associated kfree() missing */
+
+				dprintk (KERN_INFO PFX "using USER PST at %p\n", (unsigned char *)pst);
+
+				pst->cpuid = mycpuid;
+				pst->fsbspeed = myfsbspeed;
+				pst->maxfid = mymaxfid;
+				pst->startvid = mystartvid;
+				pst->numpstates = mynumpstates;
+				t = (u8 *) pst + sizeof (struct pst_s);
+				for (i=0; i<mynumpstates; i++) {
+					*t = myfids[i]; t++;
+					*t = myvids[i] == 0 ? mystartvid : myvids[i] ; t++;
+					dprintk (KERN_INFO PFX "fid: 0x%x; vid: 0x%x; t: %p\n", myfids[i], myvids[i], t);
+				}				
+				psb->numpst = 1;
+			}
+
 			for (i = 0 ; i <psb->numpst; i++) {
-				pst = (struct pst_s *) p;
+				if (mycpuid == 0) 
+					pst = (struct pst_s *) p;
 				number_scales = pst->numpstates;
 
 				if ((etuple == pst->cpuid) && (maxfid==pst->maxfid) && (startvid==pst->startvid))
Signature · 4 lines
TAURUS (Apr 20 - May 20)
	You are practical and persistent.  You have a dogged
	determination and work like hell.  Most people think you are
	stubborn and bull headed.  You are a Communist.
#1 lore raw

powernow-k7.c line 103

Quoted 5 lines · Harald Milz
powernow-k7.c renamed from powernow-k7.c.ORIG +5 -0
+MODULE_PARM (mycpuid, "i");
+MODULE_PARM (myfsbspeed, "i");
+MODULE_PARM (mymaxfid, "i");
+MODULE_PARM (mystartvid, "i");
+MODULE_PARM (mynumpstates, "i");

Please use module_param{,_array}() instead -- MODULE_PARM is deprecated.

powernow-k7.c line 380

Quoted 8 lines
powernow-k7.c renamed from powernow-k7.c.ORIG +8 -0
+				for (i=0; i<mynumpstates; i++) {
+					*t = myfids[i]; t++;
+					*t = myvids[i] == 0 ? mystartvid : myvids[i] ; t++;
+					dprintk (KERN_INFO PFX "fid: 0x%x; vid: 0x%x; t: %p\n", myfids[i], myvids[i], t);
+				}				
+				psb->numpst = 1;
+			}
+

Some sanity checking is definitely necessary, IIRC Bruno's in-kernel-hardcoded-table did have some. I have no opinion yet which way (Bruno's in-kernel or your module-parameter) is preferrable...

Dominik

#2 lore raw
Quoted 9 lines · Dominik Brodowski

powernow-k7.c line 103

Quoted 5 lines · Harald Milz
powernow-k7.c renamed from powernow-k7.c.ORIG +5 -0
+MODULE_PARM (mycpuid, "i");
+MODULE_PARM (myfsbspeed, "i");
+MODULE_PARM (mymaxfid, "i");
+MODULE_PARM (mystartvid, "i");
+MODULE_PARM (mynumpstates, "i");

Please use module_param{,_array}() instead -- MODULE_PARM is deprecated.

Quoted 12 lines

powernow-k7.c line 380

Quoted 8 lines
powernow-k7.c renamed from powernow-k7.c.ORIG +8 -0
+				for (i=0; i<mynumpstates; i++) {
+					*t = myfids[i]; t++;
+					*t = myvids[i] == 0 ? mystartvid : myvids[i] ; t++;
+					dprintk (KERN_INFO PFX "fid: 0x%x; vid: 0x%x; t: %p\n", myfids[i], myvids[i], t);
+				}				
+				psb->numpst = 1;
+			}
+

Some sanity checking is definitely necessary, IIRC Bruno's in-kernel-hardcoded-table did have some. I have no opinion yet which way (Bruno's in-kernel or your module-parameter) is preferrable...

I'm not entirely keen on this tbh. (Although I don't recall exactly what right now, I think I had some reservations about Bruno's approach too -- or maybe my mind is playing tricks, and I need to see that patch again).

What's the general consensus on this ? It seems to be an ugly hack for a minority of users, who seem able to recompile their kernel with a hardwired table. Maybe it sounds a little elitist, but if someone can't compile their kernel, should we make it easier to allow them to potentially do bad things to their processor ?

Additionally, I think I prefer Bruno's approach to adding more userspace interfaces, especially to a chipset driver rather than the cpufreq layer.

Dave

#3 lore raw
Quoted 3 lines · Dave Jones

What's the general consensus on this ? It seems to be an ugly hack for a minority of users, who seem able to recompile their kernel with a hardwired table. Maybe it sounds a little elitist, but if someone

Oh no it's not about a hardwired table. This is why I chose the command line approach. The goal is to have this in the main distribution so that nobody needs to recompile a kernel.

Quoted 2 lines

can't compile their kernel, should we make it easier to allow them to potentially do bad things to their processor ?

As far as I can see you can't do bad things to your CPU. The module will not set the multiplier above what the CPU thinks is okay. So no overclocking is possible with the current code. But hey, it's open source. You can override anything within the module, even the CPU's perception of maxfid. You can't keep people from jumping out of a window ...

I am not sure about the "minority" -- I keep hearing many Athlon XP-M notebooks have broken BIOSes. At the moment these folks can't really use powernow-k7 anyway - and for whom else is the module?

Has anyone got Bruno's patch?

Signature · 1 line
A penny saved is ridiculous.
#4 lore raw
Quoted 9 lines · Harald Milz
Quoted 3 lines · Dave Jones

What's the general consensus on this ? It seems to be an ugly hack for a minority of users, who seem able to recompile their kernel with a hardwired table. Maybe it sounds a little elitist, but if someone

Oh no it's not about a hardwired table. This is why I chose the command line approach. The goal is to have this in the main distribution so that nobody needs to recompile a kernel.

Quoted 8 lines
Quoted 2 lines

can't compile their kernel, should we make it easier to allow them to potentially do bad things to their processor ?

As far as I can see you can't do bad things to your CPU. The module will not set the multiplier above what the CPU thinks is okay. So no overclocking is possible with the current code. But hey, it's open source. You can override anything within the module, even the CPU's perception of maxfid. You can't keep people from jumping out of a window ...

That Dave's point actually. If someone want to modify powernow-k7, because the BIOS is broken, he is free to do so. It's not that hard and anyway such hardwired tables have been posted to this list already. The main advantage for this is that the guy have to read at least the code, do some search (preferably in this list, perhaps), and so he will learn what actually are those funny VID, FID etc.

Quoted 3 lines

I am not sure about the "minority" -- I keep hearing many Athlon XP-M notebooks have broken BIOSes. At the moment these folks can't really use powernow-k7 anyway - and for whom else is the module?

The recent ACPI stuff do have actually helped already..

Quoted 1 line

Has anyone got Bruno's patch?

http://www.poupinou.org/cpufreq/powernow-k7/
But it need reworking due to some change in powernow-k7. And I must admit I have now the same kind of concern than Dave anyway.

Signature · 4 lines
Bruno Ducrot

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.