Skip to contentSkip to conversation

new cpufreq device driver for nForce4

DISCUSSION Alexander Shaposhnikov 2 participants 3 messages Nov 14, 2005 – Nov 17, 2005

lore
Share & tools
lore
#0 lore raw

Hellow.

I have written cpufreq device driver for FSB, voltage and multiplier changing on nVidia nForce4 -based motherboards.
It is very amateur thing in the present state, i use it primarily for overclocking my dual dualcore Opteron system:). But it may be used for power saving as well.

If there will be some interest in this i will continue my work on it and make it more robust, though it already works great for me.

I've attached the code.

Signature · 2 lines
Best Regards,
Alexander Shaposhnikov

_______________________________________________
Cpufreq mailing list
[email protected]
http://lists.linux.org.uk/mailman/listinfo/cpufreq

#1 lore raw

14.11.2005 10:43, Alexander Shaposhnikov wrote/a écrit:

Quoted 5 lines

Hellow.

I have written cpufreq device driver for FSB, voltage and multiplier changing on nVidia nForce4 -based motherboards.
It is very amateur thing in the present state, i use it primarily for overclocking my dual dualcore Opteron system:). But it may be used for power saving as well.

Hello Alexander,

I think in general every new driver is welcome. It doesn't matter if it looks amateur, a few iterations on the mailing list and it won't ;-) One important thing though, how dangerous is your driver? I mean, knowing you use it for overclocking, if someone use it without any knowledge of his hardware, can the driver lead to burn the CPU? If so, IMHO, it really requires you to insert some additional code to forbid overclocking by defaulf (and authorise it only via a special module parameter or a sysfs entry for example).

Quoted 2 lines

If there will be some interest in this i will continue my work on it and make it more robust, though it already works great for me.

Actually I know only very little about cpufreq, but your driver looks good, you should keep going!

Quoted 2 lines

I've attached the code.

Probably the reason no one answered is that you put it in a tar.bz2 . Only plain text is read! Actually, it could be even better if you attach a patch, so that just with "patch -p1 < your-nforce4.patch" it could go into the kernel :-) Please read Documentation/SubmittingPatches. You might want to also send the small required modifications to Kconfig and Makefile.

Also, it is very important you conform to the coding style, cf Documentation/CodingStyle. In paticular, the names of the functions and variables are in lowercase only, don't put "{" and "}" in if's and for's with only one statement, put spaces around "=" ...

Ok, now just some very small comments:

Quoted 16 lines

static int CK804_cpu_init(struct cpufreq_policy *policy)

{
	struct K8_STATUS_MSR status_msr;


	if(!cpu_online(policy->cpu))
		return -ENODEV;

	status_msr.cpu=policy->cpu;
	GET_STATUS_MSR(&status_msr);

	policy->cpus=AFFECTED_CPUS;
	
	policy->cpuinfo.min_freq = PLL_MIN_FSB*FID_to_MUL(K8_MIN_FID);
	if(ALG!=3)

Avoid magic numbers! Use "#define"'s to express the meaning of the constants.

Quoted 9 lines
	{
		policy->cpuinfo.max_freq = PLL_MAX_FSB*FID_to_MUL(status_msr.max_fid);
	}
	else
	{
		policy->cpuinfo.max_freq = 0x3FF*PLL_REF_CLOCK*FID_to_MUL(status_msr.max_fid)/0x300;
	}

	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

Please, try to put a real value here, some value which you are _sure_ that will never take so much time to change of frequency. If you put CPUFREQ_ETERNAL then your driver will not be compatible with the ondemand and conservative governors.

:

Quoted 2 lines

static struct cpufreq_driver CK804_driver = {
.name = "cpufreq_nForce4",

There is a already a driver for the nForce2 wich is called "nforce2", for consistency, you might want to rename yours to "nforce4".

Quoted 8 lines
	.verify = CK804_verify,
	.target = CK804_target,
	.get    = CK804_get,
	.init   = CK804_cpu_init,
	.exit   = CK804_cpu_exit,
	.owner  = THIS_MODULE,
};

c u
Eric

#2 lore raw

Hellow Eric,

Thanks for reply.

There are a lot of really bad places in the code, i know (if any good places at all).
The thing is, my primary motivation was to create OC'ing tool, and it works for me really great. The most difficult part was to find PLL address and decode its value:), because there is no documentation from nVidia.

It is intended for power user anyway, because for simple power saving (though not very efficient, actually) powernow-k8 is better.

By the way, it is often possible to reduce voltage for Athlon64 and Opteron processors to the much lower values than according to AMD specifications.
It is actually possible to bring power consumption of Desktop and Server cpus to the level of mobile cpus or even lower! But this requires some testing and user involvement.

I am planning to export FSB, Voltages and Multipliers through sysfs (when i'll learn how to do it right:) ).

I am testing it now on another dual Opteron board (Supermicro H8DCE), and then going to make new and hopefully much improved version.

Best Regards,
Alexander Shaposhnikov

Quoted 90 lines · Eric Piel

14.11.2005 10:43, Alexander Shaposhnikov wrote/a écrit:

Quoted 7 lines

Hellow.

I have written cpufreq device driver for FSB, voltage and multiplier changing on nVidia nForce4 -based motherboards.
It is very amateur thing in the present state, i use it primarily for overclocking my dual dualcore Opteron system:). But it may be used for power saving as well.

Hello Alexander,

I think in general every new driver is welcome. It doesn't matter if it looks amateur, a few iterations on the mailing list and it won't ;-) One important thing though, how dangerous is your driver? I mean, knowing you use it for overclocking, if someone use it without any knowledge of his hardware, can the driver lead to burn the CPU? If so, IMHO, it really requires you to insert some additional code to forbid overclocking by defaulf (and authorise it only via a special module parameter or a sysfs entry for example).

Quoted 3 lines

If there will be some interest in this i will continue my work on it and make it more robust, though it already works great for me.

Actually I know only very little about cpufreq, but your driver looks good, you should keep going!

Quoted 2 lines

I've attached the code.

Probably the reason no one answered is that you put it in a tar.bz2 . Only plain text is read! Actually, it could be even better if you attach a patch, so that just with "patch -p1 < your-nforce4.patch" it could go into the kernel :-) Please read Documentation/SubmittingPatches. You might want to also send the small required modifications to Kconfig and Makefile.

Also, it is very important you conform to the coding style, cf Documentation/CodingStyle. In paticular, the names of the functions and variables are in lowercase only, don't put "{" and "}" in if's and for's with only one statement, put spaces around "=" ...

Ok, now just some very small comments:

Quoted 16 lines

static int CK804_cpu_init(struct cpufreq_policy *policy)

{
	struct K8_STATUS_MSR status_msr;


	if(!cpu_online(policy->cpu))
		return -ENODEV;

	status_msr.cpu=policy->cpu;
	GET_STATUS_MSR(&status_msr);

	policy->cpus=AFFECTED_CPUS;
	
	policy->cpuinfo.min_freq = PLL_MIN_FSB*FID_to_MUL(K8_MIN_FID);
	if(ALG!=3)

Avoid magic numbers! Use "#define"'s to express the meaning of the constants.

Quoted 9 lines
	{
		policy->cpuinfo.max_freq = PLL_MAX_FSB*FID_to_MUL(status_msr.max_fid);
	}
	else
	{
		policy->cpuinfo.max_freq = 0x3FF*PLL_REF_CLOCK*FID_to_MUL(status_msr.max_fid)/0x300;
	}

	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

Please, try to put a real value here, some value which you are _sure_ that will never take so much time to change of frequency. If you put CPUFREQ_ETERNAL then your driver will not be compatible with the ondemand and conservative governors.

:

Quoted 2 lines

static struct cpufreq_driver CK804_driver = {
.name = "cpufreq_nForce4",

There is a already a driver for the nForce2 wich is called "nforce2", for consistency, you might want to rename yours to "nforce4".

Quoted 8 lines
	.verify = CK804_verify,
	.target = CK804_target,
	.get    = CK804_get,
	.init   = CK804_cpu_init,
	.exit   = CK804_cpu_exit,
	.owner  = THIS_MODULE,
};

c u
Eric