diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2005-08-03 00:40:16 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-08-28 20:53:35 -0400 |
commit | 8d15a3e55f49678b0900dcf5c1cddb322a129325 (patch) | |
tree | c86205bde42833c25bf2f3b51f8b67f9d4e52a22 | |
parent | 1ababe11480d59d75be806804c71fa55d203a5a6 (diff) |
[PATCH] ppc64: make firmware_has_feature() stronger
Make firmware_has_feature() evaluate at compile time for the non pSeries
case and tidy up code where possible.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/ppc64/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/ppc64/kernel/cputable.c | 27 | ||||
-rw-r--r-- | arch/ppc64/kernel/firmware.c | 47 | ||||
-rw-r--r-- | arch/ppc64/kernel/pSeries_setup.c | 4 | ||||
-rw-r--r-- | arch/ppc64/kernel/process.c | 9 | ||||
-rw-r--r-- | arch/ppc64/kernel/sysfs.c | 2 | ||||
-rw-r--r-- | arch/ppc64/kernel/time.c | 4 | ||||
-rw-r--r-- | include/asm-ppc64/firmware.h | 20 |
8 files changed, 73 insertions, 42 deletions
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile index cbf87dcac92a..f4b3bfcc109d 100644 --- a/arch/ppc64/kernel/Makefile +++ b/arch/ppc64/kernel/Makefile | |||
@@ -11,7 +11,7 @@ obj-y := setup.o entry.o traps.o irq.o idle.o dma.o \ | |||
11 | udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \ | 11 | udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \ |
12 | ptrace32.o signal32.o rtc.o init_task.o \ | 12 | ptrace32.o signal32.o rtc.o init_task.o \ |
13 | lmb.o cputable.o cpu_setup_power4.o idle_power4.o \ | 13 | lmb.o cputable.o cpu_setup_power4.o idle_power4.o \ |
14 | iommu.o sysfs.o vdso.o pmc.o | 14 | iommu.o sysfs.o vdso.o pmc.o firmware.o |
15 | obj-y += vdso32/ vdso64/ | 15 | obj-y += vdso32/ vdso64/ |
16 | 16 | ||
17 | obj-$(CONFIG_PPC_OF) += of_device.o | 17 | obj-$(CONFIG_PPC_OF) += of_device.o |
diff --git a/arch/ppc64/kernel/cputable.c b/arch/ppc64/kernel/cputable.c index 6294fc7bd442..4847f2ac8c9f 100644 --- a/arch/ppc64/kernel/cputable.c +++ b/arch/ppc64/kernel/cputable.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Modifications for ppc64: | 6 | * Modifications for ppc64: |
7 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> | 7 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
11 | * as published by the Free Software Foundation; either version | 11 | * as published by the Free Software Foundation; either version |
@@ -20,11 +20,9 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | 21 | ||
22 | #include <asm/cputable.h> | 22 | #include <asm/cputable.h> |
23 | #include <asm/firmware.h> | ||
24 | 23 | ||
25 | struct cpu_spec* cur_cpu_spec = NULL; | 24 | struct cpu_spec* cur_cpu_spec = NULL; |
26 | EXPORT_SYMBOL(cur_cpu_spec); | 25 | EXPORT_SYMBOL(cur_cpu_spec); |
27 | unsigned long ppc64_firmware_features; | ||
28 | 26 | ||
29 | /* NOTE: | 27 | /* NOTE: |
30 | * Unlike ppc32, ppc64 will only call this once for the boot CPU, it's | 28 | * Unlike ppc32, ppc64 will only call this once for the boot CPU, it's |
@@ -244,26 +242,3 @@ struct cpu_spec cpu_specs[] = { | |||
244 | .cpu_setup = __setup_cpu_power4, | 242 | .cpu_setup = __setup_cpu_power4, |
245 | } | 243 | } |
246 | }; | 244 | }; |
247 | |||
248 | firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = { | ||
249 | {FW_FEATURE_PFT, "hcall-pft"}, | ||
250 | {FW_FEATURE_TCE, "hcall-tce"}, | ||
251 | {FW_FEATURE_SPRG0, "hcall-sprg0"}, | ||
252 | {FW_FEATURE_DABR, "hcall-dabr"}, | ||
253 | {FW_FEATURE_COPY, "hcall-copy"}, | ||
254 | {FW_FEATURE_ASR, "hcall-asr"}, | ||
255 | {FW_FEATURE_DEBUG, "hcall-debug"}, | ||
256 | {FW_FEATURE_PERF, "hcall-perf"}, | ||
257 | {FW_FEATURE_DUMP, "hcall-dump"}, | ||
258 | {FW_FEATURE_INTERRUPT, "hcall-interrupt"}, | ||
259 | {FW_FEATURE_MIGRATE, "hcall-migrate"}, | ||
260 | {FW_FEATURE_PERFMON, "hcall-perfmon"}, | ||
261 | {FW_FEATURE_CRQ, "hcall-crq"}, | ||
262 | {FW_FEATURE_VIO, "hcall-vio"}, | ||
263 | {FW_FEATURE_RDMA, "hcall-rdma"}, | ||
264 | {FW_FEATURE_LLAN, "hcall-lLAN"}, | ||
265 | {FW_FEATURE_BULK, "hcall-bulk"}, | ||
266 | {FW_FEATURE_XDABR, "hcall-xdabr"}, | ||
267 | {FW_FEATURE_MULTITCE, "hcall-multi-tce"}, | ||
268 | {FW_FEATURE_SPLPAR, "hcall-splpar"}, | ||
269 | }; | ||
diff --git a/arch/ppc64/kernel/firmware.c b/arch/ppc64/kernel/firmware.c new file mode 100644 index 000000000000..d8432c0fb27d --- /dev/null +++ b/arch/ppc64/kernel/firmware.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * arch/ppc64/kernel/firmware.c | ||
3 | * | ||
4 | * Extracted from cputable.c | ||
5 | * | ||
6 | * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org) | ||
7 | * | ||
8 | * Modifications for ppc64: | ||
9 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> | ||
10 | * Copyright (C) 2005 Stephen Rothwell, IBM Corporation | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | |||
20 | #include <asm/firmware.h> | ||
21 | |||
22 | unsigned long ppc64_firmware_features; | ||
23 | |||
24 | #ifdef CONFIG_PPC_PSERIES | ||
25 | firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = { | ||
26 | {FW_FEATURE_PFT, "hcall-pft"}, | ||
27 | {FW_FEATURE_TCE, "hcall-tce"}, | ||
28 | {FW_FEATURE_SPRG0, "hcall-sprg0"}, | ||
29 | {FW_FEATURE_DABR, "hcall-dabr"}, | ||
30 | {FW_FEATURE_COPY, "hcall-copy"}, | ||
31 | {FW_FEATURE_ASR, "hcall-asr"}, | ||
32 | {FW_FEATURE_DEBUG, "hcall-debug"}, | ||
33 | {FW_FEATURE_PERF, "hcall-perf"}, | ||
34 | {FW_FEATURE_DUMP, "hcall-dump"}, | ||
35 | {FW_FEATURE_INTERRUPT, "hcall-interrupt"}, | ||
36 | {FW_FEATURE_MIGRATE, "hcall-migrate"}, | ||
37 | {FW_FEATURE_PERFMON, "hcall-perfmon"}, | ||
38 | {FW_FEATURE_CRQ, "hcall-crq"}, | ||
39 | {FW_FEATURE_VIO, "hcall-vio"}, | ||
40 | {FW_FEATURE_RDMA, "hcall-rdma"}, | ||
41 | {FW_FEATURE_LLAN, "hcall-lLAN"}, | ||
42 | {FW_FEATURE_BULK, "hcall-bulk"}, | ||
43 | {FW_FEATURE_XDABR, "hcall-xdabr"}, | ||
44 | {FW_FEATURE_MULTITCE, "hcall-multi-tce"}, | ||
45 | {FW_FEATURE_SPLPAR, "hcall-splpar"}, | ||
46 | }; | ||
47 | #endif | ||
diff --git a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c index 0058f32a3d89..7ae7a2ca1085 100644 --- a/arch/ppc64/kernel/pSeries_setup.c +++ b/arch/ppc64/kernel/pSeries_setup.c | |||
@@ -231,11 +231,9 @@ static void __init pSeries_setup_arch(void) | |||
231 | 231 | ||
232 | pSeries_nvram_init(); | 232 | pSeries_nvram_init(); |
233 | 233 | ||
234 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) | ||
235 | vpa_init(boot_cpuid); | ||
236 | |||
237 | /* Choose an idle loop */ | 234 | /* Choose an idle loop */ |
238 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { | 235 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { |
236 | vpa_init(boot_cpuid); | ||
239 | if (get_paca()->lppaca.shared_proc) { | 237 | if (get_paca()->lppaca.shared_proc) { |
240 | printk(KERN_INFO "Using shared processor idle loop\n"); | 238 | printk(KERN_INFO "Using shared processor idle loop\n"); |
241 | ppc_md.idle_loop = pseries_shared_idle; | 239 | ppc_md.idle_loop = pseries_shared_idle; |
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c index 9bad983333b1..7a7e027653ad 100644 --- a/arch/ppc64/kernel/process.c +++ b/arch/ppc64/kernel/process.c | |||
@@ -203,10 +203,9 @@ struct task_struct *__switch_to(struct task_struct *prev, | |||
203 | new_thread = &new->thread; | 203 | new_thread = &new->thread; |
204 | old_thread = ¤t->thread; | 204 | old_thread = ¤t->thread; |
205 | 205 | ||
206 | /* Collect purr utilization data per process and per processor wise */ | 206 | /* Collect purr utilization data per process and per processor |
207 | /* purr is nothing but processor time base */ | 207 | * wise purr is nothing but processor time base |
208 | 208 | */ | |
209 | #if defined(CONFIG_PPC_PSERIES) | ||
210 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { | 209 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { |
211 | struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); | 210 | struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); |
212 | long unsigned start_tb, current_tb; | 211 | long unsigned start_tb, current_tb; |
@@ -215,8 +214,6 @@ struct task_struct *__switch_to(struct task_struct *prev, | |||
215 | old_thread->accum_tb += (current_tb - start_tb); | 214 | old_thread->accum_tb += (current_tb - start_tb); |
216 | new_thread->start_tb = current_tb; | 215 | new_thread->start_tb = current_tb; |
217 | } | 216 | } |
218 | #endif | ||
219 | |||
220 | 217 | ||
221 | local_irq_save(flags); | 218 | local_irq_save(flags); |
222 | last = _switch(old_thread, new_thread); | 219 | last = _switch(old_thread, new_thread); |
diff --git a/arch/ppc64/kernel/sysfs.c b/arch/ppc64/kernel/sysfs.c index e399963521c0..eca15d25e026 100644 --- a/arch/ppc64/kernel/sysfs.c +++ b/arch/ppc64/kernel/sysfs.c | |||
@@ -153,11 +153,9 @@ void ppc64_enable_pmcs(void) | |||
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | 155 | ||
156 | #ifdef CONFIG_PPC_PSERIES | ||
157 | /* instruct hypervisor to maintain PMCs */ | 156 | /* instruct hypervisor to maintain PMCs */ |
158 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) | 157 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) |
159 | get_paca()->lppaca.pmcregs_in_use = 1; | 158 | get_paca()->lppaca.pmcregs_in_use = 1; |
160 | #endif /* CONFIG_PPC_PSERIES */ | ||
161 | } | 159 | } |
162 | 160 | ||
163 | #else | 161 | #else |
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c index d523056fd660..1696e1b05bb9 100644 --- a/arch/ppc64/kernel/time.c +++ b/arch/ppc64/kernel/time.c | |||
@@ -371,13 +371,11 @@ int timer_interrupt(struct pt_regs * regs) | |||
371 | process_hvlpevents(regs); | 371 | process_hvlpevents(regs); |
372 | #endif | 372 | #endif |
373 | 373 | ||
374 | /* collect purr register values often, for accurate calculations */ | 374 | /* collect purr register values often, for accurate calculations */ |
375 | #if defined(CONFIG_PPC_PSERIES) | ||
376 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { | 375 | if (firmware_has_feature(FW_FEATURE_SPLPAR)) { |
377 | struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); | 376 | struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); |
378 | cu->current_tb = mfspr(SPRN_PURR); | 377 | cu->current_tb = mfspr(SPRN_PURR); |
379 | } | 378 | } |
380 | #endif | ||
381 | 379 | ||
382 | irq_exit(); | 380 | irq_exit(); |
383 | 381 | ||
diff --git a/include/asm-ppc64/firmware.h b/include/asm-ppc64/firmware.h index 5bb5bf46bb4a..e3725f3c8ea6 100644 --- a/include/asm-ppc64/firmware.h +++ b/include/asm-ppc64/firmware.h | |||
@@ -45,6 +45,22 @@ | |||
45 | #define FW_FEATURE_MULTITCE (1UL<<19) | 45 | #define FW_FEATURE_MULTITCE (1UL<<19) |
46 | #define FW_FEATURE_SPLPAR (1UL<<20) | 46 | #define FW_FEATURE_SPLPAR (1UL<<20) |
47 | 47 | ||
48 | enum { | ||
49 | FW_FEATURE_PSERIES = FW_FEATURE_PFT | FW_FEATURE_TCE | | ||
50 | FW_FEATURE_SPRG0 | FW_FEATURE_DABR | FW_FEATURE_COPY | | ||
51 | FW_FEATURE_ASR | FW_FEATURE_DEBUG | FW_FEATURE_TERM | | ||
52 | FW_FEATURE_PERF | FW_FEATURE_DUMP | FW_FEATURE_INTERRUPT | | ||
53 | FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ | | ||
54 | FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN | | ||
55 | FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE | | ||
56 | FW_FEATURE_SPLPAR, | ||
57 | FW_FEATURE_POSSIBLE = | ||
58 | #ifdef CONFIG_PPC_PSERIES | ||
59 | FW_FEATURE_PSERIES | | ||
60 | #endif | ||
61 | 0, | ||
62 | }; | ||
63 | |||
48 | /* This is used to identify firmware features which are available | 64 | /* This is used to identify firmware features which are available |
49 | * to the kernel. | 65 | * to the kernel. |
50 | */ | 66 | */ |
@@ -52,15 +68,17 @@ extern unsigned long ppc64_firmware_features; | |||
52 | 68 | ||
53 | static inline unsigned long firmware_has_feature(unsigned long feature) | 69 | static inline unsigned long firmware_has_feature(unsigned long feature) |
54 | { | 70 | { |
55 | return ppc64_firmware_features & feature; | 71 | return ppc64_firmware_features & feature & FW_FEATURE_POSSIBLE; |
56 | } | 72 | } |
57 | 73 | ||
74 | #ifdef CONFIG_PPC_PSERIES | ||
58 | typedef struct { | 75 | typedef struct { |
59 | unsigned long val; | 76 | unsigned long val; |
60 | char * name; | 77 | char * name; |
61 | } firmware_feature_t; | 78 | } firmware_feature_t; |
62 | 79 | ||
63 | extern firmware_feature_t firmware_features_table[]; | 80 | extern firmware_feature_t firmware_features_table[]; |
81 | #endif | ||
64 | 82 | ||
65 | #endif /* __ASSEMBLY__ */ | 83 | #endif /* __ASSEMBLY__ */ |
66 | #endif /* __KERNEL__ */ | 84 | #endif /* __KERNEL__ */ |