Skip to contentSkip to conversation

x86/hpet: Disable legacy replacement mode after IRQ test if not needed

PATCH Superseded Simon Gaiser 3 participants 6 messages Jul 18, 2023 – Jul 24, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hpet: Disable legacy replacement mode after IRQ test if not needed

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test. For previous discussion see [1]. Keeping it enabled prevents reaching S0ix residency.

---
 xen/arch/x86/io_apic.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/io_apic.c +4 -0
index 9b8a972cf5..ea98d717d0 100644
@@ -1966,6 +1966,10 @@ static void __init check_timer(void)
 
             if ( timer_irq_works() )
             {
+                if ( boot_cpu_has(X86_FEATURE_ARAT) ) {
+                    printk(XENLOG_INFO "IRQ test with HPET Legacy Replacement Mode worked. Disabling it again.\n");
+                    hpet_disable_legacy_replacement_mode();
+                }
                 local_irq_restore(flags);
                 return;
             }
Signature · 1 line
2.40.1
#1 lore raw
Quoted 2 lines · Simon Gaiser

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test.

What's the relation with ARAT here?

It would seem to me that keeping legacy replacement enabled should only be done when opt_hpet_legacy_replacement > 0, and the currently modified block is already in a opt_hpet_legacy_replacement < 0 gated chunk.

Thanks, Roger.

#2 lore raw

Roger Pau Monné:

Quoted 10 lines · Simon Gaiser
Quoted 2 lines

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test.

What's the relation with ARAT here?

It would seem to me that keeping legacy replacement enabled should only be done when opt_hpet_legacy_replacement > 0, and the currently modified block is already in a opt_hpet_legacy_replacement < 0 gated chunk.

I was concerned that on systems without ARAT cpuidle might rely on HPET legacy mode being available. See _disable_pit_irq and lapic_timer_init. But now that I stared at this again, I think that condition isn't actually needed. If we reach that code we know that we have no working PIT, but HPET is working. So _disable_pit_irq which is run after check_timer (__start_xen first calls check_timer via smp_prepare_cpus and only later disable_pit_irq via do_initcalls) will setup HPET broadcast, which should succeed since HPET worked previously.

So I guess we can just drop the condition (please double check, that code is quite tangled and I'm not familiar with it).

Simon

#3 lore raw
Quoted 21 lines · Simon Gaiser

Roger Pau Monné:

Quoted 10 lines · Simon Gaiser
Quoted 2 lines

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test.

What's the relation with ARAT here?

It would seem to me that keeping legacy replacement enabled should only be done when opt_hpet_legacy_replacement > 0, and the currently modified block is already in a opt_hpet_legacy_replacement < 0 gated chunk.

I was concerned that on systems without ARAT cpuidle might rely on HPET legacy mode being available. See _disable_pit_irq and lapic_timer_init. But now that I stared at this again, I think that condition isn't actually needed. If we reach that code we know that we have no working PIT, but HPET is working. So _disable_pit_irq which is run after check_timer (__start_xen first calls check_timer via smp_prepare_cpus and only later disable_pit_irq via do_initcalls) will setup HPET broadcast, which should succeed since HPET worked previously.

Quoted 2 lines

So I guess we can just drop the condition (please double check, that code is quite tangled and I'm not familiar with it).

What you want to respect instead though is opt_hpet_legacy_replacement.

Jan

#4 lore raw

Jan Beulich:

Quoted 22 lines · Simon Gaiser
Quoted 21 lines

Roger Pau Monné:

Quoted 10 lines · Simon Gaiser
Quoted 2 lines

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test.

What's the relation with ARAT here?

It would seem to me that keeping legacy replacement enabled should only be done when opt_hpet_legacy_replacement > 0, and the currently modified block is already in a opt_hpet_legacy_replacement < 0 gated chunk.

I was concerned that on systems without ARAT cpuidle might rely on HPET legacy mode being available. See _disable_pit_irq and lapic_timer_init. But now that I stared at this again, I think that condition isn't actually needed. If we reach that code we know that we have no working PIT, but HPET is working. So _disable_pit_irq which is run after check_timer (__start_xen first calls check_timer via smp_prepare_cpus and only later disable_pit_irq via do_initcalls) will setup HPET broadcast, which should succeed since HPET worked previously.

Quoted 4 lines
Quoted 2 lines

So I guess we can just drop the condition (please double check, that code is quite tangled and I'm not familiar with it).

What you want to respect instead though is opt_hpet_legacy_replacement.

Can you please explain what behavior you expect? As Roger pointed out this code only runs with opt_hpet_legacy_replacement < 0 so the user didn't make an explicit choice. In that case enabling the legacy mode for the timer IRQ test and then disabling it to allow lower power modes seems reasonable to me.

Simon

#5 lore raw
Quoted 23 lines · Simon Gaiser

Jan Beulich:

Quoted 22 lines · Simon Gaiser
Quoted 21 lines

Roger Pau Monné:

Quoted 10 lines · Simon Gaiser
Quoted 2 lines

As far as I understand the HPET legacy mode is not required on systems with ARAT after the timer IRQ test.

What's the relation with ARAT here?

It would seem to me that keeping legacy replacement enabled should only be done when opt_hpet_legacy_replacement > 0, and the currently modified block is already in a opt_hpet_legacy_replacement < 0 gated chunk.

I was concerned that on systems without ARAT cpuidle might rely on HPET legacy mode being available. See _disable_pit_irq and lapic_timer_init. But now that I stared at this again, I think that condition isn't actually needed. If we reach that code we know that we have no working PIT, but HPET is working. So _disable_pit_irq which is run after check_timer (__start_xen first calls check_timer via smp_prepare_cpus and only later disable_pit_irq via do_initcalls) will setup HPET broadcast, which should succeed since HPET worked previously.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

So I guess we can just drop the condition (please double check, that code is quite tangled and I'm not familiar with it).

What you want to respect instead though is opt_hpet_legacy_replacement.

Can you please explain what behavior you expect? As Roger pointed out this code only runs with opt_hpet_legacy_replacement < 0 so the user didn't make an explicit choice.

Oh, I'm sorry. Please disregard my comment then.

Jan