aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2012-09-04 11:36:16 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2012-09-26 09:45:09 -0400
commit50ab9a9a60fc83b8e8db36b54f365226e2b139ac (patch)
tree7b31ad679ac165144824550b2b6f213d48f63203
parentfade4dc49101e3b68fb375fd2b00d0ef1f31a36f (diff)
s390/smp,topology: add polarization member to pcpu struct
The cpu polarization member is the only per cpu state that is not part of the pcpu structure. So add it there and have everything in one place. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/include/asm/smp.h2
-rw-r--r--arch/s390/include/asm/topology.h18
-rw-r--r--arch/s390/kernel/smp.c23
-rw-r--r--arch/s390/kernel/topology.c11
4 files changed, 25 insertions, 29 deletions
diff --git a/arch/s390/include/asm/smp.h b/arch/s390/include/asm/smp.h
index da7dcd7edf8e..b64f15c3b4cc 100644
--- a/arch/s390/include/asm/smp.h
+++ b/arch/s390/include/asm/smp.h
@@ -30,6 +30,8 @@ extern int smp_vcpu_scheduled(int cpu);
30extern void smp_yield_cpu(int cpu); 30extern void smp_yield_cpu(int cpu);
31extern void smp_yield(void); 31extern void smp_yield(void);
32extern void smp_stop_cpu(void); 32extern void smp_stop_cpu(void);
33extern void smp_cpu_set_polarization(int cpu, int val);
34extern int smp_cpu_get_polarization(int cpu);
33 35
34#else /* CONFIG_SMP */ 36#else /* CONFIG_SMP */
35 37
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index 1e6c446e67e1..9ca305383760 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -51,24 +51,6 @@ static inline void topology_expect_change(void) { }
51#define POLARIZATION_VM (2) 51#define POLARIZATION_VM (2)
52#define POLARIZATION_VH (3) 52#define POLARIZATION_VH (3)
53 53
54extern int cpu_polarization[];
55
56static inline void cpu_set_polarization(int cpu, int val)
57{
58#ifdef CONFIG_SCHED_BOOK
59 cpu_polarization[cpu] = val;
60#endif
61}
62
63static inline int cpu_read_polarization(int cpu)
64{
65#ifdef CONFIG_SCHED_BOOK
66 return cpu_polarization[cpu];
67#else
68 return POLARIZATION_HRZ;
69#endif
70}
71
72#ifdef CONFIG_SCHED_BOOK 54#ifdef CONFIG_SCHED_BOOK
73void s390_init_cpu_topology(void); 55void s390_init_cpu_topology(void);
74#else 56#else
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index c88fe8569e62..8676aab6ea6a 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -66,6 +66,7 @@ struct pcpu {
66 unsigned long panic_stack; /* panic stack for the cpu */ 66 unsigned long panic_stack; /* panic stack for the cpu */
67 unsigned long ec_mask; /* bit mask for ec_xxx functions */ 67 unsigned long ec_mask; /* bit mask for ec_xxx functions */
68 int state; /* physical cpu state */ 68 int state; /* physical cpu state */
69 int polarization; /* physical polarization */
69 u16 address; /* physical cpu address */ 70 u16 address; /* physical cpu address */
70}; 71};
71 72
@@ -73,6 +74,10 @@ static u8 boot_cpu_type;
73static u16 boot_cpu_address; 74static u16 boot_cpu_address;
74static struct pcpu pcpu_devices[NR_CPUS]; 75static struct pcpu pcpu_devices[NR_CPUS];
75 76
77/*
78 * The smp_cpu_state_mutex must be held when changing the state or polarization
79 * member of a pcpu data structure within the pcpu_devices arreay.
80 */
76DEFINE_MUTEX(smp_cpu_state_mutex); 81DEFINE_MUTEX(smp_cpu_state_mutex);
77 82
78/* 83/*
@@ -587,6 +592,16 @@ static inline void smp_get_save_area(int cpu, u16 address) { }
587 592
588#endif /* CONFIG_ZFCPDUMP || CONFIG_CRASH_DUMP */ 593#endif /* CONFIG_ZFCPDUMP || CONFIG_CRASH_DUMP */
589 594
595void smp_cpu_set_polarization(int cpu, int val)
596{
597 pcpu_devices[cpu].polarization = val;
598}
599
600int smp_cpu_get_polarization(int cpu)
601{
602 return pcpu_devices[cpu].polarization;
603}
604
590static struct sclp_cpu_info *smp_get_cpu_info(void) 605static struct sclp_cpu_info *smp_get_cpu_info(void)
591{ 606{
592 static int use_sigp_detection; 607 static int use_sigp_detection;
@@ -629,7 +644,7 @@ static int __devinit __smp_rescan_cpus(struct sclp_cpu_info *info,
629 pcpu->address = info->cpu[i].address; 644 pcpu->address = info->cpu[i].address;
630 pcpu->state = (cpu >= info->configured) ? 645 pcpu->state = (cpu >= info->configured) ?
631 CPU_STATE_STANDBY : CPU_STATE_CONFIGURED; 646 CPU_STATE_STANDBY : CPU_STATE_CONFIGURED;
632 cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); 647 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
633 set_cpu_present(cpu, true); 648 set_cpu_present(cpu, true);
634 if (sysfs_add && smp_add_present_cpu(cpu) != 0) 649 if (sysfs_add && smp_add_present_cpu(cpu) != 0)
635 set_cpu_present(cpu, false); 650 set_cpu_present(cpu, false);
@@ -797,7 +812,7 @@ void __init smp_prepare_boot_cpu(void)
797 pcpu->async_stack = S390_lowcore.async_stack - ASYNC_SIZE; 812 pcpu->async_stack = S390_lowcore.async_stack - ASYNC_SIZE;
798 pcpu->panic_stack = S390_lowcore.panic_stack - PAGE_SIZE; 813 pcpu->panic_stack = S390_lowcore.panic_stack - PAGE_SIZE;
799 S390_lowcore.percpu_offset = __per_cpu_offset[0]; 814 S390_lowcore.percpu_offset = __per_cpu_offset[0];
800 cpu_set_polarization(0, POLARIZATION_UNKNOWN); 815 smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN);
801 set_cpu_present(0, true); 816 set_cpu_present(0, true);
802 set_cpu_online(0, true); 817 set_cpu_online(0, true);
803} 818}
@@ -863,7 +878,7 @@ static ssize_t cpu_configure_store(struct device *dev,
863 if (rc) 878 if (rc)
864 break; 879 break;
865 pcpu->state = CPU_STATE_STANDBY; 880 pcpu->state = CPU_STATE_STANDBY;
866 cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); 881 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
867 topology_expect_change(); 882 topology_expect_change();
868 break; 883 break;
869 case 1: 884 case 1:
@@ -873,7 +888,7 @@ static ssize_t cpu_configure_store(struct device *dev,
873 if (rc) 888 if (rc)
874 break; 889 break;
875 pcpu->state = CPU_STATE_CONFIGURED; 890 pcpu->state = CPU_STATE_CONFIGURED;
876 cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); 891 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
877 topology_expect_change(); 892 topology_expect_change();
878 break; 893 break;
879 default: 894 default:
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 80ca4ba759f6..30c8533b8d4e 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -45,9 +45,6 @@ static struct mask_info book_info;
45cpumask_t cpu_book_map[NR_CPUS]; 45cpumask_t cpu_book_map[NR_CPUS];
46unsigned char cpu_book_id[NR_CPUS]; 46unsigned char cpu_book_id[NR_CPUS];
47 47
48/* smp_cpu_state_mutex must be held when accessing this array */
49int cpu_polarization[NR_CPUS];
50
51static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu) 48static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
52{ 49{
53 cpumask_t mask; 50 cpumask_t mask;
@@ -95,7 +92,7 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
95 } else { 92 } else {
96 cpu_core_id[lcpu] = core->id; 93 cpu_core_id[lcpu] = core->id;
97 } 94 }
98 cpu_set_polarization(lcpu, tl_cpu->pp); 95 smp_cpu_set_polarization(lcpu, tl_cpu->pp);
99 } 96 }
100 } 97 }
101 return core; 98 return core;
@@ -202,7 +199,7 @@ static void topology_update_polarization_simple(void)
202 199
203 mutex_lock(&smp_cpu_state_mutex); 200 mutex_lock(&smp_cpu_state_mutex);
204 for_each_possible_cpu(cpu) 201 for_each_possible_cpu(cpu)
205 cpu_set_polarization(cpu, POLARIZATION_HRZ); 202 smp_cpu_set_polarization(cpu, POLARIZATION_HRZ);
206 mutex_unlock(&smp_cpu_state_mutex); 203 mutex_unlock(&smp_cpu_state_mutex);
207} 204}
208 205
@@ -232,7 +229,7 @@ int topology_set_cpu_management(int fc)
232 if (rc) 229 if (rc)
233 return -EBUSY; 230 return -EBUSY;
234 for_each_possible_cpu(cpu) 231 for_each_possible_cpu(cpu)
235 cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); 232 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
236 return rc; 233 return rc;
237} 234}
238 235
@@ -414,7 +411,7 @@ static ssize_t cpu_polarization_show(struct device *dev,
414 ssize_t count; 411 ssize_t count;
415 412
416 mutex_lock(&smp_cpu_state_mutex); 413 mutex_lock(&smp_cpu_state_mutex);
417 switch (cpu_read_polarization(cpu)) { 414 switch (smp_cpu_get_polarization(cpu)) {
418 case POLARIZATION_HRZ: 415 case POLARIZATION_HRZ:
419 count = sprintf(buf, "horizontal\n"); 416 count = sprintf(buf, "horizontal\n");
420 break; 417 break;