[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>

authored by

Stephen Rothwell and committed by
Paul Mackerras
8d15a3e5 1ababe11

+73 -42
+1 -1
arch/ppc64/kernel/Makefile
··· 11 11 udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \ 12 12 ptrace32.o signal32.o rtc.o init_task.o \ 13 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 15 obj-y += vdso32/ vdso64/ 16 16 17 17 obj-$(CONFIG_PPC_OF) += of_device.o
+1 -26
arch/ppc64/kernel/cputable.c
··· 5 5 * 6 6 * Modifications for ppc64: 7 7 * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> 8 - * 8 + * 9 9 * This program is free software; you can redistribute it and/or 10 10 * modify it under the terms of the GNU General Public License 11 11 * as published by the Free Software Foundation; either version ··· 20 20 #include <linux/module.h> 21 21 22 22 #include <asm/cputable.h> 23 - #include <asm/firmware.h> 24 23 25 24 struct cpu_spec* cur_cpu_spec = NULL; 26 25 EXPORT_SYMBOL(cur_cpu_spec); 27 - unsigned long ppc64_firmware_features; 28 26 29 27 /* NOTE: 30 28 * Unlike ppc32, ppc64 will only call this once for the boot CPU, it's ··· 241 243 .dcache_bsize = 128, 242 244 .cpu_setup = __setup_cpu_power4, 243 245 } 244 - }; 245 - 246 - firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = { 247 - {FW_FEATURE_PFT, "hcall-pft"}, 248 - {FW_FEATURE_TCE, "hcall-tce"}, 249 - {FW_FEATURE_SPRG0, "hcall-sprg0"}, 250 - {FW_FEATURE_DABR, "hcall-dabr"}, 251 - {FW_FEATURE_COPY, "hcall-copy"}, 252 - {FW_FEATURE_ASR, "hcall-asr"}, 253 - {FW_FEATURE_DEBUG, "hcall-debug"}, 254 - {FW_FEATURE_PERF, "hcall-perf"}, 255 - {FW_FEATURE_DUMP, "hcall-dump"}, 256 - {FW_FEATURE_INTERRUPT, "hcall-interrupt"}, 257 - {FW_FEATURE_MIGRATE, "hcall-migrate"}, 258 - {FW_FEATURE_PERFMON, "hcall-perfmon"}, 259 - {FW_FEATURE_CRQ, "hcall-crq"}, 260 - {FW_FEATURE_VIO, "hcall-vio"}, 261 - {FW_FEATURE_RDMA, "hcall-rdma"}, 262 - {FW_FEATURE_LLAN, "hcall-lLAN"}, 263 - {FW_FEATURE_BULK, "hcall-bulk"}, 264 - {FW_FEATURE_XDABR, "hcall-xdabr"}, 265 - {FW_FEATURE_MULTITCE, "hcall-multi-tce"}, 266 - {FW_FEATURE_SPLPAR, "hcall-splpar"}, 267 246 };
+47
arch/ppc64/kernel/firmware.c
··· 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
+1 -3
arch/ppc64/kernel/pSeries_setup.c
··· 231 231 232 232 pSeries_nvram_init(); 233 233 234 - if (firmware_has_feature(FW_FEATURE_SPLPAR)) 235 - vpa_init(boot_cpuid); 236 - 237 234 /* Choose an idle loop */ 238 235 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 236 + vpa_init(boot_cpuid); 239 237 if (get_paca()->lppaca.shared_proc) { 240 238 printk(KERN_INFO "Using shared processor idle loop\n"); 241 239 ppc_md.idle_loop = pseries_shared_idle;
+3 -6
arch/ppc64/kernel/process.c
··· 203 203 new_thread = &new->thread; 204 204 old_thread = &current->thread; 205 205 206 - /* Collect purr utilization data per process and per processor wise */ 207 - /* purr is nothing but processor time base */ 208 - 209 - #if defined(CONFIG_PPC_PSERIES) 206 + /* Collect purr utilization data per process and per processor 207 + * wise purr is nothing but processor time base 208 + */ 210 209 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 211 210 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 212 211 long unsigned start_tb, current_tb; ··· 214 215 old_thread->accum_tb += (current_tb - start_tb); 215 216 new_thread->start_tb = current_tb; 216 217 } 217 - #endif 218 - 219 218 220 219 local_irq_save(flags); 221 220 last = _switch(old_thread, new_thread);
-2
arch/ppc64/kernel/sysfs.c
··· 153 153 break; 154 154 } 155 155 156 - #ifdef CONFIG_PPC_PSERIES 157 156 /* instruct hypervisor to maintain PMCs */ 158 157 if (firmware_has_feature(FW_FEATURE_SPLPAR)) 159 158 get_paca()->lppaca.pmcregs_in_use = 1; 160 - #endif /* CONFIG_PPC_PSERIES */ 161 159 } 162 160 163 161 #else
+1 -3
arch/ppc64/kernel/time.c
··· 371 371 process_hvlpevents(regs); 372 372 #endif 373 373 374 - /* collect purr register values often, for accurate calculations */ 375 - #if defined(CONFIG_PPC_PSERIES) 374 + /* collect purr register values often, for accurate calculations */ 376 375 if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 377 376 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 378 377 cu->current_tb = mfspr(SPRN_PURR); 379 378 } 380 - #endif 381 379 382 380 irq_exit(); 383 381
+19 -1
include/asm-ppc64/firmware.h
··· 45 45 #define FW_FEATURE_MULTITCE (1UL<<19) 46 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 64 /* This is used to identify firmware features which are available 49 65 * to the kernel. 50 66 */ ··· 68 52 69 53 static inline unsigned long firmware_has_feature(unsigned long feature) 70 54 { 71 - return ppc64_firmware_features & feature; 55 + return ppc64_firmware_features & feature & FW_FEATURE_POSSIBLE; 72 56 } 73 57 58 + #ifdef CONFIG_PPC_PSERIES 74 59 typedef struct { 75 60 unsigned long val; 76 61 char * name; 77 62 } firmware_feature_t; 78 63 79 64 extern firmware_feature_t firmware_features_table[]; 65 + #endif 80 66 81 67 #endif /* __ASSEMBLY__ */ 82 68 #endif /* __KERNEL__ */