Alpha support for QEMU
Subsystems (2)
cover Alpha support for QEMU
While there are 3 patches in this series that are specifically related to QEMU, there are 3 more that significantly re-architect generic parts of arch/alpha that hopefully bring them more into line with current linux-kernel design, and 2 more that seem like they ought to work generically, but ought to be tested on real hardware. In particular:
1/10: Ought to have no effect on real hw, since the "interrupt handling"
was a printk.
5/10: Ought to work, and result in cooler cpus, on real hardware. That
said, excersising parts of random PALcodes on misc machines is surely doomed to failure. I can well imagine that we'll need some sort of black/white-list for the various machines.
6/10: Ought to work better for Marvel, since more accesses to the RTC
are now being vectored across the smp-call. OTOH, I could have introduced a silly typo somewhere.
9/10: Probably the most significant cleanup, and the one most likely to
have something subtle go wrong on the various machines.
The series seems pretty stable under QEMU, but I have no real hardware on which to test -- the whole reason I'm interested in QEMU of course. So I'm hoping that someone will notice this and help me out with testing.
In addition, if folks more familiar with the various kernel/time or driver/rtc interfaces spot anything I'm doing wrong in the rewrite, please let me know.
r~
Richard Henderson (10):
alpha: Don't if-out dp264_device_interrupt.
alpha: Notice if we're being run under QEMU
alpha: Force the user-visible HZ to a constant 1024.
alpha: Allow HZ to be configured
alpha: Primitive support for CPU power down.
alpha: Reorganize rtc handling
alpha: Add an rtc driver for the qemu wallclock PALcall
alpha: Always enable the rpcc clocksource for single processor
alpha: Switch to GENERIC_CLOCKEVENTS
alpha: Use qemu+cserve provided high-res clock and alarm.
arch/alpha/Kconfig | 52 ++++- arch/alpha/include/asm/machvec.h | 22 +- arch/alpha/include/asm/pal.h | 71 +++++++ arch/alpha/include/asm/param.h | 8 +- arch/alpha/include/asm/rtc.h | 11 - arch/alpha/include/uapi/asm/pal.h | 1 + arch/alpha/include/uapi/asm/param.h | 7 - arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/irq_alpha.c | 16 +- arch/alpha/kernel/machvec_impl.h | 5 +- arch/alpha/kernel/process.c | 15 ++ arch/alpha/kernel/proto.h | 13 +- arch/alpha/kernel/rtc.c | 374 +++++++++++++++++++++++++++++++++ arch/alpha/kernel/setup.c | 23 +- arch/alpha/kernel/smp.c | 33 +-- arch/alpha/kernel/sys_dp264.c | 8 - arch/alpha/kernel/sys_jensen.c | 2 - arch/alpha/kernel/sys_marvel.c | 55 +---- arch/alpha/kernel/time.c | 403 ++++++++++++++++-------------------- arch/alpha/kernel/traps.c | 12 ++ drivers/rtc/Kconfig | 17 +- 21 files changed, 767 insertions(+), 383 deletions(-) create mode 100644 arch/alpha/kernel/rtc.c
Signature · 1 line
1.8.1.4
RFC PATCH 1/10 alpha: Don't if-out dp264_device_interrupt.
The code as written is correct, and will be used by QEMU emulation.
--- arch/alpha/kernel/sys_dp264.c | 8 -------- 1 file changed, 8 deletions(-)
arch/alpha/kernel/sys_dp264.c +0 -8
@@ -190,9 +190,6 @@ static struct irq_chip clipper_irq_type = {static void dp264_device_interrupt (unsigned long vector) { -#if 1 -printk ("dp264_device_interrupt: NOT IMPLEMENTED YET!!\n" ); -#else unsigned long pld;unsigned int i;
@@ -210,12 +207,7 @@ dp264_device_interrupt(unsigned long vector)isa_device_interrupt (vector); else handle_irq(16 + i); -#if 0 - TSUNAMI_cchip->dir0.csr =1UL << i;mb (); - tmp = TSUNAMI_cchip->dir0.csr; -#endif } -#endif } static void
Signature · 1 line
1.8.1.4
RFC PATCH 2/10 alpha: Notice if we're being run under QEMU
In reply to Richard HendersonWhen building a generic kernel, do a run-time check on the serial number, like we do for MILO. When building a custom kernel, make this a configure-time check.
--- arch/alpha/Kconfig | 14 ++++++++++++++ arch/alpha/include/asm/machvec.h | 18 ++++++++++++------ arch/alpha/kernel/setup.c | 13 ++++++++++++- 3 files changed, 38 insertions(+), 7 deletions(-)
arch/alpha/Kconfig +14 -0
@@ -488,6 +488,20 @@ config VGA_HOSE which always have multiple hoses, and whose consoles support it. +config ALPHA_QEMU + bool "Run under QEMU emulation" + depends on !ALPHA_GENERIC + ---help--- + Assume the presence of special features supported by QEMU PALcode + that reduce the overhead of system emulation. + + Generic kernels will auto-detect QEMU. But when building a + system-specific kernel, the assumption is that we want to + elimiate as many runtime tests as possible. + + If unsure, say N. + + config ALPHA_SRM bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME depends on TTY
arch/alpha/include/asm/machvec.h +12 -6
@@ -126,13 +126,19 @@ extern struct alpha_machine_vector alpha_mv;#ifdef CONFIG_ALPHA_GENERIC extern int alpha_using_srm; +extern int alpha_using_qemu;#else -#ifdef CONFIG_ALPHA_SRM -#define alpha_using_srm 1 -#else -#define alpha_using_srm 0 -#endif +# ifdef CONFIG_ALPHA_SRM +# define alpha_using_srm 1 +# else +# define alpha_using_srm 0 +# endif +# ifdef CONFIG_ALPHA_QEMU +# define alpha_using_qemu 1 +# else +# define alpha_using_qemu 0 +# endif #endif /* GENERIC */ -#endif +#endif /* __KERNEL__ */ #endif /* __ALPHA_MACHVEC_H */
arch/alpha/kernel/setup.c +12 -1
@@ -115,10 +115,17 @@ unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;#ifdef CONFIG_ALPHA_GENERIC struct alpha_machine_vector alpha_mv; +#endif + +#ifndef alpha_using_srmint alpha_using_srm;EXPORT_SYMBOL (alpha_using_srm);#endif +#ifndef alpha_using_qemu +int alpha_using_qemu; +#endif +static struct alpha_machine_vector *get_sysvec (unsigned long ,unsigned long ,unsigned long );static struct alpha_machine_vector *get_sysvec_byname (const char *);
@@ -529,11 +536,15 @@ setup_arch(char **cmdline_p)atomic_notifier_chain_register (&panic_notifier_list, &alpha_panic_block); -#ifdef CONFIG_ALPHA_GENERIC +#ifndef alpha_using_srm/* Assume that we've booted from SRM if we haven't booted from MILO. Detect the later by looking for "MILO" in the system serial nr. */ alpha_using_srm =strncmp ((const char *)hwrpb->ssn,"MILO" ,4 ) !=0 ;#endif +#ifndef alpha_using_qemu +/* Similarly, look for QEMU. */ + alpha_using_qemu =strstr ((const char *)hwrpb->ssn,"QEMU" ) !=0 ; +#endif /* If we are using SRM, we want to allow callbacks as early as possible, so do this NOW, and then
Signature · 1 line
1.8.1.4
RFC PATCH 3/10 alpha: Force the user-visible HZ to a constant 1024.
In reply to Richard HendersonThis kernel/user split was done long ago for other architectures.
--- arch/alpha/include/asm/param.h | 8 +++++--- arch/alpha/include/uapi/asm/param.h | 7 ------- 2 files changed, 5 insertions(+), 10 deletions(-)
arch/alpha/include/asm/param.h +5 -3
@@ -3,7 +3,9 @@#include <uapi/asm/param.h> -#define HZ CONFIG_HZ -#define USER_HZ HZ -# define CLOCKS_PER_SEC HZ/* frequency at which times() counts */ +# undef HZ +# define HZ CONFIG_HZ +# define USER_HZ 1024 +# define CLOCKS_PER_SEC USER_HZ/* frequency at which times() counts */ +#endif /* _ASM_ALPHA_PARAM_H */
arch/alpha/include/uapi/asm/param.h +0 -7
@@ -1,13 +1,7 @@#ifndef _UAPI_ASM_ALPHA_PARAM_H#define _UAPI_ASM_ALPHA_PARAM_H -/* ??? Gross. I don't want to parameterize this, and supposedly the -hardware ignores reprogramming. We also need userland buy-in to the -change in HZ, since this is visible in the wait4 resources etc. */ - -#ifndef __KERNEL__#define HZ 1024 -#endif #define EXEC_PAGESIZE 8192
@@ -17,5 +11,4 @@#define MAXHOSTNAMELEN 64/* max length of hostname */ -#endif /* _UAPI_ASM_ALPHA_PARAM_H */
Signature · 1 line
1.8.1.4
RFC PATCH 4/10 alpha: Allow HZ to be configured
In reply to Richard HendersonWith the 1024Hz default, we spend 50% of QEMU emulation processing timer interrupts.
--- arch/alpha/Kconfig | 36 ++++++++++++++++++++++++++++++++++-- arch/alpha/kernel/setup.c | 10 ++++++++-- arch/alpha/kernel/time.c | 24 +++++++++++++++++------- 3 files changed, 59 insertions(+), 11 deletions(-)
arch/alpha/Kconfig +34 -2
@@ -628,9 +628,41 @@ config VERBOSE_MCHECK_ON Take the default (1) unless you want more control or more info. +choice + prompt "Timer interrupt frequency (HZ)?" + default HZ_128 if ALPHA_QEMU + default HZ_1200 if ALPHA_RAWHIDE + default HZ_1024 + ---help--- + The frequency at which timer interrupts occur. A high frequency + minimizes latency, whereas a low frequency minimizes overhead of + process accounting. The later effect is especially significant + when being run under QEMU. + + Note that some Alpha hardware cannot change the interrupt frequency + of the timer. If unsure, say 1024 (or 1200 for Rawhide). + + config HZ_32 + bool "32 Hz" + config HZ_64 + bool "64 Hz" + config HZ_128 + bool "128 Hz" + config HZ_256 + bool "256 Hz" + config HZ_1024 + bool "1024 Hz" + config HZ_1200 + bool "1200 Hz" +endchoice + config HZ - int - default 1200 if ALPHA_RAWHIDE + int + default 32 if HZ_32 + default 64 if HZ_64 + default 128 if HZ_128 + default 256 if HZ_256 + default 1200 if HZ_1200 default 1024 source "drivers/pci/Kconfig"
arch/alpha/kernel/setup.c +8 -2
@@ -1218,6 +1218,7 @@ show_cpuinfo(struct seq_file *f, void *slot)char *systype_name;char *sysvariation_name;int nr_processors; +unsigned long timer_freq; cpu_index = (unsigned ) (cpu->type -1 ); cpu_name ="Unknown" ;
@@ -1229,6 +1230,12 @@ show_cpuinfo(struct seq_file *f, void *slot) nr_processors =get_nr_processors (cpu, hwrpb->nr_processors); +#if CONFIG_HZ ==1024 ||CONFIG_HZ ==1200 + timer_freq = (100UL * hwrpb->intr_freq) /4096 ; +#else + timer_freq =100UL *CONFIG_HZ ; +#endif +seq_printf (f,"cpu\t\t\t: Alpha\n" "cpu model\t\t: %s\n" "cpu variation\t\t: %ld\n"
@@ -1254,8 +1261,7 @@ show_cpuinfo(struct seq_file *f, void *slot) (char *)hwrpb->ssn, est_cycle_freq ? : hwrpb->cycle_freq, est_cycle_freq ?"est." :"" , - hwrpb->intr_freq /4096 , - (100 * hwrpb->intr_freq /4096 ) %100 , + timer_freq /100 , timer_freq %100 , hwrpb->pagesize, hwrpb->pa_bits, hwrpb->max_asn,
arch/alpha/kernel/time.c +17 -7
@@ -203,16 +203,26 @@ irqreturn_t timer_interrupt(int irq, void *dev)void __init common_init_rtc (void ) { -unsigned char x; +unsigned char x, sel =0 ;/* Reset periodic interrupt frequency. */ - x =CMOS_READ (RTC_FREQ_SELECT ) &0x3f ; -/* Test includes known working values on various platforms -where 0x26 is wrong; we refuse to change those. */ -if (x !=0x26 && x !=0x25 && x !=0x19 && x !=0x06 ) { -printk ("Setting RTC_FREQ to 1024 Hz (%x)\n" , x); -CMOS_WRITE (0x26 ,RTC_FREQ_SELECT ); +#if CONFIG_HZ ==1024 ||CONFIG_HZ ==1200 + x =CMOS_READ (RTC_FREQ_SELECT ) &0x3f ; +/* Test includes known working values on various platforms +where 0x26 is wrong; we refuse to change those. */ +if (x !=0x26 && x !=0x25 && x !=0x19 && x !=0x06 ) { + sel =RTC_REF_CLCK_32KHZ +6 ; } +#elif CONFIG_HZ ==256 ||CONFIG_HZ ==128 ||CONFIG_HZ ==64 ||CONFIG_HZ ==32 + sel =RTC_REF_CLCK_32KHZ +__builtin_ffs (32768 /CONFIG_HZ ); +#else +# error "Unknown HZ from arch/alpha/Kconfig" +#endif +if (sel) { +printk (KERN_INFO "Setting RTC_FREQ to %d Hz (%x)\n" , +CONFIG_HZ , sel); +CMOS_WRITE (sel,RTC_FREQ_SELECT ); + }/* Turn on periodic interrupts. */ x =CMOS_READ (RTC_CONTROL );
Signature · 1 line
1.8.1.4
RFC PATCH 5/10 alpha: Primitive support for CPU power down.
In reply to Richard HendersonUse WTINT to wait for the next interrupt. Squash the WTINT call if the PALcode doesn't support it (e.g. MILO). No attempt is yet made to skip clock ticks during normal scheduling in order to stay in power down mode longer.
--- arch/alpha/include/asm/pal.h | 1 + arch/alpha/include/uapi/asm/pal.h | 1 + arch/alpha/kernel/process.c | 15 +++++++++++++++ arch/alpha/kernel/traps.c | 12 ++++++++++++ 4 files changed, 29 insertions(+)
arch/alpha/include/asm/pal.h +1 -0
@@ -89,6 +89,7 @@ __CALL_PAL_W1(wrmces, unsigned long); __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long); __CALL_PAL_W1(wrusp, unsigned long); __CALL_PAL_W1(wrvptptr, unsigned long); +__CALL_PAL_RW1(wtint, unsigned long, unsigned long);/* * TB routines..
arch/alpha/include/uapi/asm/pal.h +1 -0
@@ -46,6 +46,7 @@#define PAL_rdusp 58#define PAL_whami 60#define PAL_retsys 61 +#define PAL_wtint 62#define PAL_rti 63
arch/alpha/kernel/process.c +15 -0
@@ -46,6 +46,21 @@void (*pm_power_off)(void ) = machine_power_off;EXPORT_SYMBOL (pm_power_off); +/* +* Sleep the CPU. +* EV6, LCA45 and QEMU know how to power down, skipping N timer interrupts. +*/ +void arch_cpu_idle (void ) +{ +wtint (0 ); +local_irq_enable (); +} + +void arch_cpu_idle_dead (void ) +{ +wtint (INT_MAX ); +} +struct halt_info {int mode;char *restart_cmd;
arch/alpha/kernel/traps.c +12 -0
@@ -243,6 +243,18 @@ do_entIF(unsigned long type, struct pt_regs *regs) (const char *)(data[1 ] | (long )data[2 ] <<32 ), data[0]); } +if (type ==4 ) { +/* If CALL_PAL WTINT is not supported by the PALcode, +"emulate" it by overwriting the insn. */ +unsigned int *pinsn + = (unsigned int *) regs->pc -1 ; +if (*pinsn == PAL_wtint) { + *pinsn =0x47e01400 ;/* mov 0,$0 */ +imb (); + regs->r0 =0 ; +return ; + } + }die_if_kernel ((type ==1 ?"Kernel Bug" :"Instruction fault" ), regs, type,NULL ); }
Signature · 1 line
1.8.1.4
Matt Turner
maintainerRe: [RFC PATCH 05/10] alpha: Primitive support for CPU power down.
Quoted 4 lines · Richard Henderson
Use WTINT to wait for the next interrupt. Squash the WTINT call if the PALcode doesn't support it (e.g. MILO). No attempt is yet made to skip clock ticks during normal scheduling in order to stay in power down mode longer.
The architecture reference manual says
Quoted 2 lines
The counter, PCC, may increment at a lower rate or may stop entirely during wtint execution. This side effect is implementation dependent.
Is that anything to worry about?
Quoted 64 lines
Signed-off-by Richard Henderson <[email protected]>--- arch/alpha/include/asm/pal.h | 1 + arch/alpha/include/uapi/asm/pal.h | 1 + arch/alpha/kernel/process.c | 15 +++++++++++++++ arch/alpha/kernel/traps.c | 12 ++++++++++++ 4 files changed, 29 insertions(+)arch/alpha/include/asm/pal.h +1
-0@@ -89,6 +89,7 @@ __CALL_PAL_W1(wrmces, unsigned long); __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long); __CALL_PAL_W1(wrusp, unsigned long); __CALL_PAL_W1(wrvptptr, unsigned long); +__CALL_PAL_RW1(wtint, unsigned long, unsigned long);/* * TB routines.. arch/alpha/include/uapi/asm/pal.h +1
-0@@ -46,6 +46,7 @@#define PAL_rdusp 58#define PAL_whami 60#define PAL_retsys 61 +#define PAL_wtint 62#define PAL_rti 63arch/alpha/kernel/process.c +15
-0@@ -46,6 +46,21 @@void (*pm_power_off)(void ) = machine_power_off;EXPORT_SYMBOL (pm_power_off); +/* +* Sleep the CPU. +* EV6, LCA45 and QEMU know how to power down, skipping N timer interrupts. +*/ +void arch_cpu_idle (void ) +{ +wtint (0 ); +local_irq_enable (); +} + +void arch_cpu_idle_dead (void ) +{ +wtint (INT_MAX ); +} +struct halt_info {int mode;char *restart_cmd;arch/alpha/kernel/traps.c +0
-0
arch/alpha/kernel/traps.c do_entIF(unsigned long type, struct pt_regs *regs) · line 248
Quoted 6 lines
arch/alpha/kernel/traps.c +3
-0@@ -243,6 +243,18 @@ do_entIF(unsigned long type, struct pt_regs *regs) (const char *)(data[1 ] | (long )data[2 ] <<32 ), data[0]); } +if (type ==4 ) { +/* If CALL_PAL WTINT is not supported by the PALcode, +"emulate" it by overwriting the insn. */
The pseudo-code for WTINT contains an IF(implemented) check, where the ELSE case just does v0 <- 0. So is overwriting with nop just an optimization to avoid the (expensive) PAL call? If it is, could we clarify the comment?
Quoted 15 lines
arch/alpha/kernel/traps.c +9
-1+unsigned int *pinsn + = (unsigned int *) regs->pc -1 ; +if (*pinsn == PAL_wtint) { + *pinsn =0x47e01400 ;/* mov 0,$0 */ +imb (); + regs->r0 =0 ; +return ; + } + }die_if_kernel ((type ==1 ?"Kernel Bug" :"Instruction fault" ), regs, type,NULL ); } --1.8.1.4
Re: [RFC PATCH 05/10] alpha: Primitive support for CPU power down.
Quoted 6 lines · Matt Turner
Quoted 4 lines · Richard Henderson
Use WTINT to wait for the next interrupt. Squash the WTINT call if the PALcode doesn't support it (e.g. MILO). No attempt is yet made to skip clock ticks during normal scheduling in order to stay in power down mode longer.
Quoted 6 lines
The architecture reference manual says
Quoted 2 lines
The counter, PCC, may increment at a lower rate or may stop entirely during wtint execution. This side effect is implementation dependent.
Is that anything to worry about?
Hmm, yes. It means that we can't use both this and rpcc as a clocksource. Which we can't do while SMP either, so perhaps that's not so bad. So, right now, with an SMP EV6 system we ought not worry. Care to report whether that hypothesis is true?
It may well be a tradeoff we want to CONFIG though, since nothing in the EV5 thru PCA56 can make use of the power down state, and were often uniprocessor systems...
Quoted 4 lines
Quoted 4 lines
arch/alpha/kernel/traps.c +0
-0@@ -243,6 +243,18 @@ do_entIF(unsigned long type, struct pt_regs *regs) (const char *)(data[1 ] | (long )data[2 ] <<32 ), data[0]); }
Quoted 8 lines
arch/alpha/kernel/traps.c do_entIF(unsigned long type, struct pt_regs *regs) · line 248
Quoted 3 lines
arch/alpha/kernel/traps.c +3
-0+if (type ==4 ) { +/* If CALL_PAL WTINT is not supported by the PALcode, +"emulate" it by overwriting the insn. */ The pseudo-code for WTINT contains an IF(implemented) check, where the ELSE case just does v0 <- 0. So is overwriting with nop just an optimization to avoid the (expensive) PAL call? If it is, could we clarify the comment?
No, notice where this code is: entIF, aka SIGILL. Looking at MILO sources I can tell you that WTINT isn't implemented at all. Overwriting with the mov insn is what I call "emulating" the unimplemented PALcall.
r~
RFC PATCH 6/10 alpha: Reorganize rtc handling
In reply to Richard HendersonDiscontinue use of GENERIC_CMOS_UPDATE; rely on the RTC subsystem.
The marvel platform requires that the rtc only be touched from the boot cpu. This had been partially implemented with hooks for get/set_rtc_time, but read/update_persistent_clock were not handled. Fixed by adding an rtc_set_mmss hook along the way.
We had read_persistent_clock managing the epoch against which the rtc hw is based, but this didn't apply to get_rtc_time or set_rtc_time. This resulted in incorrect values when hwclock(8) gets involved.
Allow the epoch to be set from the kernel command-line, overriding the autodetection, which is doomed to fail in 2028. Further, by implementing the rtc ioctl function, we can expose this epoch to userland.
Elide the alarm functions that RTC_DRV_CMOS implements. This was highly questionable on Alpha, since the interrupt is used by the system timer.
--- arch/alpha/Kconfig | 1 - arch/alpha/include/asm/machvec.h | 4 +- arch/alpha/include/asm/rtc.h | 11 -- arch/alpha/kernel/Makefile | 1 + arch/alpha/kernel/machvec_impl.h | 5 +- arch/alpha/kernel/proto.h | 9 ++ arch/alpha/kernel/rtc.c | 323 +++++++++++++++++++++++++++++++++++++++ arch/alpha/kernel/sys_jensen.c | 2 - arch/alpha/kernel/sys_marvel.c | 55 +------ arch/alpha/kernel/time.c | 146 +----------------- drivers/rtc/Kconfig | 10 +- 11 files changed, 346 insertions(+), 221 deletions(-) create mode 100644 arch/alpha/kernel/rtc.c
arch/alpha/Kconfig +0 -1
@@ -17,7 +17,6 @@ config ALPHA select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select GENERIC_SMP_IDLE_THREAD - select GENERIC_CMOS_UPDATE select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HAVE_MOD_ARCH_SPECIFIC
arch/alpha/include/asm/machvec.h +1 -3
@@ -33,6 +33,7 @@ struct alpha_machine_vectorint nr_irqs;int rtc_port; +int rtc_boot_cpu_only;unsigned int max_asn;unsigned long max_isa_dma_address;unsigned long irq_probe_mask;
@@ -95,9 +96,6 @@ struct alpha_machine_vectorstruct _alpha_agp_info *(*agp_info)(void ); -unsigned int (*rtc_get_time)(struct rtc_time *); -int (*rtc_set_time)(struct rtc_time *); -const char *vector_name;/* NUMA information */
arch/alpha/include/asm/rtc.h +0 -11
@@ -1,12 +1 @@ -#ifndef _ALPHA_RTC_H -#define _ALPHA_RTC_H - -#if defined(CONFIG_ALPHA_MARVEL ) && defined(CONFIG_SMP ) \ - || defined(CONFIG_ALPHA_GENERIC ) -# define get_rtc_time alpha_mv.rtc_get_time -# define set_rtc_time alpha_mv.rtc_set_time -#endif -#include <asm-generic/rtc.h> - -#endif
arch/alpha/kernel/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_PCI) += pci.o pci_iommu.o pci-sysfs.o obj-$(CONFIG_SRM_ENV) += srm_env.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o +obj-$(CONFIG_RTC_DRV_ALPHA) += rtc.o ifdef CONFIG_ALPHA_GENERIC
arch/alpha/kernel/machvec_impl.h +1 -4
@@ -43,10 +43,7 @@#define CAT1 (x,y) x##y#define CAT (x,y) CAT1(x,y) -#define DO_DEFAULT_RTC \ - .rtc_port = 0x70, \ - .rtc_get_time = common_get_rtc_time, \ - .rtc_set_time = common_set_rtc_time +#define DO_DEFAULT_RTC .rtc_port = 0x70#define DO_EV4_MMU \ .max_asn = EV4_MAX_ASN, \
arch/alpha/kernel/proto.h +9 -0
@@ -144,8 +144,17 @@ extern void smp_percpu_timer_interrupt(struct pt_regs *);extern irqreturn_t timer_interrupt (int irq,void *dev);extern void common_init_rtc (void );extern unsigned long est_cycle_freq; + +/* rtc.c */ +#ifdef CONFIG_RTC_DRV_ALPHA extern unsigned int common_get_rtc_time (struct rtc_time *time);extern int common_set_rtc_time (struct rtc_time *time); +extern int common_set_rtc_mmss (unsigned long ); +#else +# define common_get_rtc_time NULL +# define common_set_rtc_time NULL +# define common_set_rtc_mmss NULL +#endif /* smc37c93x.c */ extern void SMC93x_Init (void );
arch/alpha/kernel/rtc.c new file +323 -0
323 lines not on this page · raw message
arch/alpha/kernel/sys_jensen.c +0 -2
@@ -224,8 +224,6 @@ struct alpha_machine_vector jensen_mv __initmv = { .machine_check = jensen_machine_check, .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS, .rtc_port = 0x170, - .rtc_get_time = common_get_rtc_time, - .rtc_set_time = common_set_rtc_time, .nr_irqs = 16, .device_interrupt = jensen_device_interrupt,
arch/alpha/kernel/sys_marvel.c +1 -54
73 lines not on this page · raw message
arch/alpha/kernel/time.c +1 -145
185 lines not on this page · raw message
drivers/rtc/Kconfig +9 -1
@@ -606,7 +606,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" - depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS || SPARC64 + depends on X86 || ARM || M32R || ATARI || PPC || MIPS || SPARC64 default y if X86 help Say "yes" here to get direct support for the real time clock
@@ -623,6 +623,14 @@ config RTC_DRV_CMOS This driver can also be built as a module. If so, the module will be called rtc-cmos. +config RTC_DRV_ALPHA + bool "Alpha PC-style CMOS" + depends on ALPHA + default y + help + Direct support for the real-time clock found on every Alpha + system, specifically MC146818 compatibles. If in doubt, say Y. + config RTC_DRV_VRTC tristate "Virtual RTC for Intel MID platforms" depends on X86_INTEL_MID
Signature · 1 line
1.8.1.4
RFC PATCH 7/10 alpha: Add an rtc driver for the qemu wallclock PALcall
In reply to Richard HendersonIn the normal case, one wants the guest to follow the host time. QEMU has a cserve call that retrieves the wall clock.
--- arch/alpha/include/asm/pal.h | 56 ++++++++++++++++++++++++++++++++++++++ arch/alpha/kernel/Makefile | 3 +- arch/alpha/kernel/rtc.c | 65 +++++++++++++++++++++++++++++++++++++++----- drivers/rtc/Kconfig | 7 +++++ 4 files changed, 122 insertions(+), 9 deletions(-)
arch/alpha/include/asm/pal.h +56 -0
@@ -112,5 +112,61 @@ __CALL_PAL_RW1(wtint, unsigned long, unsigned long); #define tbiap() __tbi(-1, /* no second argument */) #define tbia() __tbi(-2, /* no second argument */) +/* +* QEMU Cserv routines.. +*/ + +static inline unsigned long +qemu_get_walltime (void ) +{ + registerunsigned long v0 __asm__("$0" ); + register unsigned long a0 __asm__("$16") = 3; + + asm("call_pal %2 # cserve get_time" + :"=r" (v0),"+r" (a0) + :"i" (PAL_cserve) + :"$17" ,"$18" ,"$19" ,"$20" ,"$21" ); + +return v0; +} + +static inline unsigned long +qemu_get_alarm (void ) +{ + registerunsigned long v0 __asm__("$0" ); + register unsigned long a0 __asm__("$16") = 4; + + asm("call_pal %2 # cserve get_alarm" + :"=r" (v0),"+r" (a0) + :"i" (PAL_cserve) + :"$17" ,"$18" ,"$19" ,"$20" ,"$21" ); + +return v0; +} + +static inline void +qemu_set_alarm_rel (unsigned long expire) +{ + register unsigned long a0 __asm__("$16") = 5; + register unsigned long a1 __asm__("$17") = expire; + + asmvolatile ("call_pal %2 # cserve set_alarm_rel" + :"+r" (a0),"+r" (a1) + :"i" (PAL_cserve) + :"$0" ,"$18" ,"$19" ,"$20" ,"$21" ); +} + +static inline void +qemu_set_alarm_abs (unsigned long expire) +{ + register unsigned long a0 __asm__("$16") = 6; + register unsigned long a1 __asm__("$17") = expire; + + asmvolatile ("call_pal %2 # cserve set_alarm_abs" + :"+r" (a0),"+r" (a1) + :"i" (PAL_cserve) + :"$0" ,"$18" ,"$19" ,"$20" ,"$21" ); +} +#endif /* !__ASSEMBLY__ */ #endif /* __ALPHA_PAL_H */
arch/alpha/kernel/Makefile +1 -2
@@ -8,7 +8,7 @@ ccflags-y := -Wno-sign-compare obj-y := entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ - alpha_ksyms.o systbls.o err_common.o io.o + alpha_ksyms.o systbls.o err_common.o io.o rtc.o obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o
@@ -16,7 +16,6 @@ obj-$(CONFIG_PCI) += pci.o pci_iommu.o pci-sysfs.o obj-$(CONFIG_SRM_ENV) += srm_env.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o -obj-$(CONFIG_RTC_DRV_ALPHA) += rtc.o ifdef CONFIG_ALPHA_GENERIC
arch/alpha/kernel/rtc.c +58 -7
98 lines not on this page · raw message
drivers/rtc/Kconfig +7 -0
@@ -631,6 +631,13 @@ config RTC_DRV_ALPHA Direct support for the real-time clock found on every Alpha system, specifically MC146818 compatibles. If in doubt, say Y. +config RTC_DRV_ALPHA_QEMU + bool "Alpha QEMU paravirtual RTC" + depends on ALPHA + default y if ALPHA_QEMU + help + Support for the paravirtual real-time clock found in QEMU. + config RTC_DRV_VRTC tristate "Virtual RTC for Intel MID platforms" depends on X86_INTEL_MID
Signature · 1 line
1.8.1.4
RFC PATCH 8/10 alpha: Always enable the rpcc clocksource for single processor
In reply to Richard HendersonDon't depend on SMP, just check the number of processors online. This allows a single distribution kernel to use the clocksource when run on a single processor machine.
--- arch/alpha/kernel/time.c | 58 +++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 30 deletions(-)
arch/alpha/kernel/time.c +28 -30
@@ -186,6 +186,31 @@ common_init_rtc(void)init_rtc_irq (); } + +/* +* The RPCC as a clocksource primitive. +* +* While we have free-running timecounters running on all CPUs, and we make +* a half-hearted attempt in init_rtc_rpcc_info to sync the timecounter +* with the wall clock, that initialization isn't kept up-to-date across +* different time counters in SMP mode. Therefore we can only use this +* method when there's only one CPU enabled. +*/ + +static cycle_t read_rpcc (struct clocksource *cs) +{ +return rpcc (); +} + +static struct clocksource clocksource_rpcc = { + .name ="rpcc" , + .rating =300 , + .read = read_rpcc, + .mask =CLOCKSOURCE_MASK (32 ), + .flags =CLOCK_SOURCE_IS_CONTINUOUS +}; + +/* Validate a computed cycle counter result against the known bounds for the given processor core. There's too much brokenness in the way of timing hardware for any one method to work everywhere. :-(
@@ -296,33 +321,6 @@ rpcc_after_update_in_progress(void)return rpcc (); } -#ifndef CONFIG_SMP -/* Until and unless we figure out how to get cpu cycle counters -in sync and keep them there, we can't use the rpcc. */ -static cycle_t read_rpcc (struct clocksource *cs) -{ -cycle_t ret = (cycle_t )rpcc (); -return ret; -} - -static struct clocksource clocksource_rpcc = { - .name ="rpcc" , - .rating =300 , - .read = read_rpcc, - .mask =CLOCKSOURCE_MASK (32 ), - .flags =CLOCK_SOURCE_IS_CONTINUOUS -}; - -static inline void register_rpcc_clocksource (long cycle_freq) -{ -clocksource_register_hz (&clocksource_rpcc, cycle_freq); -} -#else /* !CONFIG_SMP */ -static inline void register_rpcc_clocksource (long cycle_freq) -{ -} -#endif /* !CONFIG_SMP */ -void __init time_init (void ) {
@@ -364,20 +362,20 @@ time_init(void) "and unable to estimate a proper value!\n"); } +if (hwrpb->nr_processors ==1 ) +clocksource_register_hz (&clocksource_rpcc, cycle_freq); +/* From John Bowman <[email protected]>: allow the values to settle, as the Update-In-Progress bit going low isn't good enough on some hardware. 2ms is our guess; we haven't found bogomips yet, but this is close on a 500Mhz box. */ __delay (1000000 ); -if (HZ > (1 <<16 )) {extern void __you_loose (void );__you_loose (); } -register_rpcc_clocksource (cycle_freq); - state.last_time = cc1; state.scaled_ticks_per_cycle = ((unsigned long )HZ <<FIX_SHIFT ) / cycle_freq;
Signature · 1 line
1.8.1.4
RFC PATCH 9/10 alpha: Switch to GENERIC_CLOCKEVENTS
In reply to Richard HendersonThis allows us to get rid of some hacky code for SMP. Get rid of some cycle counter hackery that's now handled by generic code via clocksource + clock_event_device objects.
--- arch/alpha/Kconfig | 1 + arch/alpha/kernel/irq_alpha.c | 14 ------ arch/alpha/kernel/proto.h | 2 +- arch/alpha/kernel/smp.c | 33 ++----------- arch/alpha/kernel/time.c | 111 ++++++++++++++++++------------------------ 5 files changed, 52 insertions(+), 109 deletions(-)
arch/alpha/Kconfig +1 -0
@@ -16,6 +16,7 @@ config ALPHA select ARCH_WANT_IPC_PARSE_VERSION select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE + select GENERIC_CLOCKEVENTS select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER
arch/alpha/kernel/irq_alpha.c +0 -14
@@ -66,21 +66,7 @@ do_entInt(unsigned long type, unsigned long vector,break ;case 1 : old_regs =set_irq_regs (regs); -#ifdef CONFIG_SMP - { -long cpu; - -smp_percpu_timer_interrupt (regs); - cpu =smp_processor_id (); -if (cpu != boot_cpuid) { -kstat_incr_irqs_this_cpu (RTC_IRQ ,irq_to_desc (RTC_IRQ )); - }else { -handle_irq (RTC_IRQ ); - } - } -#else handle_irq (RTC_IRQ ); -#endif set_irq_regs (old_regs);return ;case 2 :
arch/alpha/kernel/proto.h +1 -1
@@ -135,13 +135,13 @@ extern void unregister_srm_console(void);/* smp.c */ extern void setup_smp (void );extern void handle_ipi (struct pt_regs *); -extern void smp_percpu_timer_interrupt (struct pt_regs *);/* bios32.c */ /* extern void reset_for_srm(void); */ /* time.c */ extern irqreturn_t timer_interrupt (int irq,void *dev); +extern void init_clockevent (void );extern void common_init_rtc (void );extern unsigned long est_cycle_freq;
arch/alpha/kernel/smp.c +3 -30
@@ -138,9 +138,11 @@ smp_callin(void)/* Get our local ticker going. */ smp_setup_percpu_timer (cpuid); +init_clockevent ();/* Call platform-specific callin, if specified */ -if (alpha_mv.smp_callin) alpha_mv.smp_callin (); +if (alpha_mv.smp_callin) + alpha_mv.smp_callin ();/* All kernel threads share the same mm context. */ atomic_inc (&init_mm.mm_count);
@@ -497,35 +499,6 @@ smp_cpus_done(unsigned int max_cpus) ((bogosum + 2500) / (5000/HZ)) % 100); } - -void -smp_percpu_timer_interrupt (struct pt_regs *regs) -{ -struct pt_regs *old_regs; -int cpu =smp_processor_id (); -unsigned long user =user_mode (regs); -struct cpuinfo_alpha *data = &cpu_data[cpu]; - - old_regs =set_irq_regs (regs); - -/* Record kernel PC. */ -profile_tick (CPU_PROFILING ); - -if (!--data->prof_counter) { -/* We need to make like a normal interrupt -- otherwise -timer interrupts ignore the global interrupt lock, -which would be a Bad Thing. */ -irq_enter (); - -update_process_times (user); - - data->prof_counter = data->prof_multiplier; - -irq_exit (); - } -set_irq_regs (old_regs); -} -int setup_profiling_timer (unsigned int multiplier) {
arch/alpha/kernel/time.c +47 -64
149 lines not on this page · raw message
Signature · 1 line
1.8.1.4
RFC PATCH 10/10 alpha: Use qemu+cserve provided high-res clock and alarm.
In reply to Richard HendersonQEMU provides a high-resolution timer and alarm; use this for a clock source and clock event source when available.
--- arch/alpha/include/asm/pal.h | 14 ++++++ arch/alpha/kernel/irq_alpha.c | 2 +- arch/alpha/kernel/proto.h | 2 +- arch/alpha/kernel/time.c | 106 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 117 insertions(+), 7 deletions(-)
arch/alpha/include/asm/pal.h +14 -0
@@ -168,5 +168,19 @@ qemu_set_alarm_abs(unsigned long expire) : "$0", "$18", "$19", "$20", "$21"); } +static inline unsigned long +qemu_get_vmtime (void ) +{ + registerunsigned long v0 __asm__("$0" ); + register unsigned long a0 __asm__("$16") = 7; + + asm("call_pal %2 # cserve get_time" + :"=r" (v0),"+r" (a0) + :"i" (PAL_cserve) + :"$17" ,"$18" ,"$19" ,"$20" ,"$21" ); + +return v0; +} +#endif /* !__ASSEMBLY__ */ #endif /* __ALPHA_PAL_H */
arch/alpha/kernel/irq_alpha.c +1 -1
@@ -214,7 +214,7 @@ process_mcheck_info(unsigned long vector, unsigned long la_ptr,*/ struct irqaction timer_irqaction = { - .handler = timer_interrupt, + .handler = rtc_timer_interrupt, .name ="timer" , };
arch/alpha/kernel/proto.h +1 -1
@@ -140,7 +140,7 @@ extern void handle_ipi(struct pt_regs *);/* extern void reset_for_srm(void); */ /* time.c */ -extern irqreturn_t timer_interrupt (int irq,void *dev); +extern irqreturn_t rtc_timer_interrupt (int irq,void *dev);extern void init_clockevent (void );extern void common_init_rtc (void );extern unsigned long est_cycle_freq;
arch/alpha/kernel/time.c +101 -5
135 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Quoted 3 lines · Richard Henderson
The series seems pretty stable under QEMU, but I have no real hardware on which to test -- the whole reason I'm interested in QEMU of course. So I'm hoping that someone will notice this and help me out with testing.
Tested the patch series applied against 3.10.1 on a 3-CPU ES45. System came up fine but I noticed date was wrong and had been reset back to the start of the epoch (Jan 1 1970). Appears it is not reading hardware clock correctly on boot.
I manually set the clock to the correct time but noticed it is running slow, indeed in a period of 60s the system clock incremented by 21s (+/-1s) so would appear clock is running slow by a factor given by the number of CPUs.
Cheers
Michael
Quoted 4 lines · Michael Cree
Tested the patch series applied against 3.10.1 on a 3-CPU ES45. System came up fine but I noticed date was wrong and had been reset back to the start of the epoch (Jan 1 1970). Appears it is not reading hardware clock correctly on boot.
Please scan the dmesg for the "Using epoch 2000 for rtc year 13" line, and compare vs a similar message on the previous kernel.
Quoted 3 lines
I manually set the clock to the correct time but noticed it is running slow, indeed in a period of 60s the system clock incremented by 21s (+/-1s) so would appear clock is running slow by a factor given by the number of CPUs.
That's curious. I wonder if somehow I botched the smp changes, and I'm not getting the timer interrupt either (1) enabled or (2) registered on the secondary cpus...
Perhaps /proc/interrupts will confirm or deny this?
r~
Quoted 8 lines · Richard Henderson
Quoted 4 lines · Michael Cree
Tested the patch series applied against 3.10.1 on a 3-CPU ES45. System came up fine but I noticed date was wrong and had been reset back to the start of the epoch (Jan 1 1970). Appears it is not reading hardware clock correctly on boot.
Please scan the dmesg for the "Using epoch 2000 for rtc year 13" line, and compare vs a similar message on the previous kernel.
The kernel without the patch set has the "Using epoch 2000" line and the kernel with the patch set is missing the "Using epoch 2000" line.
The differences in config between the two kernels are:
diff /boot/config-3.10.1-titan-p1+ /boot/config-3.10.1-titan-rth2+ 25c25
< CONFIG_LOCALVERSION="-titan-p1"
---
Quoted 1 line
CONFIG_LOCALVERSION="-titan-rth2"
44c44,53
< CONFIG_GENERIC_CMOS_UPDATE=y
---
Quoted 10 lines
CONFIG_GENERIC_CLOCKEVENTS=yCONFIG_GENERIC_CLOCKEVENTS_BUILD=y#
# Timers subsystem
#CONFIG_HZ_PERIODIC=y
#CONFIG_NO_HZ_IDLEis not set
#CONFIG_NO_HZis not set
#CONFIG_HIGH_RES_TIMERSis not set
253a263
Quoted 1 line
#
CONFIG_ALPHA_QEMUis not set
277a288,293
Quoted 12 lines
#
CONFIG_HZ_32is not set
#CONFIG_HZ_64is not set
#CONFIG_HZ_128is not set
#CONFIG_HZ_256is not setCONFIG_HZ_1024=y
#CONFIG_HZ_1200is not setQuoted 3 lines
I manually set the clock to the correct time but noticed it is running slow, indeed in a period of 60s the system clock incremented by 21s (+/-1s) so would appear clock is running slow by a factor given by the number of CPUs.
Quoted 5 lines
That's curious. I wonder if somehow I botched the smp changes, and I'm not getting the timer interrupt either (1) enabled or (2) registered on the secondary cpus...
Perhaps
/proc/interruptswill confirm or deny this?
On the kernel without the patch set the dummy-RTC timer interrupt received 30876 interrupts in a 30s period which is within measurement uncertainty of the expected 30*1024 = 30720 interrupts.
On the kernel with the patch set the dummy-RTC timer interrupt received 14419 interrupts on CPU-1, 13935 interrupts on CPU-2 and 2619 interrupts on CPU-3 over a 30s period.
Cheers
Michael.
Quoted 2 lines · Michael Cree
The kernel without the patch set has the "Using epoch 2000" line and the kernel with the patch set is missing the "Using epoch 2000" line.
Ah hah. You appear to be missing CONFIG_RTC_DRV_ALPHA in the new kernel, so you have no support for the RTC at all. Please re-try.
Quoted 7 lines
On the kernel without the patch set the dummy-RTC timer interrupt received 30876 interrupts in a 30s period which is within measurement uncertainty of the expected 30*1024 = 30720 interrupts.
On the kernel with the patch set the dummy-RTC timer interrupt received 14419 interrupts on CPU-1, 13935 interrupts on CPU-2 and 2619 interrupts on CPU-3 over a 30s period.
Grr. Naturally, the old kernel obfuscates which timers are being delivered where. So a direct comparison doesn't appear possible. But those separated numbers seem uncomfortably low.
I've just pushed a new branch to
git://github.com/rth7680/linux.git axp-qemu-7
Please try that with CONFIG_ALPHA_WTINT disabled. I'd like to eliminate that as a source of uncertainty for your system.
r~
Quoted 13 lines · Richard Henderson
Quoted 7 lines · Michael Cree
On the kernel without the patch set the dummy-RTC timer interrupt received 30876 interrupts in a 30s period which is within measurement uncertainty of the expected 30*1024 = 30720 interrupts.
On the kernel with the patch set the dummy-RTC timer interrupt received 14419 interrupts on CPU-1, 13935 interrupts on CPU-2 and 2619 interrupts on CPU-3 over a 30s period.
Grr. Naturally, the old kernel obfuscates which timers are being delivered where. So a direct comparison doesn't appear possible. But those separated numbers seem uncomfortably low.
Quoted 6 lines
I've just pushed a new branch to
git://github.com/rth7680/linux.gitaxp-qemu-7Please try that with
CONFIG_ALPHA_WTINTdisabled. I'd like to eliminate that as a source of uncertainty for your system.
Running that axp-qemu-7 branch with RTC_DRV_ALPHA on and ALPHA_WTINT off still results in a rather slow clock. (Does start up with correct time now that I have RTC_DRV_ALPHA selected.)
Over a 30s period still get too few timer interrupts: 843, 28805 and 1434 interrupts on the CPUs.
Cheers
Michael