diff options
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/asm-offsets.c | 2 | ||||
-rw-r--r-- | arch/s390/kernel/compat_linux.c | 18 | ||||
-rw-r--r-- | arch/s390/kernel/compat_wrapper.S | 18 | ||||
-rw-r--r-- | arch/s390/kernel/early.c | 19 | ||||
-rw-r--r-- | arch/s390/kernel/entry.S | 13 | ||||
-rw-r--r-- | arch/s390/kernel/entry64.S | 13 | ||||
-rw-r--r-- | arch/s390/kernel/head.S | 15 | ||||
-rw-r--r-- | arch/s390/kernel/nmi.c | 5 | ||||
-rw-r--r-- | arch/s390/kernel/setup.c | 12 | ||||
-rw-r--r-- | arch/s390/kernel/smp.c | 4 | ||||
-rw-r--r-- | arch/s390/kernel/syscalls.S | 2 | ||||
-rw-r--r-- | arch/s390/kernel/time.c | 77 | ||||
-rw-r--r-- | arch/s390/kernel/vtime.c | 67 |
13 files changed, 185 insertions, 80 deletions
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 67a60016babb..fa9905ce7d0b 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c | |||
@@ -27,6 +27,8 @@ int main(void) | |||
27 | DEFINE(__TI_flags, offsetof(struct thread_info, flags)); | 27 | DEFINE(__TI_flags, offsetof(struct thread_info, flags)); |
28 | DEFINE(__TI_cpu, offsetof(struct thread_info, cpu)); | 28 | DEFINE(__TI_cpu, offsetof(struct thread_info, cpu)); |
29 | DEFINE(__TI_precount, offsetof(struct thread_info, preempt_count)); | 29 | DEFINE(__TI_precount, offsetof(struct thread_info, preempt_count)); |
30 | DEFINE(__TI_user_timer, offsetof(struct thread_info, user_timer)); | ||
31 | DEFINE(__TI_system_timer, offsetof(struct thread_info, system_timer)); | ||
30 | BLANK(); | 32 | BLANK(); |
31 | DEFINE(__PT_ARGS, offsetof(struct pt_regs, args)); | 33 | DEFINE(__PT_ARGS, offsetof(struct pt_regs, args)); |
32 | DEFINE(__PT_PSW, offsetof(struct pt_regs, psw)); | 34 | DEFINE(__PT_PSW, offsetof(struct pt_regs, psw)); |
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index 6cc87d8c8682..002c70d3cb75 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c | |||
@@ -702,20 +702,12 @@ asmlinkage long sys32_fstatat64(unsigned int dfd, char __user *filename, | |||
702 | struct stat64_emu31 __user* statbuf, int flag) | 702 | struct stat64_emu31 __user* statbuf, int flag) |
703 | { | 703 | { |
704 | struct kstat stat; | 704 | struct kstat stat; |
705 | int error = -EINVAL; | 705 | int error; |
706 | |||
707 | if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) | ||
708 | goto out; | ||
709 | |||
710 | if (flag & AT_SYMLINK_NOFOLLOW) | ||
711 | error = vfs_lstat_fd(dfd, filename, &stat); | ||
712 | else | ||
713 | error = vfs_stat_fd(dfd, filename, &stat); | ||
714 | 706 | ||
715 | if (!error) | 707 | error = vfs_fstatat(dfd, filename, &stat, flag); |
716 | error = cp_stat64(statbuf, &stat); | 708 | if (error) |
717 | out: | 709 | return error; |
718 | return error; | 710 | return cp_stat64(statbuf, &stat); |
719 | } | 711 | } |
720 | 712 | ||
721 | /* | 713 | /* |
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S index 87cf5a79a351..fb38af6316bb 100644 --- a/arch/s390/kernel/compat_wrapper.S +++ b/arch/s390/kernel/compat_wrapper.S | |||
@@ -1805,3 +1805,21 @@ compat_sys_keyctl_wrapper: | |||
1805 | llgfr %r5,%r5 # u32 | 1805 | llgfr %r5,%r5 # u32 |
1806 | llgfr %r6,%r6 # u32 | 1806 | llgfr %r6,%r6 # u32 |
1807 | jg compat_sys_keyctl # branch to system call | 1807 | jg compat_sys_keyctl # branch to system call |
1808 | |||
1809 | .globl compat_sys_preadv_wrapper | ||
1810 | compat_sys_preadv_wrapper: | ||
1811 | llgfr %r2,%r2 # unsigned long | ||
1812 | llgtr %r3,%r3 # compat_iovec * | ||
1813 | llgfr %r4,%r4 # unsigned long | ||
1814 | llgfr %r5,%r5 # u32 | ||
1815 | llgfr %r6,%r6 # u32 | ||
1816 | jg compat_sys_preadv # branch to system call | ||
1817 | |||
1818 | .globl compat_sys_pwritev_wrapper | ||
1819 | compat_sys_pwritev_wrapper: | ||
1820 | llgfr %r2,%r2 # unsigned long | ||
1821 | llgtr %r3,%r3 # compat_iovec * | ||
1822 | llgfr %r4,%r4 # unsigned long | ||
1823 | llgfr %r5,%r5 # u32 | ||
1824 | llgfr %r6,%r6 # u32 | ||
1825 | jg compat_sys_pwritev # branch to system call | ||
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c index 4d221c81c849..cf09948faad6 100644 --- a/arch/s390/kernel/early.c +++ b/arch/s390/kernel/early.c | |||
@@ -34,8 +34,25 @@ | |||
34 | 34 | ||
35 | char kernel_nss_name[NSS_NAME_SIZE + 1]; | 35 | char kernel_nss_name[NSS_NAME_SIZE + 1]; |
36 | 36 | ||
37 | static unsigned long machine_flags; | ||
38 | |||
37 | static void __init setup_boot_command_line(void); | 39 | static void __init setup_boot_command_line(void); |
38 | 40 | ||
41 | /* | ||
42 | * Get the TOD clock running. | ||
43 | */ | ||
44 | static void __init reset_tod_clock(void) | ||
45 | { | ||
46 | u64 time; | ||
47 | |||
48 | if (store_clock(&time) == 0) | ||
49 | return; | ||
50 | /* TOD clock not running. Set the clock to Unix Epoch. */ | ||
51 | if (set_clock(TOD_UNIX_EPOCH) != 0 || store_clock(&time) != 0) | ||
52 | disabled_wait(0); | ||
53 | |||
54 | sched_clock_base_cc = TOD_UNIX_EPOCH; | ||
55 | } | ||
39 | 56 | ||
40 | #ifdef CONFIG_SHARED_KERNEL | 57 | #ifdef CONFIG_SHARED_KERNEL |
41 | int __init savesys_ipl_nss(char *cmd, const int cmdlen); | 58 | int __init savesys_ipl_nss(char *cmd, const int cmdlen); |
@@ -370,6 +387,7 @@ static void __init setup_boot_command_line(void) | |||
370 | */ | 387 | */ |
371 | void __init startup_init(void) | 388 | void __init startup_init(void) |
372 | { | 389 | { |
390 | reset_tod_clock(); | ||
373 | ipl_save_parameters(); | 391 | ipl_save_parameters(); |
374 | rescue_initrd(); | 392 | rescue_initrd(); |
375 | clear_bss_section(); | 393 | clear_bss_section(); |
@@ -391,5 +409,6 @@ void __init startup_init(void) | |||
391 | setup_hpage(); | 409 | setup_hpage(); |
392 | sclp_facilities_detect(); | 410 | sclp_facilities_detect(); |
393 | detect_memory_layout(memory_chunk); | 411 | detect_memory_layout(memory_chunk); |
412 | S390_lowcore.machine_flags = machine_flags; | ||
394 | lockdep_on(); | 413 | lockdep_on(); |
395 | } | 414 | } |
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index 1268aa2991bf..f3e275934213 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S | |||
@@ -837,16 +837,29 @@ mcck_return: | |||
837 | __CPUINIT | 837 | __CPUINIT |
838 | .globl restart_int_handler | 838 | .globl restart_int_handler |
839 | restart_int_handler: | 839 | restart_int_handler: |
840 | basr %r1,0 | ||
841 | restart_base: | ||
842 | spt restart_vtime-restart_base(%r1) | ||
843 | stck __LC_LAST_UPDATE_CLOCK | ||
844 | mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1) | ||
845 | mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1) | ||
840 | l %r15,__LC_SAVE_AREA+60 # load ksp | 846 | l %r15,__LC_SAVE_AREA+60 # load ksp |
841 | lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs | 847 | lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs |
842 | lam %a0,%a15,__LC_AREGS_SAVE_AREA | 848 | lam %a0,%a15,__LC_AREGS_SAVE_AREA |
843 | lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone | 849 | lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone |
850 | l %r1,__LC_THREAD_INFO | ||
851 | mvc __LC_USER_TIMER(8),__TI_user_timer(%r1) | ||
852 | mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1) | ||
853 | xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER | ||
844 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on | 854 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on |
845 | basr %r14,0 | 855 | basr %r14,0 |
846 | l %r14,restart_addr-.(%r14) | 856 | l %r14,restart_addr-.(%r14) |
847 | br %r14 # branch to start_secondary | 857 | br %r14 # branch to start_secondary |
848 | restart_addr: | 858 | restart_addr: |
849 | .long start_secondary | 859 | .long start_secondary |
860 | .align 8 | ||
861 | restart_vtime: | ||
862 | .long 0x7fffffff,0xffffffff | ||
850 | .previous | 863 | .previous |
851 | #else | 864 | #else |
852 | /* | 865 | /* |
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index c6fbde13971a..84a105838e03 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S | |||
@@ -831,14 +831,27 @@ mcck_return: | |||
831 | __CPUINIT | 831 | __CPUINIT |
832 | .globl restart_int_handler | 832 | .globl restart_int_handler |
833 | restart_int_handler: | 833 | restart_int_handler: |
834 | basr %r1,0 | ||
835 | restart_base: | ||
836 | spt restart_vtime-restart_base(%r1) | ||
837 | stck __LC_LAST_UPDATE_CLOCK | ||
838 | mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1) | ||
839 | mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1) | ||
834 | lg %r15,__LC_SAVE_AREA+120 # load ksp | 840 | lg %r15,__LC_SAVE_AREA+120 # load ksp |
835 | lghi %r10,__LC_CREGS_SAVE_AREA | 841 | lghi %r10,__LC_CREGS_SAVE_AREA |
836 | lctlg %c0,%c15,0(%r10) # get new ctl regs | 842 | lctlg %c0,%c15,0(%r10) # get new ctl regs |
837 | lghi %r10,__LC_AREGS_SAVE_AREA | 843 | lghi %r10,__LC_AREGS_SAVE_AREA |
838 | lam %a0,%a15,0(%r10) | 844 | lam %a0,%a15,0(%r10) |
839 | lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone | 845 | lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone |
846 | lg %r1,__LC_THREAD_INFO | ||
847 | mvc __LC_USER_TIMER(8),__TI_user_timer(%r1) | ||
848 | mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1) | ||
849 | xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER | ||
840 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on | 850 | stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on |
841 | jg start_secondary | 851 | jg start_secondary |
852 | .align 8 | ||
853 | restart_vtime: | ||
854 | .long 0x7fffffff,0xffffffff | ||
842 | .previous | 855 | .previous |
843 | #else | 856 | #else |
844 | /* | 857 | /* |
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index 1046c2c9f8d1..bba14494ee00 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S | |||
@@ -471,7 +471,12 @@ startup:basr %r13,0 # get base | |||
471 | .LPG0: | 471 | .LPG0: |
472 | xc 0x200(256),0x200 # partially clear lowcore | 472 | xc 0x200(256),0x200 # partially clear lowcore |
473 | xc 0x300(256),0x300 | 473 | xc 0x300(256),0x300 |
474 | 474 | l %r1,5f-.LPG0(%r13) | |
475 | stck 0(%r1) | ||
476 | spt 6f-.LPG0(%r13) | ||
477 | mvc __LC_LAST_UPDATE_CLOCK(8),0(%r1) | ||
478 | mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13) | ||
479 | mvc __LC_EXIT_TIMER(8),5f-.LPG0(%r13) | ||
475 | #ifndef CONFIG_MARCH_G5 | 480 | #ifndef CONFIG_MARCH_G5 |
476 | # check processor version against MARCH_{G5,Z900,Z990,Z9_109,Z10} | 481 | # check processor version against MARCH_{G5,Z900,Z990,Z9_109,Z10} |
477 | stidp __LC_CPUID # store cpuid | 482 | stidp __LC_CPUID # store cpuid |
@@ -496,9 +501,13 @@ startup:basr %r13,0 # get base | |||
496 | brct %r0,0b | 501 | brct %r0,0b |
497 | #endif | 502 | #endif |
498 | 503 | ||
499 | l %r13,0f-.LPG0(%r13) | 504 | l %r13,4f-.LPG0(%r13) |
500 | b 0(%r13) | 505 | b 0(%r13) |
501 | 0: .long startup_continue | 506 | .align 4 |
507 | 4: .long startup_continue | ||
508 | 5: .long sched_clock_base_cc | ||
509 | .align 8 | ||
510 | 6: .long 0x7fffffff,0xffffffff | ||
502 | 511 | ||
503 | # | 512 | # |
504 | # params at 10400 (setup.h) | 513 | # params at 10400 (setup.h) |
diff --git a/arch/s390/kernel/nmi.c b/arch/s390/kernel/nmi.c index 4bfdc421d7e9..28cf196ba775 100644 --- a/arch/s390/kernel/nmi.c +++ b/arch/s390/kernel/nmi.c | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
13 | #include <linux/hardirq.h> | ||
13 | #include <linux/time.h> | 14 | #include <linux/time.h> |
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <asm/lowcore.h> | 16 | #include <asm/lowcore.h> |
@@ -253,7 +254,7 @@ void notrace s390_do_machine_check(struct pt_regs *regs) | |||
253 | struct mci *mci; | 254 | struct mci *mci; |
254 | int umode; | 255 | int umode; |
255 | 256 | ||
256 | lockdep_off(); | 257 | nmi_enter(); |
257 | s390_idle_check(); | 258 | s390_idle_check(); |
258 | 259 | ||
259 | mci = (struct mci *) &S390_lowcore.mcck_interruption_code; | 260 | mci = (struct mci *) &S390_lowcore.mcck_interruption_code; |
@@ -363,7 +364,7 @@ void notrace s390_do_machine_check(struct pt_regs *regs) | |||
363 | mcck->warning = 1; | 364 | mcck->warning = 1; |
364 | set_thread_flag(TIF_MCCK_PENDING); | 365 | set_thread_flag(TIF_MCCK_PENDING); |
365 | } | 366 | } |
366 | lockdep_on(); | 367 | nmi_exit(); |
367 | } | 368 | } |
368 | 369 | ||
369 | static int __init machine_check_init(void) | 370 | static int __init machine_check_init(void) |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 06201b93cbbf..7402b6a39ead 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -82,9 +82,6 @@ EXPORT_SYMBOL(console_devno); | |||
82 | unsigned int console_irq = -1; | 82 | unsigned int console_irq = -1; |
83 | EXPORT_SYMBOL(console_irq); | 83 | EXPORT_SYMBOL(console_irq); |
84 | 84 | ||
85 | unsigned long machine_flags; | ||
86 | EXPORT_SYMBOL(machine_flags); | ||
87 | |||
88 | unsigned long elf_hwcap = 0; | 85 | unsigned long elf_hwcap = 0; |
89 | char elf_platform[ELF_PLATFORM_SIZE]; | 86 | char elf_platform[ELF_PLATFORM_SIZE]; |
90 | 87 | ||
@@ -426,6 +423,7 @@ setup_lowcore(void) | |||
426 | __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE; | 423 | __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE; |
427 | lc->current_task = (unsigned long) init_thread_union.thread_info.task; | 424 | lc->current_task = (unsigned long) init_thread_union.thread_info.task; |
428 | lc->thread_info = (unsigned long) &init_thread_union; | 425 | lc->thread_info = (unsigned long) &init_thread_union; |
426 | lc->machine_flags = S390_lowcore.machine_flags; | ||
429 | #ifndef CONFIG_64BIT | 427 | #ifndef CONFIG_64BIT |
430 | if (MACHINE_HAS_IEEE) { | 428 | if (MACHINE_HAS_IEEE) { |
431 | lc->extended_save_area_addr = (__u32) | 429 | lc->extended_save_area_addr = (__u32) |
@@ -436,6 +434,14 @@ setup_lowcore(void) | |||
436 | #else | 434 | #else |
437 | lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0]; | 435 | lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0]; |
438 | #endif | 436 | #endif |
437 | lc->sync_enter_timer = S390_lowcore.sync_enter_timer; | ||
438 | lc->async_enter_timer = S390_lowcore.async_enter_timer; | ||
439 | lc->exit_timer = S390_lowcore.exit_timer; | ||
440 | lc->user_timer = S390_lowcore.user_timer; | ||
441 | lc->system_timer = S390_lowcore.system_timer; | ||
442 | lc->steal_timer = S390_lowcore.steal_timer; | ||
443 | lc->last_update_timer = S390_lowcore.last_update_timer; | ||
444 | lc->last_update_clock = S390_lowcore.last_update_clock; | ||
439 | set_prefix((u32)(unsigned long) lc); | 445 | set_prefix((u32)(unsigned long) lc); |
440 | lowcore_ptr[0] = lc; | 446 | lowcore_ptr[0] = lc; |
441 | } | 447 | } |
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 006ed5016eb4..a985a3ba4401 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c | |||
@@ -571,6 +571,7 @@ int __cpuinit __cpu_up(unsigned int cpu) | |||
571 | cpu_lowcore->current_task = (unsigned long) idle; | 571 | cpu_lowcore->current_task = (unsigned long) idle; |
572 | cpu_lowcore->cpu_nr = cpu; | 572 | cpu_lowcore->cpu_nr = cpu; |
573 | cpu_lowcore->kernel_asce = S390_lowcore.kernel_asce; | 573 | cpu_lowcore->kernel_asce = S390_lowcore.kernel_asce; |
574 | cpu_lowcore->machine_flags = S390_lowcore.machine_flags; | ||
574 | eieio(); | 575 | eieio(); |
575 | 576 | ||
576 | while (signal_processor(cpu, sigp_restart) == sigp_busy) | 577 | while (signal_processor(cpu, sigp_restart) == sigp_busy) |
@@ -590,7 +591,8 @@ static int __init setup_possible_cpus(char *s) | |||
590 | int pcpus, cpu; | 591 | int pcpus, cpu; |
591 | 592 | ||
592 | pcpus = simple_strtoul(s, NULL, 0); | 593 | pcpus = simple_strtoul(s, NULL, 0); |
593 | for (cpu = 0; cpu < pcpus && cpu < nr_cpu_ids; cpu++) | 594 | init_cpu_possible(cpumask_of(0)); |
595 | for (cpu = 1; cpu < pcpus && cpu < nr_cpu_ids; cpu++) | ||
594 | set_cpu_possible(cpu, true); | 596 | set_cpu_possible(cpu, true); |
595 | return 0; | 597 | return 0; |
596 | } | 598 | } |
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S index fe5b25a988ab..2c7739fe70b1 100644 --- a/arch/s390/kernel/syscalls.S +++ b/arch/s390/kernel/syscalls.S | |||
@@ -336,3 +336,5 @@ SYSCALL(sys_inotify_init1,sys_inotify_init1,sys_inotify_init1_wrapper) | |||
336 | SYSCALL(sys_pipe2,sys_pipe2,sys_pipe2_wrapper) /* 325 */ | 336 | SYSCALL(sys_pipe2,sys_pipe2,sys_pipe2_wrapper) /* 325 */ |
337 | SYSCALL(sys_dup3,sys_dup3,sys_dup3_wrapper) | 337 | SYSCALL(sys_dup3,sys_dup3,sys_dup3_wrapper) |
338 | SYSCALL(sys_epoll_create1,sys_epoll_create1,sys_epoll_create1_wrapper) | 338 | SYSCALL(sys_epoll_create1,sys_epoll_create1,sys_epoll_create1_wrapper) |
339 | SYSCALL(sys_preadv,sys_preadv,compat_sys_preadv_wrapper) | ||
340 | SYSCALL(sys_pwritev,sys_pwritev,compat_sys_pwritev_wrapper) | ||
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index f72d41068dc2..6ded50dfa75a 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c | |||
@@ -52,9 +52,6 @@ | |||
52 | #define USECS_PER_JIFFY ((unsigned long) 1000000/HZ) | 52 | #define USECS_PER_JIFFY ((unsigned long) 1000000/HZ) |
53 | #define CLK_TICKS_PER_JIFFY ((unsigned long) USECS_PER_JIFFY << 12) | 53 | #define CLK_TICKS_PER_JIFFY ((unsigned long) USECS_PER_JIFFY << 12) |
54 | 54 | ||
55 | /* The value of the TOD clock for 1.1.1970. */ | ||
56 | #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL | ||
57 | |||
58 | /* | 55 | /* |
59 | * Create a small time difference between the timer interrupts | 56 | * Create a small time difference between the timer interrupts |
60 | * on the different cpus to avoid lock contention. | 57 | * on the different cpus to avoid lock contention. |
@@ -63,9 +60,10 @@ | |||
63 | 60 | ||
64 | #define TICK_SIZE tick | 61 | #define TICK_SIZE tick |
65 | 62 | ||
63 | u64 sched_clock_base_cc = -1; /* Force to data section. */ | ||
64 | |||
66 | static ext_int_info_t ext_int_info_cc; | 65 | static ext_int_info_t ext_int_info_cc; |
67 | static ext_int_info_t ext_int_etr_cc; | 66 | static ext_int_info_t ext_int_etr_cc; |
68 | static u64 sched_clock_base_cc; | ||
69 | 67 | ||
70 | static DEFINE_PER_CPU(struct clock_event_device, comparators); | 68 | static DEFINE_PER_CPU(struct clock_event_device, comparators); |
71 | 69 | ||
@@ -195,22 +193,12 @@ static void timing_alert_interrupt(__u16 code) | |||
195 | static void etr_reset(void); | 193 | static void etr_reset(void); |
196 | static void stp_reset(void); | 194 | static void stp_reset(void); |
197 | 195 | ||
198 | /* | 196 | unsigned long read_persistent_clock(void) |
199 | * Get the TOD clock running. | ||
200 | */ | ||
201 | static u64 __init reset_tod_clock(void) | ||
202 | { | 197 | { |
203 | u64 time; | 198 | struct timespec ts; |
204 | |||
205 | etr_reset(); | ||
206 | stp_reset(); | ||
207 | if (store_clock(&time) == 0) | ||
208 | return time; | ||
209 | /* TOD clock not running. Set the clock to Unix Epoch. */ | ||
210 | if (set_clock(TOD_UNIX_EPOCH) != 0 || store_clock(&time) != 0) | ||
211 | panic("TOD clock not operational."); | ||
212 | 199 | ||
213 | return TOD_UNIX_EPOCH; | 200 | tod_to_timeval(get_clock() - TOD_UNIX_EPOCH, &ts); |
201 | return ts.tv_sec; | ||
214 | } | 202 | } |
215 | 203 | ||
216 | static cycle_t read_tod_clock(void) | 204 | static cycle_t read_tod_clock(void) |
@@ -265,12 +253,13 @@ void update_vsyscall_tz(void) | |||
265 | */ | 253 | */ |
266 | void __init time_init(void) | 254 | void __init time_init(void) |
267 | { | 255 | { |
268 | sched_clock_base_cc = reset_tod_clock(); | 256 | struct timespec ts; |
257 | unsigned long flags; | ||
258 | cycle_t now; | ||
269 | 259 | ||
270 | /* set xtime */ | 260 | /* Reset time synchronization interfaces. */ |
271 | tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, &xtime); | 261 | etr_reset(); |
272 | set_normalized_timespec(&wall_to_monotonic, | 262 | stp_reset(); |
273 | -xtime.tv_sec, -xtime.tv_nsec); | ||
274 | 263 | ||
275 | /* request the clock comparator external interrupt */ | 264 | /* request the clock comparator external interrupt */ |
276 | if (register_early_external_interrupt(0x1004, | 265 | if (register_early_external_interrupt(0x1004, |
@@ -278,17 +267,38 @@ void __init time_init(void) | |||
278 | &ext_int_info_cc) != 0) | 267 | &ext_int_info_cc) != 0) |
279 | panic("Couldn't request external interrupt 0x1004"); | 268 | panic("Couldn't request external interrupt 0x1004"); |
280 | 269 | ||
281 | if (clocksource_register(&clocksource_tod) != 0) | ||
282 | panic("Could not register TOD clock source"); | ||
283 | |||
284 | /* request the timing alert external interrupt */ | 270 | /* request the timing alert external interrupt */ |
285 | if (register_early_external_interrupt(0x1406, | 271 | if (register_early_external_interrupt(0x1406, |
286 | timing_alert_interrupt, | 272 | timing_alert_interrupt, |
287 | &ext_int_etr_cc) != 0) | 273 | &ext_int_etr_cc) != 0) |
288 | panic("Couldn't request external interrupt 0x1406"); | 274 | panic("Couldn't request external interrupt 0x1406"); |
289 | 275 | ||
276 | if (clocksource_register(&clocksource_tod) != 0) | ||
277 | panic("Could not register TOD clock source"); | ||
278 | |||
279 | /* | ||
280 | * The TOD clock is an accurate clock. The xtime should be | ||
281 | * initialized in a way that the difference between TOD and | ||
282 | * xtime is reasonably small. Too bad that timekeeping_init | ||
283 | * sets xtime.tv_nsec to zero. In addition the clock source | ||
284 | * change from the jiffies clock source to the TOD clock | ||
285 | * source add another error of up to 1/HZ second. The same | ||
286 | * function sets wall_to_monotonic to a value that is too | ||
287 | * small for /proc/uptime to be accurate. | ||
288 | * Reset xtime and wall_to_monotonic to sane values. | ||
289 | */ | ||
290 | write_seqlock_irqsave(&xtime_lock, flags); | ||
291 | now = get_clock(); | ||
292 | tod_to_timeval(now - TOD_UNIX_EPOCH, &xtime); | ||
293 | clocksource_tod.cycle_last = now; | ||
294 | clocksource_tod.raw_time = xtime; | ||
295 | tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, &ts); | ||
296 | set_normalized_timespec(&wall_to_monotonic, -ts.tv_sec, -ts.tv_nsec); | ||
297 | write_sequnlock_irqrestore(&xtime_lock, flags); | ||
298 | |||
290 | /* Enable TOD clock interrupts on the boot cpu. */ | 299 | /* Enable TOD clock interrupts on the boot cpu. */ |
291 | init_cpu_timer(); | 300 | init_cpu_timer(); |
301 | |||
292 | /* Enable cpu timer interrupts on the boot cpu. */ | 302 | /* Enable cpu timer interrupts on the boot cpu. */ |
293 | vtime_init(); | 303 | vtime_init(); |
294 | } | 304 | } |
@@ -1423,6 +1433,7 @@ static void *stp_page; | |||
1423 | static void stp_work_fn(struct work_struct *work); | 1433 | static void stp_work_fn(struct work_struct *work); |
1424 | static DEFINE_MUTEX(stp_work_mutex); | 1434 | static DEFINE_MUTEX(stp_work_mutex); |
1425 | static DECLARE_WORK(stp_work, stp_work_fn); | 1435 | static DECLARE_WORK(stp_work, stp_work_fn); |
1436 | static struct timer_list stp_timer; | ||
1426 | 1437 | ||
1427 | static int __init early_parse_stp(char *p) | 1438 | static int __init early_parse_stp(char *p) |
1428 | { | 1439 | { |
@@ -1454,10 +1465,16 @@ static void __init stp_reset(void) | |||
1454 | } | 1465 | } |
1455 | } | 1466 | } |
1456 | 1467 | ||
1468 | static void stp_timeout(unsigned long dummy) | ||
1469 | { | ||
1470 | queue_work(time_sync_wq, &stp_work); | ||
1471 | } | ||
1472 | |||
1457 | static int __init stp_init(void) | 1473 | static int __init stp_init(void) |
1458 | { | 1474 | { |
1459 | if (!test_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags)) | 1475 | if (!test_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags)) |
1460 | return 0; | 1476 | return 0; |
1477 | setup_timer(&stp_timer, stp_timeout, 0UL); | ||
1461 | time_init_wq(); | 1478 | time_init_wq(); |
1462 | if (!stp_online) | 1479 | if (!stp_online) |
1463 | return 0; | 1480 | return 0; |
@@ -1565,6 +1582,7 @@ static void stp_work_fn(struct work_struct *work) | |||
1565 | 1582 | ||
1566 | if (!stp_online) { | 1583 | if (!stp_online) { |
1567 | chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000); | 1584 | chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000); |
1585 | del_timer_sync(&stp_timer); | ||
1568 | goto out_unlock; | 1586 | goto out_unlock; |
1569 | } | 1587 | } |
1570 | 1588 | ||
@@ -1586,6 +1604,13 @@ static void stp_work_fn(struct work_struct *work) | |||
1586 | stop_machine(stp_sync_clock, &stp_sync, &cpu_online_map); | 1604 | stop_machine(stp_sync_clock, &stp_sync, &cpu_online_map); |
1587 | put_online_cpus(); | 1605 | put_online_cpus(); |
1588 | 1606 | ||
1607 | if (!check_sync_clock()) | ||
1608 | /* | ||
1609 | * There is a usable clock but the synchonization failed. | ||
1610 | * Retry after a second. | ||
1611 | */ | ||
1612 | mod_timer(&stp_timer, jiffies + HZ); | ||
1613 | |||
1589 | out_unlock: | 1614 | out_unlock: |
1590 | mutex_unlock(&stp_work_mutex); | 1615 | mutex_unlock(&stp_work_mutex); |
1591 | } | 1616 | } |
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index ecf0304e61c1..38ea92ff04f9 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c | |||
@@ -134,6 +134,8 @@ void vtime_start_cpu(void) | |||
134 | /* Account time spent with enabled wait psw loaded as idle time. */ | 134 | /* Account time spent with enabled wait psw loaded as idle time. */ |
135 | idle_time = S390_lowcore.int_clock - idle->idle_enter; | 135 | idle_time = S390_lowcore.int_clock - idle->idle_enter; |
136 | account_idle_time(idle_time); | 136 | account_idle_time(idle_time); |
137 | S390_lowcore.steal_timer += | ||
138 | idle->idle_enter - S390_lowcore.last_update_clock; | ||
137 | S390_lowcore.last_update_clock = S390_lowcore.int_clock; | 139 | S390_lowcore.last_update_clock = S390_lowcore.int_clock; |
138 | 140 | ||
139 | /* Account system time spent going idle. */ | 141 | /* Account system time spent going idle. */ |
@@ -425,17 +427,7 @@ void add_virt_timer_periodic(void *new) | |||
425 | } | 427 | } |
426 | EXPORT_SYMBOL(add_virt_timer_periodic); | 428 | EXPORT_SYMBOL(add_virt_timer_periodic); |
427 | 429 | ||
428 | /* | 430 | int __mod_vtimer(struct vtimer_list *timer, __u64 expires, int periodic) |
429 | * If we change a pending timer the function must be called on the CPU | ||
430 | * where the timer is running on, e.g. by smp_call_function_single() | ||
431 | * | ||
432 | * The original mod_timer adds the timer if it is not pending. For | ||
433 | * compatibility we do the same. The timer will be added on the current | ||
434 | * CPU as a oneshot timer. | ||
435 | * | ||
436 | * returns whether it has modified a pending timer (1) or not (0) | ||
437 | */ | ||
438 | int mod_virt_timer(struct vtimer_list *timer, __u64 expires) | ||
439 | { | 431 | { |
440 | struct vtimer_queue *vq; | 432 | struct vtimer_queue *vq; |
441 | unsigned long flags; | 433 | unsigned long flags; |
@@ -444,39 +436,35 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires) | |||
444 | BUG_ON(!timer->function); | 436 | BUG_ON(!timer->function); |
445 | BUG_ON(!expires || expires > VTIMER_MAX_SLICE); | 437 | BUG_ON(!expires || expires > VTIMER_MAX_SLICE); |
446 | 438 | ||
447 | /* | ||
448 | * This is a common optimization triggered by the | ||
449 | * networking code - if the timer is re-modified | ||
450 | * to be the same thing then just return: | ||
451 | */ | ||
452 | if (timer->expires == expires && vtimer_pending(timer)) | 439 | if (timer->expires == expires && vtimer_pending(timer)) |
453 | return 1; | 440 | return 1; |
454 | 441 | ||
455 | cpu = get_cpu(); | 442 | cpu = get_cpu(); |
456 | vq = &per_cpu(virt_cpu_timer, cpu); | 443 | vq = &per_cpu(virt_cpu_timer, cpu); |
457 | 444 | ||
458 | /* check if we run on the right CPU */ | ||
459 | BUG_ON(timer->cpu != cpu); | ||
460 | |||
461 | /* disable interrupts before test if timer is pending */ | 445 | /* disable interrupts before test if timer is pending */ |
462 | spin_lock_irqsave(&vq->lock, flags); | 446 | spin_lock_irqsave(&vq->lock, flags); |
463 | 447 | ||
464 | /* if timer isn't pending add it on the current CPU */ | 448 | /* if timer isn't pending add it on the current CPU */ |
465 | if (!vtimer_pending(timer)) { | 449 | if (!vtimer_pending(timer)) { |
466 | spin_unlock_irqrestore(&vq->lock, flags); | 450 | spin_unlock_irqrestore(&vq->lock, flags); |
467 | /* we do not activate an interval timer with mod_virt_timer */ | 451 | |
468 | timer->interval = 0; | 452 | if (periodic) |
453 | timer->interval = expires; | ||
454 | else | ||
455 | timer->interval = 0; | ||
469 | timer->expires = expires; | 456 | timer->expires = expires; |
470 | timer->cpu = cpu; | 457 | timer->cpu = cpu; |
471 | internal_add_vtimer(timer); | 458 | internal_add_vtimer(timer); |
472 | return 0; | 459 | return 0; |
473 | } | 460 | } |
474 | 461 | ||
462 | /* check if we run on the right CPU */ | ||
463 | BUG_ON(timer->cpu != cpu); | ||
464 | |||
475 | list_del_init(&timer->entry); | 465 | list_del_init(&timer->entry); |
476 | timer->expires = expires; | 466 | timer->expires = expires; |
477 | 467 | if (periodic) | |
478 | /* also change the interval if we have an interval timer */ | ||
479 | if (timer->interval) | ||
480 | timer->interval = expires; | 468 | timer->interval = expires; |
481 | 469 | ||
482 | /* the timer can't expire anymore so we can release the lock */ | 470 | /* the timer can't expire anymore so we can release the lock */ |
@@ -484,9 +472,32 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires) | |||
484 | internal_add_vtimer(timer); | 472 | internal_add_vtimer(timer); |
485 | return 1; | 473 | return 1; |
486 | } | 474 | } |
475 | |||
476 | /* | ||
477 | * If we change a pending timer the function must be called on the CPU | ||
478 | * where the timer is running on. | ||
479 | * | ||
480 | * returns whether it has modified a pending timer (1) or not (0) | ||
481 | */ | ||
482 | int mod_virt_timer(struct vtimer_list *timer, __u64 expires) | ||
483 | { | ||
484 | return __mod_vtimer(timer, expires, 0); | ||
485 | } | ||
487 | EXPORT_SYMBOL(mod_virt_timer); | 486 | EXPORT_SYMBOL(mod_virt_timer); |
488 | 487 | ||
489 | /* | 488 | /* |
489 | * If we change a pending timer the function must be called on the CPU | ||
490 | * where the timer is running on. | ||
491 | * | ||
492 | * returns whether it has modified a pending timer (1) or not (0) | ||
493 | */ | ||
494 | int mod_virt_timer_periodic(struct vtimer_list *timer, __u64 expires) | ||
495 | { | ||
496 | return __mod_vtimer(timer, expires, 1); | ||
497 | } | ||
498 | EXPORT_SYMBOL(mod_virt_timer_periodic); | ||
499 | |||
500 | /* | ||
490 | * delete a virtual timer | 501 | * delete a virtual timer |
491 | * | 502 | * |
492 | * returns whether the deleted timer was pending (1) or not (0) | 503 | * returns whether the deleted timer was pending (1) or not (0) |
@@ -516,16 +527,8 @@ EXPORT_SYMBOL(del_virt_timer); | |||
516 | */ | 527 | */ |
517 | void init_cpu_vtimer(void) | 528 | void init_cpu_vtimer(void) |
518 | { | 529 | { |
519 | struct thread_info *ti = current_thread_info(); | ||
520 | struct vtimer_queue *vq; | 530 | struct vtimer_queue *vq; |
521 | 531 | ||
522 | S390_lowcore.user_timer = ti->user_timer; | ||
523 | S390_lowcore.system_timer = ti->system_timer; | ||
524 | |||
525 | /* kick the virtual timer */ | ||
526 | asm volatile ("STCK %0" : "=m" (S390_lowcore.last_update_clock)); | ||
527 | asm volatile ("STPT %0" : "=m" (S390_lowcore.last_update_timer)); | ||
528 | |||
529 | /* initialize per cpu vtimer structure */ | 532 | /* initialize per cpu vtimer structure */ |
530 | vq = &__get_cpu_var(virt_cpu_timer); | 533 | vq = &__get_cpu_var(virt_cpu_timer); |
531 | INIT_LIST_HEAD(&vq->list); | 534 | INIT_LIST_HEAD(&vq->list); |