Skip to contentSkip to conversation

tsc: Change default tsc calibration method to EFI on EFI systems

PATCH Superseded David E. Box 4 participants 6 messages Sep 6, 2017 – Sep 15, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tsc: Change default tsc calibration method to EFI on EFI systems

On efi systems, make efi based tsc calibration the default, followed by the pmtimer before using the pit. This prevents Grub boot failure on newer x86 systems that power gate the pit.

---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +1 -1
index 2e85289d8..de4057ddb 100644
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_COREBOOT)
   (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #else
Signature · 1 line
2.13.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · On Wed, 6 Sep 2017 13:20:54 -0700 "David E. Box"…

On efi systems, make efi based tsc calibration the default, followed by the pmtimer before using the pit. This prevents Grub boot failure on newer x86 systems that power gate the pit.

---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +0 -0
index 2e85289d8..de4057ddb 100644

grub-core/kern/i386/tsc.c grub_tsc_init (void) · line 74

Quoted 8 lines
grub-core/kern/i386/tsc.c +1 -1
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_COREBOOT)
   (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #else

Good catch!

Noted the baked-in, minor style cleanup:
grub_tsc_calibrate_from_efi() -> grub_tsc_calibrate_from_efi ()

You have my:

Cheers

#2 lore raw
In reply to David E. Box

Dear David,

Am Mittwoch, den 06.09.2017, 13:20 -0700 schrieb David E. Box:

Quoted 3 lines

On efi systems, make efi based tsc calibration the default, followed by the pmtimer before using the pit. This prevents Grub boot failure on newer x86 systems that power gate the pit.

Could you please be specific, what “newer x86 systems” are? Also, what is the “GRUB boot failure”? A hang?

What about older EFI x86 systems? Is there a chance, that they hang now?

Quoted 10 lines
---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +0 -0
index 2e85289d8..de4057ddb 100644

grub-core/kern/i386/tsc.c grub_tsc_init (void) · line 74

Quoted 8 lines
grub-core/kern/i386/tsc.c +1 -1
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_COREBOOT)
   (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
 #else

Thanks,

Paul

#3 lore raw

Hi Paul,

Quoted 10 lines · Paul Menzel

Dear David,

Am Mittwoch, den 06.09.2017, 13:20 -0700 schrieb David E. Box:

Quoted 5 lines

On efi systems, make efi based tsc calibration the default, followed by
the pmtimer before using the pit. This prevents Grub boot failure on
newer x86 systems that power gate the pit.

Quoted 3 lines

Could you please be specific, what “newer x86 systems” are? Also, what
is the “GRUB boot failure”? A hang?

Intel SoC's supporting the S0ix feature require the 8254 to be power gated. This feature as been around as early as the Cherry Trail line. In order to support this some firmware configurations clock gate the 8254 by default. This causes grub to hang on these systems when they attempt to use it to calibrate the tsc.

See section 18.9.2.4 in https://www.intel.com/content/www/us/en/process
ors/atom/atom-z8000-datasheet-vol-1.html

Quoted 4 lines

What about older EFI x86 systems? Is there a chance, that they hang now?support this some firmware configurations clock gate the 8254 by default. This causes grub to hang on t

Can't say for sure. I have no reason to suspect so. Such a system would have to have no (or broken) support for the EFI_STALL boot service command, which has been around since EFI 1.0.

Quoted 29 lines
Quoted 19 lines
---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +1 -1
index 2e85289d8..de4057ddb 100644
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () ||
 calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () ||
 grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi()
 || calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi () ||
Quoted 6 lines

grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#elif defined (GRUB_MACHINE_COREBOOT)
(void) (grub_tsc_calibrate_from_pmtimer () ||
grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#else

Thanks,

Quoted 1 line

Paul

Dave

#4 lore raw
In reply to David E. Box
Quoted 4 lines · On Wed, Sep 6, 2017, 22:21 David E. Box <[email protected]> wrote:

On efi systems, make efi based tsc calibration the default, followed by the pmtimer before using the pit. This prevents Grub boot failure on newer x86 systems that power gate the pit.

Why does put code fail? I think it was changed to detect gated pit. Also I'd prefer to use pmtimer first as we had problems with event and time routines on some Macs. Any reason not to use pmtimer first?

Quoted 33 lines
---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +0 -1
index 2e85289d8..de4057ddb 100644
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () ||

grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+ (void) (grub_tsc_calibrate_from_efi () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#elif defined (GRUB_MACHINE_COREBOOT)
(void) (grub_tsc_calibrate_from_pmtimer () ||
grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#else
--
2.13.5

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
Quoted 11 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines · On Wed, Sep 6, 2017, 22:21 David E. Box <[email protected]> wrote:

On efi systems, make efi based tsc calibration the default, followed by
the pmtimer before using the pit. This prevents Grub boot failure on
newer x86 systems that power gate the pit.

Why does put code fail? I think it was changed to detect gated pit.

On these systems, even though the pit is gated the timer2 latch logic still works. So when the tics are set the latch still goes from high to active low as expected for a functional timer. But since the device is clock gated it never counts down and the bit never gets reset, leading to an infinite loop.

Quoted 2 lines

Also I'd prefer to use pmtimer first as we had problems with event and time routines on some Macs. Any reason not to use pmtimer first?

No reason not to use pmtimer first. I had not considered boot speed as well which must be prioritized. I'll submit a new patch.

Quoted 37 lines
Quoted 28 lines
---
 grub-core/kern/i386/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/i386/tsc.c +1 -1
index 2e85289d8..de4057ddb 100644
@@ -68,7 +68,7 @@ grub_tsc_init (void)
 #ifdef GRUB_MACHINE_XEN
   (void) (grub_tsc_calibrate_from_xen () ||
 calibrate_tsc_hardcode());
 #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pit () ||
 grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi()
 || calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi () ||

grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#elif defined (GRUB_MACHINE_COREBOOT)
(void) (grub_tsc_calibrate_from_pmtimer () ||
grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#else
--
2.13.5

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel