Skip to content

Commit 2d0c87c

Browse files
john stultzLinus Torvalds
authored andcommitted
[PATCH] time: x86_64: hpet_address cleanup
In preparation for supporting generic timekeeping, this patch cleans up x86-64's use of vxtime.hpet_address, changing it to just hpet_address as is also used in i386. This is necessary since the vxtime structure will be going away. Signed-off-by: John Stultz <johnstul@us.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andi Kleen <ak@muc.de> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent acc9a9d commit 2d0c87c

4 files changed

Lines changed: 26 additions & 34 deletions

File tree

‎arch/i386/kernel/acpi/boot.c‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ static int __init acpi_parse_sbf(struct acpi_table_header *table)
616616
}
617617

618618
#ifdef CONFIG_HPET_TIMER
619+
#include <asm/hpet.h>
619620

620621
static int __init acpi_parse_hpet(struct acpi_table_header *table)
621622
{
@@ -646,24 +647,11 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
646647
hpet_res->end = (1 * 1024) - 1;
647648
}
648649

649-
#ifdef CONFIG_X86_64
650-
vxtime.hpet_address = hpet_tbl->address.address;
651-
650+
hpet_address = hpet_tbl->address.address;
652651
printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
653-
hpet_tbl->id, vxtime.hpet_address);
654-
655-
res_start = vxtime.hpet_address;
656-
#else /* X86 */
657-
{
658-
extern unsigned long hpet_address;
652+
hpet_tbl->id, hpet_address);
659653

660-
hpet_address = hpet_tbl->address.address;
661-
printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
662-
hpet_tbl->id, hpet_address);
663-
664-
res_start = hpet_address;
665-
}
666-
#endif /* X86 */
654+
res_start = hpet_address;
667655

