From: Christian Hoelbling <christian.holbling@cern.ch>
To: cpufreq@www.linux.org.uk
Subject: [PATCH] 2.6.5 speedstep on P4Ms
Date: Fri, 11 Jun 2004 00:21:06 +0000 [thread overview]
Message-ID: <40C8FAF2.1070305@cern.ch> (raw)
[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]
hi and thanks! here is a batch that should do what you suggested.
>>/ diff --unified --recursive --new-file linux-2.6.7-rc3/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c linux-2.6.7-rc3.speedstep/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c
>/>/ --- linux-2.6.7-rc3/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c 2004-06-09 22:27:18.000000000 +0000
>/>/ +++ linux-2.6.7-rc3.speedstep/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c 2004-06-10 00:29:54.388186856 +0000
>/>/ @@ -70,6 +70,7 @@
>/>/ * @notify: whether to call cpufreq_notify_transition for CPU speed changes
>/>/ *
>/>/ * Tries to change the SpeedStep state.
>/>/ + * Note: notify is a dummy argument. The routine never notifies.
>/
>Maybe it's better to kill notify, and modify a little speedstep-smi and speedstep-lib
done
>Dominik, your though, please?
>
>...
>
>>/ +
>/>/ + for_each_cpu(i) {
>/>/ + if (cpu_isset(i, affected_cpu_map)) {
>/>/ + freqs.cpu = i;
>/>/ + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
>/>/ + }
>/>/ + }
>/
>What about
> for_each_cpu_mask(i, affected_cpu_map) {
> ...
> }
>instead?
thanks, done
>>/
>/>/ /* detect low and high frequency */
>/>/ result = speedstep_get_freqs(speedstep_processor,
>/>/ @@ -297,6 +337,9 @@
>/>/ if (!speed)
>/>/ return -EIO;
>/>/
>/>/ + /* allow to run on any CPU */
>/>/ + set_cpus_allowed(current, cpus_allowed);
>/>/ +
>/
>Something wrong. I mean, there is a return but the set_cpu_allowed()
>is done after...
this was a nasty one and i screwed up in 2 other places before. thanks alot!
chris
[-- Attachment #2: speedstep_patch.2.6.7-rc3_SMT.diff --]
[-- Type: text/x-patch, Size: 4434 bytes --]
diff --unified --recursive --new-file linux-2.6.7-rc3/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c linux-2.6.7-rc3.speedstep/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c
--- linux-2.6.7-rc3/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c 2004-06-09 22:27:18.000000000 +0000
+++ linux-2.6.7-rc3.speedstep/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c 2004-06-10 23:57:40.779127072 +0000
@@ -71,24 +71,16 @@
*
* Tries to change the SpeedStep state.
*/
-static void speedstep_set_state (unsigned int state, unsigned int notify)
+static void speedstep_set_state (unsigned int state)
{
u32 pmbase;
u8 pm2_blk;
u8 value;
unsigned long flags;
- struct cpufreq_freqs freqs;
if (!speedstep_chipset_dev || (state > 0x1))
return;
- freqs.old = speedstep_get_processor_frequency(speedstep_processor);
- freqs.new = speedstep_freqs[state].frequency;
- freqs.cpu = 0; /* speedstep.c is UP only driver */
-
- if (notify)
- cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
-
/* get PMBASE */
pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase);
if (!(pmbase & 0x01))
@@ -143,9 +135,6 @@
printk (KERN_ERR "cpufreq: change failed - I/O error\n");
}
- if (notify)
- cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
-
return;
}
@@ -251,12 +240,53 @@
unsigned int target_freq,
unsigned int relation)
{
- unsigned int newstate = 0;
+ unsigned int newstate = 0;
+ struct cpufreq_freqs freqs;
+ cpumask_t cpus_allowed, affected_cpu_map;
+ int i;
+
if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate))
return -EINVAL;
- speedstep_set_state(newstate, 1);
+ /* switch to physical CPU where state is to be changed*/
+ cpus_allowed = current->cpus_allowed;
+
+ /* only run on CPU to be set, or on its sibling */
+#ifdef CONFIG_SMP
+ affected_cpu_map = cpu_sibling_map[policy->cpu];
+#else
+ affected_cpu_map = cpumask_of_cpu(policy->cpu);
+#endif
+
+ set_cpus_allowed(current, affected_cpu_map);
+ freqs.old = speedstep_get_processor_frequency(speedstep_processor);
+ set_cpus_allowed(current, cpus_allowed);
+
+ freqs.new = speedstep_freqs[newstate].frequency;
+ freqs.cpu = policy->cpu;
+
+ /* no transition necessary */
+ if (freqs.old == freqs.new) {
+ set_cpus_allowed(current, cpus_allowed);
+ return 0;
+ }
+
+ for_each_cpu_mask(i, affected_cpu_map) {
+ freqs.cpu = i;
+ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+ }
+
+ /* do the transition */
+ set_cpus_allowed(current, affected_cpu_map);
+ speedstep_set_state(newstate);
+ set_cpus_allowed(current, cpus_allowed);
+
+ /* notifiers */
+ for_each_cpu_mask(i, affected_cpu_map) {
+ freqs.cpu = i;
+ cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+ }
return 0;
}
@@ -279,21 +309,31 @@
{
int result = 0;
unsigned int speed;
+ cpumask_t cpus_allowed,affected_cpu_map;
- /* capability check */
- if (policy->cpu != 0)
- return -ENODEV;
+ /* only run on CPU to be set, or on its sibling */
+ cpus_allowed = current->cpus_allowed;
+#ifdef CONFIG_SMP
+ affected_cpu_map = cpu_sibling_map[policy->cpu];
+#else
+ affected_cpu_map = cpumask_of_cpu(policy->cpu);
+#endif
/* detect low and high frequency */
+ set_cpus_allowed(current, affected_cpu_map);
result = speedstep_get_freqs(speedstep_processor,
&speedstep_freqs[SPEEDSTEP_LOW].frequency,
&speedstep_freqs[SPEEDSTEP_HIGH].frequency,
&speedstep_set_state);
+ set_cpus_allowed(current, cpus_allowed);
if (result)
return result;
/* get current speed setting */
+ set_cpus_allowed(current, affected_cpu_map);
speed = speedstep_get_processor_frequency(speedstep_processor);
+ set_cpus_allowed(current, cpus_allowed);
+
if (!speed)
return -EIO;
@@ -324,7 +364,20 @@
static unsigned int speedstep_get(unsigned int cpu)
{
- return speedstep_get_processor_frequency(speedstep_processor);
+ unsigned int speed;
+ cpumask_t cpus_allowed,affected_cpu_map;
+
+ /* only run on CPU to be set, or on its sibling */
+ cpus_allowed = current->cpus_allowed;
+#ifdef CONFIG_SMP
+ affected_cpu_map = cpu_sibling_map[cpu];
+#else
+ affected_cpu_map = cpumask_of_cpu(cpu);
+#endif
+ set_cpus_allowed(current, affected_cpu_map);
+ speed=speedstep_get_processor_frequency(speedstep_processor);
+ set_cpus_allowed(current, cpus_allowed);
+ return speed;
}
static struct freq_attr* speedstep_attr[] = {
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Cpufreq mailing list
Cpufreq@www.linux.org.uk
http://www.linux.org.uk/mailman/listinfo/cpufreq
next reply other threads:[~2004-06-11 0:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-11 0:21 Christian Hoelbling [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-06-11 0:30 [PATCH] 2.6.5 speedstep on P4Ms Christian Hoelbling
2004-06-08 17:15 Christian Hoelbling
2004-06-08 15:30 ` Bruno Ducrot
2004-06-08 23:53 ` Christian Hoelbling
2004-06-09 15:47 ` Dominik Brodowski
2004-06-09 16:09 ` Bruno Ducrot
2004-06-09 16:29 ` Dave Jones
2004-06-09 16:53 ` Dominik Brodowski
2004-06-09 18:32 ` Mattia Dongili
2004-06-10 0:46 ` Christian Hoelbling
2004-06-10 8:30 ` Dominik Brodowski
2004-06-10 11:20 ` Dave Jones
2004-06-10 9:10 ` Bruno Ducrot
2004-06-10 15:37 ` Bruno Ducrot
2004-06-10 16:44 ` Dominik Brodowski
2004-06-10 19:44 ` Bruno Ducrot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40C8FAF2.1070305@cern.ch \
--to=christian.holbling@cern.ch \
--cc=cpufreq@www.linux.org.uk \
--cc=holbling@cpt.univ-mrs.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox