aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2014-10-01 04:57:57 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-10-09 03:14:03 -0400
commitb5f87f15e20092c060f465b283b07a76af7f2e5f (patch)
treef6a7b227a09ce5fd47e28113e0f48208654dd82c
parentfe0f49768d807a8fe6336b097feb8c4441951710 (diff)
s390/idle: consolidate idle functions and definitions
Move the C functions and definitions related to the idle state handling to arch/s390/include/asm/idle.h and arch/s390/kernel/idle.c. The function s390_get_idle_time is renamed to arch_cpu_idle_time and vtime_stop_cpu to enabled_wait. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/include/asm/cputime.h18
-rw-r--r--arch/s390/include/asm/idle.h26
-rw-r--r--arch/s390/include/asm/processor.h7
-rw-r--r--arch/s390/include/asm/vtimer.h2
-rw-r--r--arch/s390/kernel/Makefile2
-rw-r--r--arch/s390/kernel/asm-offsets.c2
-rw-r--r--arch/s390/kernel/entry.h2
-rw-r--r--arch/s390/kernel/idle.c124
-rw-r--r--arch/s390/kernel/process.c24
-rw-r--r--arch/s390/kernel/smp.c39
-rw-r--r--arch/s390/kernel/vtime.c60
-rw-r--r--arch/s390/lib/delay.c4
12 files changed, 166 insertions, 144 deletions
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 01887b1fade5..1c016a5fa97e 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -8,8 +8,6 @@
8#define _S390_CPUTIME_H 8#define _S390_CPUTIME_H
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/percpu.h>
12#include <linux/spinlock.h>
13#include <asm/div64.h> 11#include <asm/div64.h>
14 12
15 13
@@ -165,20 +163,8 @@ static inline clock_t cputime64_to_clock_t(cputime64_t cputime)
165 return clock; 163 return clock;
166} 164}
167 165
168struct s390_idle_data { 166cputime64_t arch_cpu_idle_time(int cpu);
169 unsigned int sequence;
170 unsigned long long idle_count;
171 unsigned long long idle_time;
172 unsigned long long clock_idle_enter;
173 unsigned long long clock_idle_exit;
174 unsigned long long timer_idle_enter;
175 unsigned long long timer_idle_exit;
176};
177 167
178DECLARE_PER_CPU(struct s390_idle_data, s390_idle); 168#define arch_idle_time(cpu) arch_cpu_idle_time(cpu)
179
180cputime64_t s390_get_idle_time(int cpu);
181
182#define arch_idle_time(cpu) s390_get_idle_time(cpu)
183 169
184#endif /* _S390_CPUTIME_H */ 170#endif /* _S390_CPUTIME_H */
diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h
new file mode 100644
index 000000000000..6af037f574b8
--- /dev/null
+++ b/arch/s390/include/asm/idle.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright IBM Corp. 2014
3 *
4 * Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
5 */
6
7#ifndef _S390_IDLE_H
8#define _S390_IDLE_H
9
10#include <linux/types.h>
11#include <linux/device.h>
12
13struct s390_idle_data {
14 unsigned int sequence;
15 unsigned long long idle_count;
16 unsigned long long idle_time;
17 unsigned long long clock_idle_enter;
18 unsigned long long clock_idle_exit;
19 unsigned long long timer_idle_enter;
20 unsigned long long timer_idle_exit;
21};
22
23extern struct device_attribute dev_attr_idle_count;
24extern struct device_attribute dev_attr_idle_time_us;
25
26#endif /* _S390_IDLE_H */
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index bc796d73129b..3d0871058306 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -289,7 +289,12 @@ static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc)
289 return (psw.addr - ilc) & mask; 289 return (psw.addr - ilc) & mask;
290#endif 290#endif
291} 291}
292 292
293/*
294 * Function to stop a processor until the next interrupt occurs
295 */
296void enabled_wait(void);
297
293/* 298/*
294 * Function to drop a processor into disabled wait state 299 * Function to drop a processor into disabled wait state
295 */ 300 */
diff --git a/arch/s390/include/asm/vtimer.h b/arch/s390/include/asm/vtimer.h
index bfe25d513ad2..10a179af62d8 100644
--- a/arch/s390/include/asm/vtimer.h
+++ b/arch/s390/include/asm/vtimer.h
@@ -28,6 +28,4 @@ extern int del_virt_timer(struct vtimer_list *timer);
28extern void init_cpu_vtimer(void); 28extern void init_cpu_vtimer(void);
29extern void vtime_init(void); 29extern void vtime_init(void);
30 30
31extern void vtime_stop_cpu(void);
32
33#endif /* _ASM_S390_TIMER_H */ 31#endif /* _ASM_S390_TIMER_H */
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 3249e1f36d55..c249785669f3 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -28,7 +28,7 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
28 28
29CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w 29CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w
30 30
31obj-y := traps.o time.o process.o base.o early.o setup.o vtime.o 31obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
32obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o 32obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
33obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o 33obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o
34obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o 34obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index 3e9e479d9b49..ef279a136801 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -9,7 +9,7 @@
9#include <linux/kbuild.h> 9#include <linux/kbuild.h>
10#include <linux/kvm_host.h> 10#include <linux/kvm_host.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <asm/cputime.h> 12#include <asm/idle.h>
13#include <asm/vdso.h> 13#include <asm/vdso.h>
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15 15
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index 58541633b8d6..cd68869f9504 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -4,7 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/signal.h> 5#include <linux/signal.h>
6#include <asm/ptrace.h> 6#include <asm/ptrace.h>
7#include <asm/cputime.h> 7#include <asm/idle.h>
8 8
9extern void *restart_stack; 9extern void *restart_stack;
10extern unsigned long suspend_zero_pages; 10extern unsigned long suspend_zero_pages;
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
new file mode 100644
index 000000000000..c846aee7372f
--- /dev/null
+++ b/arch/s390/kernel/idle.c
@@ -0,0 +1,124 @@
1/*
2 * Idle functions for s390.
3 *
4 * Copyright IBM Corp. 2014
5 *
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 */
8
9#include <linux/kernel.h>
10#include <linux/kernel_stat.h>
11#include <linux/kprobes.h>
12#include <linux/notifier.h>
13#include <linux/init.h>
14#include <linux/cpu.h>
15#include <asm/cputime.h>
16#include <asm/nmi.h>
17#include <asm/smp.h>
18#include "entry.h"
19
20static DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
21
22void __kprobes enabled_wait(void)
23{
24 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
25 unsigned long long idle_time;
26 unsigned long psw_mask;
27
28 trace_hardirqs_on();
29
30 /* Wait for external, I/O or machine check interrupt. */
31 psw_mask = PSW_KERNEL_BITS | PSW_MASK_WAIT | PSW_MASK_DAT |
32 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
33 clear_cpu_flag(CIF_NOHZ_DELAY);
34
35 /* Call the assembler magic in entry.S */
36 psw_idle(idle, psw_mask);
37
38 /* Account time spent with enabled wait psw loaded as idle time. */
39 idle->sequence++;
40 smp_wmb();
41 idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
42 idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
43 idle->idle_time += idle_time;
44 idle->idle_count++;
45 account_idle_time(idle_time);