668656
if (hpet_res) {
669657
hpet_res->start = res_start;

‎arch/x86_64/kernel/apic.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <asm/idle.h>
3838
#include <asm/proto.h>
3939
#include <asm/timex.h>
40+
#include <asm/hpet.h>
4041
#include <asm/apic.h>
4142

4243
int apic_mapped;
@@ -763,7 +764,7 @@ static void setup_APIC_timer(unsigned int clocks)
763764
local_irq_save(flags);
764765

765766
/* wait for irq slice */
766-
if (vxtime.hpet_address && hpet_use_timer) {
767+
if (hpet_address && hpet_use_timer) {
767768
int trigger = hpet_readl(HPET_T0_CMP);
768769
while (hpet_readl(HPET_COUNTER) >= trigger)
769770
/* do nothing */ ;

‎arch/x86_64/kernel/time.c‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static int notsc __initdata = 0;
6767

6868
unsigned int cpu_khz; /* TSC clocks / usec, not used here */
6969
EXPORT_SYMBOL(cpu_khz);
70+
unsigned long hpet_address;
7071
static unsigned long hpet_period; /* fsecs / HPET clock */
7172
unsigned long hpet_tick; /* HPET clocks / interrupt */
7273
int hpet_use_timer; /* Use counter of hpet for time keeping, otherwise PIT */
@@ -316,14 +317,15 @@ static noinline void handle_lost_ticks(int lost)
316317
KERN_WARNING "Your time source seems to be instable or "
317318
"some driver is hogging interupts\n");
318319
print_symbol("rip %s\n", get_irq_regs()->rip);
319-
if (vxtime.mode == VXTIME_TSC && vxtime.hpet_address) {
320+
if (vxtime.mode == VXTIME_TSC && hpet_address) {
320321
printk(KERN_WARNING "Falling back to HPET\n");
321322
if (hpet_use_timer)
322323
vxtime.last = hpet_readl(HPET_T0_CMP) -
323324
hpet_tick;
324325
else
325326
vxtime.last = hpet_readl(HPET_COUNTER);
326327
vxtime.mode = VXTIME_HPET;
328+
vxtime.hpet_address = hpet_address;
327329
do_gettimeoffset = do_gettimeoffset_hpet;
328330
}
329331
/* else should fall back to PIT, but code missing. */
@@ -354,7 +356,7 @@ void main_timer_handler(void)
354356

355357
write_seqlock(&xtime_lock);
356358

357-
if (vxtime.hpet_address)
359+
if (hpet_address)
358360
offset = hpet_readl(HPET_COUNTER);
359361

360362
if (hpet_use_timer) {
@@ -739,7 +741,7 @@ static __init int late_hpet_init(void)
739741
struct hpet_data hd;
740742
unsigned int ntimer;
741743

742-
if (!vxtime.hpet_address)
744+
if (!hpet_address)
743745
return 0;
744746

745747
memset(&hd, 0, sizeof (hd));
@@ -752,7 +754,7 @@ static __init int late_hpet_init(void)
752754
* Register with driver.
753755
* Timer0 and Timer1 is used by platform.
754756
*/
755-
hd.hd_phys_address = vxtime.hpet_address;
757+
hd.hd_phys_address = hpet_address;
756758
hd.hd_address = (void __iomem *)fix_to_virt(FIX_HPET_BASE);
757759
hd.hd_nirqs = ntimer;
758760
hd.hd_flags = HPET_DATA_PLATFORM;
@@ -821,10 +823,10 @@ static int hpet_init(void)
821823
{
822824
unsigned int id;
823825

824-
if (!vxtime.hpet_address)
826+
if (!hpet_address)
825827
return -1;
826-
set_fixmap_nocache(FIX_HPET_BASE, vxtime.hpet_address);
827-
__set_fixmap(VSYSCALL_HPET, vxtime.hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
828+
set_fixmap_nocache(FIX_HPET_BASE, hpet_address);
829+
__set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
828830

829831
/*
830832
* Read the period, compute tick and quotient.
@@ -878,7 +880,7 @@ void __init pit_stop_interrupt(void)
878880
void __init stop_timer_interrupt(void)
879881
{
880882
char *name;
881-
if (vxtime.hpet_address) {
883+
if (hpet_address) {
882884
name = "HPET";
883885
hpet_timer_stop_set_go(0);
884886
} else {
@@ -901,8 +903,7 @@ static struct irqaction irq0 = {
901903
void __init time_init(void)
902904
{
903905
if (nohpet)
904-
vxtime.hpet_address = 0;
905-
906+
hpet_address = 0;
906907
xtime.tv_sec = get_cmos_time();
907908
xtime.tv_nsec = 0;
908909

@@ -912,15 +913,15 @@ void __init time_init(void)
912913
if (!hpet_init())
913914
vxtime_hz = (FSEC_PER_SEC + hpet_period / 2) / hpet_period;
914915
else
915-
vxtime.hpet_address = 0;
916+
hpet_address = 0;
916917

917918
if (hpet_use_timer) {
918919
/* set tick_nsec to use the proper rate for HPET */
919920
tick_nsec = TICK_NSEC_HPET;
920921
cpu_khz = hpet_calibrate_tsc();
921922
timename = "HPET";
922923
#ifdef CONFIG_X86_PM_TIMER
923-
} else if (pmtmr_ioport && !vxtime.hpet_address) {
924+
} else if (pmtmr_ioport && !hpet_address) {
924925
vxtime_hz = PM_TIMER_FREQUENCY;
925926
timename = "PM";
926927
pit_init();
@@ -990,23 +991,24 @@ void time_init_gtod(void)
990991
if (unsynchronized_tsc())
991992
notsc = 1;
992993

993-
if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
994+
if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
994995
vgetcpu_mode = VGETCPU_RDTSCP;
995996
else
996997
vgetcpu_mode = VGETCPU_LSL;
997998

998-
if (vxtime.hpet_address && notsc) {
999+
if (hpet_address && notsc) {
9991000
timetype = hpet_use_timer ? "HPET" : "PIT/HPET";
10001001
if (hpet_use_timer)
10011002
vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick;
10021003
else
10031004
vxtime.last = hpet_readl(HPET_COUNTER);
10041005
vxtime.mode = VXTIME_HPET;
1006+
vxtime.hpet_address = hpet_address;
10051007
do_gettimeoffset = do_gettimeoffset_hpet;
10061008
#ifdef CONFIG_X86_PM_TIMER
10071009
/* Using PM for gettimeofday is quite slow, but we have no other
10081010
choice because the TSC is too unreliable on some systems. */
1009-
} else if (pmtmr_ioport && !vxtime.hpet_address && notsc) {
1011+
} else if (pmtmr_ioport && !hpet_address && notsc) {
10101012
timetype = "PM";
10111013
do_gettimeoffset = do_gettimeoffset_pm;
10121014
vxtime.mode = VXTIME_PMTMR;
@@ -1066,7 +1068,7 @@ static int timer_resume(struct sys_device *dev)
10661068
sleep_length = 0;
10671069
ctime = sleep_start;
10681070
}
1069-
if (vxtime.hpet_address)
1071+
if (hpet_address)
10701072
hpet_reenable();
10711073
else
10721074
i8254_timer_resume();
@@ -1150,7 +1152,7 @@ static unsigned int hpet_t1_cmp; /* cached comparator register */
11501152

11511153
int is_hpet_enabled(void)
11521154
{
1153-
return vxtime.hpet_address != 0;
1155+
return hpet_address != 0;
11541156
}
11551157

11561158
/*

‎include/asm-x86_64/hpet.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern int hpet_rtc_timer_init(void);
5858
extern int apic_is_clustered_box(void);
5959

6060
extern int hpet_use_timer;
61+
extern unsigned long hpet_address;
6162

6263
#ifdef CONFIG_HPET_EMULATE_RTC
6364
extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);

0 commit comments

Comments
 (0)