Jan Beulich
2012-Sep-24 11:02 UTC
[PATCH] x86: fix MWAIT-based idle driver for CPUs without ARAT
lapic_timer_{on,off} need to get initialized in this case. This in turn requires getting HPET broadcast setup to be carried out earlier (and hence preventing double initialization there). Signed-off-by: Jan Beulich <jbeulich@suse.com> --- Note that I don''t have a respective system available to test these adjustments (which is also why I didn''t notice the omission from the original patch), so I can only hope that this works and takes care of the observed boot failure. --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -74,6 +74,29 @@ static void lapic_timer_nop(void) { } void (*__read_mostly lapic_timer_off)(void); void (*__read_mostly lapic_timer_on)(void); +bool_t lapic_timer_init(void) +{ + if ( boot_cpu_has(X86_FEATURE_ARAT) ) + { + lapic_timer_off = lapic_timer_nop; + lapic_timer_on = lapic_timer_nop; + } + else if ( hpet_broadcast_is_available() ) + { + lapic_timer_off = hpet_broadcast_enter; + lapic_timer_on = hpet_broadcast_exit; + } + else if ( pit_broadcast_is_available() ) + { + lapic_timer_off = pit_broadcast_enter; + lapic_timer_on = pit_broadcast_exit; + } + else + return 0; + + return 1; +} + static uint64_t (*__read_mostly tick_to_ns)(uint64_t) = acpi_pm_tick_to_ns; void (*__read_mostly pm_idle_save)(void); @@ -789,25 +812,8 @@ static int check_cx(struct acpi_processo if ( local_apic_timer_c2_ok ) break; case ACPI_STATE_C3: - if ( boot_cpu_has(X86_FEATURE_ARAT) ) - { - lapic_timer_off = lapic_timer_nop; - lapic_timer_on = lapic_timer_nop; - } - else if ( hpet_broadcast_is_available() ) - { - lapic_timer_off = hpet_broadcast_enter; - lapic_timer_on = hpet_broadcast_exit; - } - else if ( pit_broadcast_is_available() ) - { - lapic_timer_off = pit_broadcast_enter; - lapic_timer_on = pit_broadcast_exit; - } - else - { + if ( !lapic_timer_init() ) return -EINVAL; - } /* All the logic here assumes flags.bm_check is same across all CPUs */ if ( bm_check_flag == -1 ) --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -56,6 +56,7 @@ #include <xen/softirq.h> #include <xen/trace.h> #include <asm/cpuidle.h> +#include <asm/hpet.h> #include <asm/mwait.h> #include <asm/msr.h> #include <acpi/cpufreq/cpufreq.h> @@ -501,6 +502,12 @@ int __init mwait_idle_init(struct notifi err = mwait_idle_probe(); if (!err) { + if (!boot_cpu_has(X86_FEATURE_ARAT)) + hpet_broadcast_init(); + if (!lapic_timer_init()) + err = -EINVAL; + } + if (!err) { nfb->notifier_call = mwait_idle_cpu_init; mwait_idle_cpu_init(nfb, CPU_UP_PREPARE, NULL); --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -495,7 +495,7 @@ void __init hpet_broadcast_init(void) u32 hpet_id, cfg; unsigned int i, n; - if ( hpet_rate == 0 ) + if ( hpet_rate == 0 || hpet_broadcast_is_available() ) return; cfg = hpet_read32(HPET_CFG); --- a/xen/include/asm-x86/cpuidle.h +++ b/xen/include/asm-x86/cpuidle.h @@ -10,6 +10,7 @@ extern struct acpi_processor_power *proc extern void (*pm_idle_save)(void); +bool_t lapic_timer_init(void); extern void (*lapic_timer_off)(void); extern void (*lapic_timer_on)(void); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Keir Fraser
2012-Sep-25 14:10 UTC
Re: [PATCH] x86: fix MWAIT-based idle driver for CPUs without ARAT
On 24/09/2012 12:02, "Jan Beulich" <JBeulich@suse.com> wrote:> lapic_timer_{on,off} need to get initialized in this case. This in turn > requires getting HPET broadcast setup to be carried out earlier (and > hence preventing double initialization there). > > Signed-off-by: Jan Beulich <jbeulich@suse.com>Acked-by: Keir Fraser <keir@xen.org>> --- > Note that I don''t have a respective system available to test these > adjustments (which is also why I didn''t notice the omission from the > original patch), so I can only hope that this works and takes care of > the observed boot failure. > > --- a/xen/arch/x86/acpi/cpu_idle.c > +++ b/xen/arch/x86/acpi/cpu_idle.c > @@ -74,6 +74,29 @@ static void lapic_timer_nop(void) { } > void (*__read_mostly lapic_timer_off)(void); > void (*__read_mostly lapic_timer_on)(void); > > +bool_t lapic_timer_init(void) > +{ > + if ( boot_cpu_has(X86_FEATURE_ARAT) ) > + { > + lapic_timer_off = lapic_timer_nop; > + lapic_timer_on = lapic_timer_nop; > + } > + else if ( hpet_broadcast_is_available() ) > + { > + lapic_timer_off = hpet_broadcast_enter; > + lapic_timer_on = hpet_broadcast_exit; > + } > + else if ( pit_broadcast_is_available() ) > + { > + lapic_timer_off = pit_broadcast_enter; > + lapic_timer_on = pit_broadcast_exit; > + } > + else > + return 0; > + > + return 1; > +} > + > static uint64_t (*__read_mostly tick_to_ns)(uint64_t) = acpi_pm_tick_to_ns; > > void (*__read_mostly pm_idle_save)(void); > @@ -789,25 +812,8 @@ static int check_cx(struct acpi_processo > if ( local_apic_timer_c2_ok ) > break; > case ACPI_STATE_C3: > - if ( boot_cpu_has(X86_FEATURE_ARAT) ) > - { > - lapic_timer_off = lapic_timer_nop; > - lapic_timer_on = lapic_timer_nop; > - } > - else if ( hpet_broadcast_is_available() ) > - { > - lapic_timer_off = hpet_broadcast_enter; > - lapic_timer_on = hpet_broadcast_exit; > - } > - else if ( pit_broadcast_is_available() ) > - { > - lapic_timer_off = pit_broadcast_enter; > - lapic_timer_on = pit_broadcast_exit; > - } > - else > - { > + if ( !lapic_timer_init() ) > return -EINVAL; > - } > > /* All the logic here assumes flags.bm_check is same across all CPUs > */ > if ( bm_check_flag == -1 ) > --- a/xen/arch/x86/cpu/mwait-idle.c > +++ b/xen/arch/x86/cpu/mwait-idle.c > @@ -56,6 +56,7 @@ > #include <xen/softirq.h> > #include <xen/trace.h> > #include <asm/cpuidle.h> > +#include <asm/hpet.h> > #include <asm/mwait.h> > #include <asm/msr.h> > #include <acpi/cpufreq/cpufreq.h> > @@ -501,6 +502,12 @@ int __init mwait_idle_init(struct notifi > > err = mwait_idle_probe(); > if (!err) { > + if (!boot_cpu_has(X86_FEATURE_ARAT)) > + hpet_broadcast_init(); > + if (!lapic_timer_init()) > + err = -EINVAL; > + } > + if (!err) { > nfb->notifier_call = mwait_idle_cpu_init; > mwait_idle_cpu_init(nfb, CPU_UP_PREPARE, NULL); > > --- a/xen/arch/x86/hpet.c > +++ b/xen/arch/x86/hpet.c > @@ -495,7 +495,7 @@ void __init hpet_broadcast_init(void) > u32 hpet_id, cfg; > unsigned int i, n; > > - if ( hpet_rate == 0 ) > + if ( hpet_rate == 0 || hpet_broadcast_is_available() ) > return; > > cfg = hpet_read32(HPET_CFG); > --- a/xen/include/asm-x86/cpuidle.h > +++ b/xen/include/asm-x86/cpuidle.h > @@ -10,6 +10,7 @@ extern struct acpi_processor_power *proc > > extern void (*pm_idle_save)(void); > > +bool_t lapic_timer_init(void); > extern void (*lapic_timer_off)(void); > extern void (*lapic_timer_on)(void); > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel