From: Keir Fraser Date: Thu, 15 Jan 2009 12:39:59 +0000 (+0000) Subject: x86 acpi: remove redundant function call. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14014^2~57 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=dcf9f950dc59b90bea3188e37ab108d87fae4876;p=xen.git x86 acpi: remove redundant function call. PM_TIMER_TICKS_TO_US() and acpi_pm_tick_to_ns() does the almost the same stuff. Thus remove the old one. Signed-off-by: Lu Guanqun Signed-off-by: Wei Gang --- diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 9d080f6506..b86d622bf9 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -50,11 +50,6 @@ #define DEBUG_PM_CX -#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) -#define PM_TIMER_TICKS_TO_US(t) ((t * 1000) / (PM_TIMER_FREQUENCY / 1000)) -#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ -#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ - static void (*lapic_timer_off)(void); static void (*lapic_timer_on)(void); @@ -366,7 +361,7 @@ static void acpi_processor_idle(void) cx->usage++; if ( sleep_ticks > 0 ) { - power->last_residency = PM_TIMER_TICKS_TO_US(sleep_ticks); + power->last_residency = acpi_pm_tick_to_ns(sleep_ticks) / 1000UL; cx->time += sleep_ticks; } @@ -611,7 +606,7 @@ static void set_cx( cx->latency = xen_cx->latency; cx->power = xen_cx->power; - cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); + cx->latency_ticks = ns_to_acpi_pm_tick(cx->latency * 1000UL); cx->target_residency = cx->latency * latency_factor; if ( cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ) acpi_power->safe_state = cx; diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index a642401546..6030915a83 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -532,9 +532,11 @@ static struct platform_timesource plt_pmtimer = }; static struct time_scale pmt_scale; +static struct time_scale pmt_scale_r; static __init int init_pmtmr_scale(void) { set_time_scale(&pmt_scale, ACPI_PM_FREQUENCY); + pmt_scale_r = scale_reciprocal(pmt_scale); return 0; } __initcall(init_pmtmr_scale); @@ -544,6 +546,11 @@ uint64_t acpi_pm_tick_to_ns(uint64_t ticks) return scale_delta(ticks, &pmt_scale); } +uint64_t ns_to_acpi_pm_tick(uint64_t ns) +{ + return scale_delta(ns, &pmt_scale_r); +} + /************************************************************ * GENERIC PLATFORM TIMER INFRASTRUCTURE */ diff --git a/xen/include/asm-x86/time.h b/xen/include/asm-x86/time.h index 73b06a7246..1d687a8060 100644 --- a/xen/include/asm-x86/time.h +++ b/xen/include/asm-x86/time.h @@ -39,5 +39,6 @@ void pit_broadcast_exit(void); int pit_broadcast_is_available(void); uint64_t acpi_pm_tick_to_ns(uint64_t ticks); +uint64_t ns_to_acpi_pm_tick(uint64_t ns); #endif /* __X86_TIME_H__ */