Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209991
b: refs/heads/master
c: cd7240c
h: refs/heads/master
i:
  209989: 9803586
  209987: 5f9ef66
  209983: 074cf67
v: v3
  • Loading branch information
Suresh Siddha authored and Ingo Molnar committed Aug 20, 2010
1 parent 1995a1d commit e591017
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 861d034ee814917a83bd5de4b26e3b8336ddeeb8
refs/heads/master: cd7240c0b900eb6d690ccee088a6c9b46dae815a
2 changes: 2 additions & 0 deletions trunk/arch/x86/include/asm/tsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ extern void check_tsc_sync_source(int cpu);
extern void check_tsc_sync_target(void);

extern int notsc_setup(char *);
extern void save_sched_clock_state(void);
extern void restore_sched_clock_state(void);

#endif /* _ASM_X86_TSC_H */
38 changes: 38 additions & 0 deletions trunk/arch/x86/kernel/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,44 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
local_irq_restore(flags);
}

static unsigned long long cyc2ns_suspend;

void save_sched_clock_state(void)
{
if (!sched_clock_stable)
return;

cyc2ns_suspend = sched_clock();
}

/*
* Even on processors with invariant TSC, TSC gets reset in some the
* ACPI system sleep states. And in some systems BIOS seem to reinit TSC to
* arbitrary value (still sync'd across cpu's) during resume from such sleep
* states. To cope up with this, recompute the cyc2ns_offset for each cpu so
* that sched_clock() continues from the point where it was left off during
* suspend.
*/
void restore_sched_clock_state(void)
{
unsigned long long offset;
unsigned long flags;
int cpu;

if (!sched_clock_stable)
return;

local_irq_save(flags);

get_cpu_var(cyc2ns_offset) = 0;
offset = cyc2ns_suspend - sched_clock();

for_each_possible_cpu(cpu)
per_cpu(cyc2ns_offset, cpu) = offset;

local_irq_restore(flags);
}

#ifdef CONFIG_CPU_FREQ

/* Frequency scaling support. Adjust the TSC based timer when the cpu frequency
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/x86/power/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ static void __save_processor_state(struct saved_context *ctxt)
void save_processor_state(void)
{
__save_processor_state(&saved_context);
save_sched_clock_state();
}
#ifdef CONFIG_X86_32
EXPORT_SYMBOL(save_processor_state);
Expand Down Expand Up @@ -229,6 +230,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
void restore_processor_state(void)
{
__restore_processor_state(&saved_context);
restore_sched_clock_state();
}
#ifdef CONFIG_X86_32
EXPORT_SYMBOL(restore_processor_state);
Expand Down

0 comments on commit e591017

Please sign in to comment.