[PATCH] ppc64: create firmware_has_feature()

Create the firmware_has_feature() inline and move the firmware feature
stuff into its own header file.

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
1ababe11 7a6af5e3

+87 -55
+1
arch/ppc64/kernel/cputable.c
··· 20 #include <linux/module.h> 21 22 #include <asm/cputable.h> 23 24 struct cpu_spec* cur_cpu_spec = NULL; 25 EXPORT_SYMBOL(cur_cpu_spec);
··· 20 #include <linux/module.h> 21 22 #include <asm/cputable.h> 23 + #include <asm/firmware.h> 24 25 struct cpu_spec* cur_cpu_spec = NULL; 26 EXPORT_SYMBOL(cur_cpu_spec);
+3 -3
arch/ppc64/kernel/lparcfg.c
··· 29 #include <asm/iSeries/HvLpConfig.h> 30 #include <asm/lppaca.h> 31 #include <asm/hvcall.h> 32 - #include <asm/cputable.h> 33 #include <asm/rtas.h> 34 #include <asm/system.h> 35 #include <asm/time.h> ··· 377 378 partition_active_processors = lparcfg_count_active_processors(); 379 380 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) { 381 unsigned long h_entitled, h_unallocated; 382 unsigned long h_aggregation, h_resource; 383 unsigned long pool_idle_time, pool_procs; ··· 571 mode_t mode = S_IRUSR; 572 573 /* Allow writing if we have FW_FEATURE_SPLPAR */ 574 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) { 575 lparcfg_fops.write = lparcfg_write; 576 mode |= S_IWUSR; 577 }
··· 29 #include <asm/iSeries/HvLpConfig.h> 30 #include <asm/lppaca.h> 31 #include <asm/hvcall.h> 32 + #include <asm/firmware.h> 33 #include <asm/rtas.h> 34 #include <asm/system.h> 35 #include <asm/time.h> ··· 377 378 partition_active_processors = lparcfg_count_active_processors(); 379 380 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 381 unsigned long h_entitled, h_unallocated; 382 unsigned long h_aggregation, h_resource; 383 unsigned long pool_idle_time, pool_procs; ··· 571 mode_t mode = S_IRUSR; 572 573 /* Allow writing if we have FW_FEATURE_SPLPAR */ 574 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 575 lparcfg_fops.write = lparcfg_write; 576 mode |= S_IWUSR; 577 }
+2 -1
arch/ppc64/kernel/pSeries_iommu.c
··· 45 #include <asm/plpar_wrappers.h> 46 #include <asm/pSeries_reconfig.h> 47 #include <asm/systemcfg.h> 48 #include "pci.h" 49 50 #define DBG(fmt...) ··· 547 } 548 549 if (systemcfg->platform & PLATFORM_LPAR) { 550 - if (ppc64_firmware_features & FW_FEATURE_MULTITCE) { 551 ppc_md.tce_build = tce_buildmulti_pSeriesLP; 552 ppc_md.tce_free = tce_freemulti_pSeriesLP; 553 } else {
··· 45 #include <asm/plpar_wrappers.h> 46 #include <asm/pSeries_reconfig.h> 47 #include <asm/systemcfg.h> 48 + #include <asm/firmware.h> 49 #include "pci.h" 50 51 #define DBG(fmt...) ··· 546 } 547 548 if (systemcfg->platform & PLATFORM_LPAR) { 549 + if (firmware_has_feature(FW_FEATURE_MULTITCE)) { 550 ppc_md.tce_build = tce_buildmulti_pSeriesLP; 551 ppc_md.tce_free = tce_freemulti_pSeriesLP; 552 } else {
+3 -3
arch/ppc64/kernel/pSeries_setup.c
··· 60 #include <asm/nvram.h> 61 #include <asm/plpar_wrappers.h> 62 #include <asm/xics.h> 63 - #include <asm/cputable.h> 64 65 #include "i8259.h" 66 #include "mpic.h" ··· 231 232 pSeries_nvram_init(); 233 234 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) 235 vpa_init(boot_cpuid); 236 237 /* Choose an idle loop */ 238 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) { 239 if (get_paca()->lppaca.shared_proc) { 240 printk(KERN_INFO "Using shared processor idle loop\n"); 241 ppc_md.idle_loop = pseries_shared_idle;
··· 60 #include <asm/nvram.h> 61 #include <asm/plpar_wrappers.h> 62 #include <asm/xics.h> 63 + #include <asm/firmware.h> 64 65 #include "i8259.h" 66 #include "mpic.h" ··· 231 232 pSeries_nvram_init(); 233 234 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) 235 vpa_init(boot_cpuid); 236 237 /* Choose an idle loop */ 238 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 239 if (get_paca()->lppaca.shared_proc) { 240 printk(KERN_INFO "Using shared processor idle loop\n"); 241 ppc_md.idle_loop = pseries_shared_idle;
+2 -1
arch/ppc64/kernel/pSeries_smp.c
··· 41 #include <asm/machdep.h> 42 #include <asm/xics.h> 43 #include <asm/cputable.h> 44 #include <asm/system.h> 45 #include <asm/rtas.h> 46 #include <asm/plpar_wrappers.h> ··· 327 if (cpu != boot_cpuid) 328 xics_setup_cpu(); 329 330 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) 331 vpa_init(cpu); 332 333 cpu_clear(cpu, of_spin_map);
··· 41 #include <asm/machdep.h> 42 #include <asm/xics.h> 43 #include <asm/cputable.h> 44 + #include <asm/firmware.h> 45 #include <asm/system.h> 46 #include <asm/rtas.h> 47 #include <asm/plpar_wrappers.h> ··· 326 if (cpu != boot_cpuid) 327 xics_setup_cpu(); 328 329 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) 330 vpa_init(cpu); 331 332 cpu_clear(cpu, of_spin_map);
+2 -1
arch/ppc64/kernel/process.c
··· 50 #include <asm/machdep.h> 51 #include <asm/iSeries/HvCallHpt.h> 52 #include <asm/cputable.h> 53 #include <asm/sections.h> 54 #include <asm/tlbflush.h> 55 #include <asm/time.h> ··· 207 /* purr is nothing but processor time base */ 208 209 #if defined(CONFIG_PPC_PSERIES) 210 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) { 211 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 212 long unsigned start_tb, current_tb; 213 start_tb = old_thread->start_tb;
··· 50 #include <asm/machdep.h> 51 #include <asm/iSeries/HvCallHpt.h> 52 #include <asm/cputable.h> 53 + #include <asm/firmware.h> 54 #include <asm/sections.h> 55 #include <asm/tlbflush.h> 56 #include <asm/time.h> ··· 206 /* purr is nothing but processor time base */ 207 208 #if defined(CONFIG_PPC_PSERIES) 209 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 210 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 211 long unsigned start_tb, current_tb; 212 start_tb = old_thread->start_tb;
+2 -1
arch/ppc64/kernel/sysfs.c
··· 13 #include <asm/current.h> 14 #include <asm/processor.h> 15 #include <asm/cputable.h> 16 #include <asm/hvcall.h> 17 #include <asm/prom.h> 18 #include <asm/systemcfg.h> ··· 155 156 #ifdef CONFIG_PPC_PSERIES 157 /* instruct hypervisor to maintain PMCs */ 158 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) 159 get_paca()->lppaca.pmcregs_in_use = 1; 160 #endif /* CONFIG_PPC_PSERIES */ 161 }
··· 13 #include <asm/current.h> 14 #include <asm/processor.h> 15 #include <asm/cputable.h> 16 + #include <asm/firmware.h> 17 #include <asm/hvcall.h> 18 #include <asm/prom.h> 19 #include <asm/systemcfg.h> ··· 154 155 #ifdef CONFIG_PPC_PSERIES 156 /* instruct hypervisor to maintain PMCs */ 157 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) 158 get_paca()->lppaca.pmcregs_in_use = 1; 159 #endif /* CONFIG_PPC_PSERIES */ 160 }
+2 -1
arch/ppc64/kernel/time.c
··· 67 #include <asm/prom.h> 68 #include <asm/sections.h> 69 #include <asm/systemcfg.h> 70 71 u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES; 72 ··· 373 374 /* collect purr register values often, for accurate calculations */ 375 #if defined(CONFIG_PPC_PSERIES) 376 - if (ppc64_firmware_features & FW_FEATURE_SPLPAR) { 377 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 378 cu->current_tb = mfspr(SPRN_PURR); 379 }
··· 67 #include <asm/prom.h> 68 #include <asm/sections.h> 69 #include <asm/systemcfg.h> 70 + #include <asm/firmware.h> 71 72 u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES; 73 ··· 372 373 /* collect purr register values often, for accurate calculations */ 374 #if defined(CONFIG_PPC_PSERIES) 375 + if (firmware_has_feature(FW_FEATURE_SPLPAR)) { 376 struct cpu_usage *cu = &__get_cpu_var(cpu_usage_array); 377 cu->current_tb = mfspr(SPRN_PURR); 378 }
+3 -44
include/asm-ppc64/cputable.h
··· 66 return cur_cpu_spec->cpu_features & feature; 67 } 68 69 - 70 - /* This is used to identify firmware features which are available 71 - * to the kernel. 72 - */ 73 - extern unsigned long ppc64_firmware_features; 74 - 75 - /* firmware feature bitmask values */ 76 - #define FIRMWARE_MAX_FEATURES 63 77 - 78 - #define FW_FEATURE_PFT (1UL<<0) 79 - #define FW_FEATURE_TCE (1UL<<1) 80 - #define FW_FEATURE_SPRG0 (1UL<<2) 81 - #define FW_FEATURE_DABR (1UL<<3) 82 - #define FW_FEATURE_COPY (1UL<<4) 83 - #define FW_FEATURE_ASR (1UL<<5) 84 - #define FW_FEATURE_DEBUG (1UL<<6) 85 - #define FW_FEATURE_TERM (1UL<<7) 86 - #define FW_FEATURE_PERF (1UL<<8) 87 - #define FW_FEATURE_DUMP (1UL<<9) 88 - #define FW_FEATURE_INTERRUPT (1UL<<10) 89 - #define FW_FEATURE_MIGRATE (1UL<<11) 90 - #define FW_FEATURE_PERFMON (1UL<<12) 91 - #define FW_FEATURE_CRQ (1UL<<13) 92 - #define FW_FEATURE_VIO (1UL<<14) 93 - #define FW_FEATURE_RDMA (1UL<<15) 94 - #define FW_FEATURE_LLAN (1UL<<16) 95 - #define FW_FEATURE_BULK (1UL<<17) 96 - #define FW_FEATURE_XDABR (1UL<<18) 97 - #define FW_FEATURE_MULTITCE (1UL<<19) 98 - #define FW_FEATURE_SPLPAR (1UL<<20) 99 - 100 - typedef struct { 101 - unsigned long val; 102 - char * name; 103 - } firmware_feature_t; 104 - 105 - extern firmware_feature_t firmware_features_table[]; 106 - 107 #endif /* __ASSEMBLY__ */ 108 109 /* CPU kernel features */ ··· 102 #define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000) 103 #define CPU_FTR_CTRL ASM_CONST(0x0000100000000000) 104 105 - /* Platform firmware features */ 106 - #define FW_FTR_ ASM_CONST(0x0000000000000001) 107 - 108 #ifndef __ASSEMBLY__ 109 #define COMMON_USER_PPC64 (PPC_FEATURE_32 | PPC_FEATURE_64 | \ 110 PPC_FEATURE_HAS_FPU | PPC_FEATURE_HAS_MMU) 111 ··· 116 #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE) 117 #else 118 #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE | CPU_FTR_16M_PAGE) 119 - #endif 120 121 - #define COMMON_PPC64_FW (0) 122 - #endif 123 124 #ifdef __ASSEMBLY__ 125
··· 66 return cur_cpu_spec->cpu_features & feature; 67 } 68 69 #endif /* __ASSEMBLY__ */ 70 71 /* CPU kernel features */ ··· 140 #define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000) 141 #define CPU_FTR_CTRL ASM_CONST(0x0000100000000000) 142 143 #ifndef __ASSEMBLY__ 144 + 145 #define COMMON_USER_PPC64 (PPC_FEATURE_32 | PPC_FEATURE_64 | \ 146 PPC_FEATURE_HAS_FPU | PPC_FEATURE_HAS_MMU) 147 ··· 156 #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE) 157 #else 158 #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE | CPU_FTR_16M_PAGE) 159 + #endif /* CONFIG_PPC_ISERIES */ 160 161 + #endif /* __ASSEMBLY */ 162 163 #ifdef __ASSEMBLY__ 164
+67
include/asm-ppc64/firmware.h
···
··· 1 + /* 2 + * include/asm-ppc64/firmware.h 3 + * 4 + * Extracted from include/asm-ppc64/cputable.h 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 + * 11 + * This program is free software; you can redistribute it and/or 12 + * modify it under the terms of the GNU General Public License 13 + * as published by the Free Software Foundation; either version 14 + * 2 of the License, or (at your option) any later version. 15 + */ 16 + #ifndef __ASM_PPC_FIRMWARE_H 17 + #define __ASM_PPC_FIRMWARE_H 18 + 19 + #ifdef __KERNEL__ 20 + 21 + #ifndef __ASSEMBLY__ 22 + 23 + /* firmware feature bitmask values */ 24 + #define FIRMWARE_MAX_FEATURES 63 25 + 26 + #define FW_FEATURE_PFT (1UL<<0) 27 + #define FW_FEATURE_TCE (1UL<<1) 28 + #define FW_FEATURE_SPRG0 (1UL<<2) 29 + #define FW_FEATURE_DABR (1UL<<3) 30 + #define FW_FEATURE_COPY (1UL<<4) 31 + #define FW_FEATURE_ASR (1UL<<5) 32 + #define FW_FEATURE_DEBUG (1UL<<6) 33 + #define FW_FEATURE_TERM (1UL<<7) 34 + #define FW_FEATURE_PERF (1UL<<8) 35 + #define FW_FEATURE_DUMP (1UL<<9) 36 + #define FW_FEATURE_INTERRUPT (1UL<<10) 37 + #define FW_FEATURE_MIGRATE (1UL<<11) 38 + #define FW_FEATURE_PERFMON (1UL<<12) 39 + #define FW_FEATURE_CRQ (1UL<<13) 40 + #define FW_FEATURE_VIO (1UL<<14) 41 + #define FW_FEATURE_RDMA (1UL<<15) 42 + #define FW_FEATURE_LLAN (1UL<<16) 43 + #define FW_FEATURE_BULK (1UL<<17) 44 + #define FW_FEATURE_XDABR (1UL<<18) 45 + #define FW_FEATURE_MULTITCE (1UL<<19) 46 + #define FW_FEATURE_SPLPAR (1UL<<20) 47 + 48 + /* This is used to identify firmware features which are available 49 + * to the kernel. 50 + */ 51 + extern unsigned long ppc64_firmware_features; 52 + 53 + static inline unsigned long firmware_has_feature(unsigned long feature) 54 + { 55 + return ppc64_firmware_features & feature; 56 + } 57 + 58 + typedef struct { 59 + unsigned long val; 60 + char * name; 61 + } firmware_feature_t; 62 + 63 + extern firmware_feature_t firmware_features_table[]; 64 + 65 + #endif /* __ASSEMBLY__ */ 66 + #endif /* __KERNEL__ */ 67 + #endif /* __ASM_PPC_FIRMWARE_H */