Use UEFI Time Service to calibrate TSC
PATCH 1/1 Use UEFI Time Service to calibrate TSC
This patch tries to detect PIT timer is broken and use UEFI Time Service to calibrate TSC.
--- grub-core/kern/i386/tsc.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-)
grub-core/kern/i386/tsc.c +29 -4
@@ -29,6 +29,10 @@#include <grub/xen.h> #else #include <grub/i386/pit.h> +#ifdef GRUB_MACHINE_EFI +#include <grub/efi/efi.h> +#include <grub/efi/api.h> +#endif #endif #include <grub/cpu/io.h>
@@ -72,7 +76,7 @@ grub_cpu_is_tsc_supported (void) }static void -grub_pit_wait (grub_uint16_t tics) +grub_pit_wait (grub_uint16_t tics,int *is_started) {/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
@@ -90,8 +94,17 @@ grub_pit_wait (grub_uint16_t tics) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); -/* Wait. */ -while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); +if ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH )) + { +/* The ticks have expired too fast to know the counting really started or not */ + *is_started =0 ; + } +else + { + *is_started =1 ; +/* Wait. */ +while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); + }/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
@@ -117,11 +130,23 @@ calibrate_tsc (void) {/* First calibrate the TSC rate (relative, not absolute time). */ grub_uint64_t end_tsc; +int is_started; tsc_boot_time =grub_get_tsc (); -grub_pit_wait (0xffff ); +grub_pit_wait (0xffff , &is_started); end_tsc =grub_get_tsc (); +#ifdef GRUB_MACHINE_EFI +/* The PIT is broken as 55ms is too sufficent to any cpu to catch it */ +if (!is_started) + { +/* Use EFI Time Service to calibrate TSC */ + tsc_boot_time =grub_get_tsc (); +efi_call_1 (grub_efi_system_table->boot_services->stall,54925 ); + end_tsc =grub_get_tsc (); + } +#endif + grub_tsc_rate =0 ;if (end_tsc > tsc_boot_time) grub_tsc_rate =grub_divmod64 ((55ULL <<32 ), end_tsc - tsc_boot_time,0 );
Signature · 1 line
1.7.3.4
Quoted 2 lines · Michael Chang
This patch tries to detect PIT timer is broken and use UEFI Time Service to calibrate TSC.
Second try :)
https://lists.gnu.org/archive/html/grub-devel/2014-11/msg00079.html
Although I think that this one is acceptable - it is used as fallback only. Will it also catch the case when PIT is not present at all?
Quoted 81 lines
--- grub-core/kern/i386/tsc.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-)grub-core/kern/i386/tsc.c +29
-5@@ -29,6 +29,10 @@#include <grub/xen.h> #else #include <grub/i386/pit.h> +#ifdef GRUB_MACHINE_EFI +#include <grub/efi/efi.h> +#include <grub/efi/api.h> +#endif #endif #include <grub/cpu/io.h> @@ -72,7 +76,7 @@ grub_cpu_is_tsc_supported (void) }static void -grub_pit_wait (grub_uint16_t tics) +grub_pit_wait (grub_uint16_t tics,int *is_started) {/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -90,8 +94,17 @@ grub_pit_wait (grub_uint16_t tics) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); -/* Wait. */ -while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); +if ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH )) + { +/* The ticks have expired too fast to know the counting really started or not */ + *is_started =0 ; + } +else + { + *is_started =1 ; +/* Wait. */ +while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); + }/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -117,11 +130,23 @@ calibrate_tsc (void) {/* First calibrate the TSC rate (relative, not absolute time). */ grub_uint64_t end_tsc; +int is_started; tsc_boot_time =grub_get_tsc (); -grub_pit_wait (0xffff ); +grub_pit_wait (0xffff , &is_started); end_tsc =grub_get_tsc (); +#ifdef GRUB_MACHINE_EFI +/* The PIT is broken as 55ms is too sufficent to any cpu to catch it */ +if (!is_started) + { +/* Use EFI Time Service to calibrate TSC */ + tsc_boot_time =grub_get_tsc (); +efi_call_1 (grub_efi_system_table->boot_services->stall,54925 ); + end_tsc =grub_get_tsc (); + } +#endif + grub_tsc_rate =0 ;if (end_tsc > tsc_boot_time) grub_tsc_rate =grub_divmod64 ((55ULL <<32 ), end_tsc - tsc_boot_time,0 ); --1.7.3.4
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Andrei Borzenkov
Quoted 2 lines · Michael Chang
This patch tries to detect PIT timer is broken and use UEFI Time Service to calibrate TSC.
Second try :)
https://lists.gnu.org/archive/html/grub-devel/2014-11/msg00079.html
Although I think that this one is acceptable - it is used as fallback only. Will it also catch the case when PIT is not present at all?
I think yes, actually this patch was tested and can fix the timeout problem on hyper-v Generation 2 VMs with UEFI, which is known to ship without PIT.
In addition to that, the linux kernel also calibrates the tsc via PIT as default on x86.
http://lxr.free-electrons.com/source/arch/x86/kernel/tsc.c#L441
But with some sanity checks to detect the SMI storm interfering the result and will fallback to other timer sources if the sanity check fails. This patch is inspired by that one of that check with much more restricted loopmin to "1" that's basically a insane condition.
Thanks,
Michael
Quoted 87 lines
Quoted 78 lines
--- grub-core/kern/i386/tsc.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-)grub-core/kern/i386/tsc.c +29
-5@@ -29,6 +29,10 @@#include <grub/xen.h> #else #include <grub/i386/pit.h> +#ifdef GRUB_MACHINE_EFI +#include <grub/efi/efi.h> +#include <grub/efi/api.h> +#endif #endif #include <grub/cpu/io.h> @@ -72,7 +76,7 @@ grub_cpu_is_tsc_supported (void) }static void -grub_pit_wait (grub_uint16_t tics) +grub_pit_wait (grub_uint16_t tics,int *is_started) {/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -90,8 +94,17 @@ grub_pit_wait (grub_uint16_t tics) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); -/* Wait. */ -while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); +if ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH )) + { +/* The ticks have expired too fast to know the counting really started or not */ + *is_started =0 ; + } +else + { + *is_started =1 ; +/* Wait. */ +while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); + }/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -117,11 +130,23 @@ calibrate_tsc (void) {/* First calibrate the TSC rate (relative, not absolute time). */ grub_uint64_t end_tsc; +int is_started; tsc_boot_time =grub_get_tsc (); -grub_pit_wait (0xffff ); +grub_pit_wait (0xffff , &is_started); end_tsc =grub_get_tsc (); +#ifdef GRUB_MACHINE_EFI +/* The PIT is broken as 55ms is too sufficent to any cpu to catch it */ +if (!is_started) + { +/* Use EFI Time Service to calibrate TSC */ + tsc_boot_time =grub_get_tsc (); +efi_call_1 (grub_efi_system_table->boot_services->stall,54925 ); + end_tsc =grub_get_tsc (); + } +#endif + grub_tsc_rate =0 ;if (end_tsc > tsc_boot_time) grub_tsc_rate =grub_divmod64 ((55ULL <<32 ), end_tsc - tsc_boot_time,0 ); --1.7.3.4
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
Quoted 19 lines · Michael Chang
Quoted 10 lines · Andrei Borzenkov
Quoted 2 lines · Michael Chang
This patch tries to detect PIT timer is broken and use UEFI Time Service to calibrate TSC.
Second try :)
https://lists.gnu.org/archive/html/grub-devel/2014-11/msg00079.html
Although I think that this one is acceptable - it is used as fallback only. Will it also catch the case when PIT is not present at all?
I think yes, actually this patch was tested and can fix the timeout problem on hyper-v Generation 2 VMs with UEFI, which is known to ship without PIT.
In addition to that, the linux kernel also calibrates the tsc via PIT as default on x86.
Quoted 7 lines
http://lxr.free-electrons.com/source/arch/x86/kernel/tsc.c#L441
But with some sanity checks to detect the SMI storm interfering the result and will fallback to other timer sources if the sanity check fails. This patch is inspired by that one of that check with much more restricted loopmin to "1" that's basically a insane condition.
I like some aspects of this patch, i.a. that it's unlikely to break compatibility. ut I feel that we can do a bit better:
1) Returning through pointed variable is expensive in terms of binary size. Just plain return is better.
2) More modern calibrations can calibrate in 1ms, not 55ms. This is one that slows down coreboot boot (I think only USB init is slower).
3) We could have a cascade of methods. E.g.
on EFI: PIT -> PM -> Stall -> hardcoded 1GHz (putting PM as first would be slightly more risk
on coreboot: PM -> PIT -> hardcoded 1GHz
rest: PIT -> hardcoded 1GHz (need to keep size down)
I'm going to prepare proof-of-concept patch
Quoted 96 lines
Thanks,
MichaelQuoted 78 lines
Quoted 78 lines
--- grub-core/kern/i386/tsc.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-)grub-core/kern/i386/tsc.c +29
-5@@ -29,6 +29,10 @@#include <grub/xen.h> #else #include <grub/i386/pit.h> +#ifdef GRUB_MACHINE_EFI +#include <grub/efi/efi.h> +#include <grub/efi/api.h> +#endif #endif #include <grub/cpu/io.h> @@ -72,7 +76,7 @@ grub_cpu_is_tsc_supported (void) }static void -grub_pit_wait (grub_uint16_t tics) +grub_pit_wait (grub_uint16_t tics,int *is_started) {/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -90,8 +94,17 @@ grub_pit_wait (grub_uint16_t tics) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); -/* Wait. */ -while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); +if ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH )) + { +/* The ticks have expired too fast to know the counting really started or not */ + *is_started =0 ; + } +else + { + *is_started =1 ; +/* Wait. */ +while ((grub_inb (GRUB_PIT_SPEAKER_PORT ) &GRUB_PIT_SPK_TMR2_LATCH ) ==0x00 ); + }/* Disable timer2 gate and speaker. */ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)@@ -117,11 +130,23 @@ calibrate_tsc (void) {/* First calibrate the TSC rate (relative, not absolute time). */ grub_uint64_t end_tsc; +int is_started; tsc_boot_time =grub_get_tsc (); -grub_pit_wait (0xffff ); +grub_pit_wait (0xffff , &is_started); end_tsc =grub_get_tsc (); +#ifdef GRUB_MACHINE_EFI +/* The PIT is broken as 55ms is too sufficent to any cpu to catch it */ +if (!is_started) + { +/* Use EFI Time Service to calibrate TSC */ + tsc_boot_time =grub_get_tsc (); +efi_call_1 (grub_efi_system_table->boot_services->stall,54925 ); + end_tsc =grub_get_tsc (); + } +#endif + grub_tsc_rate =0 ;if (end_tsc > tsc_boot_time) grub_tsc_rate =grub_divmod64 ((55ULL <<32 ), end_tsc - tsc_boot_time,0 ); --1.7.3.4
Quoted 9 lines
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_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 39 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 19 lines · Michael Chang
Quoted 10 lines · Andrei Borzenkov
Quoted 2 lines · Michael Chang
This patch tries to detect PIT timer is broken and use UEFI Time Service to calibrate TSC.
Second try :)
https://lists.gnu.org/archive/html/grub-devel/2014-11/msg00079.html
Although I think that this one is acceptable - it is used as fallback only. Will it also catch the case when PIT is not present at all?
I think yes, actually this patch was tested and can fix the timeout problem on hyper-v Generation 2 VMs with UEFI, which is known to ship without PIT.
In addition to that, the linux kernel also calibrates the tsc via PIT as default on x86.
Quoted 7 lines
http://lxr.free-electrons.com/source/arch/x86/kernel/tsc.c#L441
But with some sanity checks to detect the SMI storm interfering the result and will fallback to other timer sources if the sanity check fails. This patch is inspired by that one of that check with much more restricted loopmin to "1" that's basically a insane condition.
I like some aspects of this patch, i.a. that it's unlikely to break compatibility. ut I feel that we can do a bit better:
1) Returning through pointed variable is expensive in terms of binary size. Just plain return is better.
2) More modern calibrations can calibrate in 1ms, not 55ms. This is one that slows down coreboot boot (I think only USB init is slower).
3) We could have a cascade of methods. E.g.
on EFI: PIT -> PM -> Stall -> hardcoded 1GHz (putting PM as first would be slightly more risk
on coreboot: PM -> PIT -> hardcoded 1GHz
rest: PIT -> hardcoded 1GHz (need to keep size down)
Quoted 1 line
I'm going to prepare proof-of-concept patch
Attached proof-of-concept. It's all in one file but different methods should probably go in separate files.
grub-core/commands/efi/acpi.c deleted +0 -59
@@ -1,59 +0,0 @@ -/* acpi.c - get acpi tables. */ -/* -* GRUB -- GRand Unified Bootloader -* Copyright (C) 2009 Free Software Foundation, Inc. -* -* GRUB is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* GRUB is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with GRUB. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <grub/acpi.h> -#include <grub/misc.h> -#include <grub/efi/efi.h> -#include <grub/efi/api.h> - -struct grub_acpi_rsdp_v10 * -grub_machine_acpi_get_rsdpv1 (void ) -{ -unsigned i; -static grub_efi_packed_guid_t acpi_guid =GRUB_EFI_ACPI_TABLE_GUID ; - -for (i =0 ; i < grub_efi_system_table->num_table_entries; i++) - { -grub_efi_packed_guid_t *guid = - &grub_efi_system_table->configuration_table[i].vendor_guid; - -if (!grub_memcmp (guid, &acpi_guid,sizeof (grub_efi_packed_guid_t))) -return (struct grub_acpi_rsdp_v10 *) - grub_efi_system_table->configuration_table[i].vendor_table; - } -return 0 ; -} - -struct grub_acpi_rsdp_v20 * -grub_machine_acpi_get_rsdpv2 (void ) -{ -unsigned i; -static grub_efi_packed_guid_t acpi20_guid =GRUB_EFI_ACPI_20_TABLE_GUID ; - -for (i =0 ; i < grub_efi_system_table->num_table_entries; i++) - { -grub_efi_packed_guid_t *guid = - &grub_efi_system_table->configuration_table[i].vendor_guid; - -if (!grub_memcmp (guid, &acpi20_guid,sizeof (grub_efi_packed_guid_t))) -return (struct grub_acpi_rsdp_v20 *) - grub_efi_system_table->configuration_table[i].vendor_table; - } -return 0 ; -}
grub-core/kern/acpi.c new file +119 -0
119 lines not on this page · raw message
grub-core/kern/efi/acpi.c new file +59 -0
59 lines not on this page · raw message
grub-core/Makefile.am +3 -0
@@ -101,6 +101,7 @@ if COND_i386_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h endif
@@ -112,6 +113,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_multiboot
@@ -154,6 +156,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_ia64_efi
grub-core/Makefile.core.def +6 -4
@@ -171,6 +171,12 @@ kernel = { efi = kern/efi/init.c; efi = kern/efi/mm.c; efi = term/efi/console.c; + efi = kern/acpi.c; + efi = kern/efi/acpi.c; + i386_coreboot = kern/i386/pc/acpi.c; + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; + i386_multiboot = kern/acpi.c; x86 = kern/i386/tsc.c;
@@ -665,10 +671,6 @@ module = { name = acpi; common = commands/acpi.c; - efi = commands/efi/acpi.c; - i386_pc = commands/i386/pc/acpi.c; - i386_coreboot = commands/i386/pc/acpi.c; - i386_multiboot = commands/i386/pc/acpi.c; enable = efi; enable = i386_pc;
grub-core/commands/acpi.c +0 -12
@@ -61,18 +61,6 @@ static const struct grub_arg_option options[] = { {0, 0, 0, 0, 0, 0} }; -/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ -grub_uint8_t -grub_byte_checksum (void *base,grub_size_t size) -{ -grub_uint8_t *ptr; -grub_uint8_t ret =0 ; -for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; - ptr++) - ret += *ptr; -return ret; -} -/* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise. rev2 contains the revision of ACPIv2+ to generate or 0 if none. */ static int rev1, rev2;
grub-core/kern/i386/tsc.c +134 -30
237 lines not on this page · raw message
include/grub/acpi.h +12 -5
@@ -67,10 +67,14 @@ struct grub_acpi_fadtgrub_uint32_t dsdt_addr;grub_uint8_t somefields1[20 ];grub_uint32_t pm1a; -grub_uint8_t somefields2[64 ]; +grub_uint8_t somefields2[8 ]; +grub_uint32_t pmtimer; +grub_uint8_t somefields3[32 ]; +grub_uint32_t flags; +grub_uint8_t somefields4[16 ];grub_uint64_t facs_xaddr;grub_uint64_t dsdt_xaddr; -grub_uint8_t somefields3[96 ]; +grub_uint8_t somefields5[96 ]; }GRUB_PACKED ;#define GRUB_ACPI_MADT_SIGNATURE "APIC"
@@ -176,9 +180,9 @@ enum#ifndef GRUB_DSDT_TEST struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void );struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void ); -struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void ); -struct grub_acpi_rsdp_v20 *grub_machine_acpi_get_rsdpv2 (void ); -grub_uint8_t grub_byte_checksum (void *base,grub_size_t size); +struct grub_acpi_rsdp_v10 *EXPORT_FUNC (grub_machine_acpi_get_rsdpv1 ) (void ); +struct grub_acpi_rsdp_v20 *EXPORT_FUNC (grub_machine_acpi_get_rsdpv2 ) (void ); +grub_uint8_t EXPORT_FUNC (grub_byte_checksum ) (void *base,grub_size_t size);grub_err_t grub_acpi_create_ebda (void );
@@ -234,4 +238,7 @@ enum GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87, }; +struct grub_acpi_fadt * +EXPORT_FUNC (grub_acpi_find_fadt ) (void ); +#endif /* ! GRUB_ACPI_HEADER */
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko
On 09.11.2015 09:03, Michael Chang wrote:
Attached proof-of-concept. It's all in one file but different methods should probably go in separate files.
Hi Vladmir,
Thanks for your guidence to the better fix. I built your patch with attach patch on top of yours to fix the errors found in our build service and also some other affected platforms which might also need the similar fix.
In the attatched patch, for i386-pc the acpi module was not built into kernel because from your patch seems not use pmtimer on it. That would be help in saving up the kernel image size.
I have tested on x86_64-efi and i386-pc and so far it works as expected. Please note I also manually tweaked the patch to run pmtimer calibration in efi and it also worked.
Thanks,
Michael
grub-core/Makefile.am +4 -0
@@ -118,6 +118,7 @@ endif if COND_i386_multiboot KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_qemu
@@ -162,6 +163,7 @@ endif if COND_ia64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_mips
@@ -236,11 +238,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_arm64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_emu
grub-core/Makefile.core.def +2 -0
@@ -675,6 +675,8 @@ module = { name = acpi; common = commands/acpi.c; + i386_pc = kern/i386/pc/acpi.c; + i386_pc = kern/acpi.c; enable = efi; enable = i386_pc;
grub-core/commands/i386/pc/acpi.c deleted +0 -83
83 lines not on this page · raw message
grub-core/kern/i386/pc/acpi.c new file +83 -0
83 lines not on this page · raw message
grub-core/kern/i386/tsc.c +7 -7
@@ -145,6 +145,13 @@ calibrate_tsc_pit (void) return 1; } +static int +calibrate_tsc_hardcode (void ) +{ + grub_tsc_rate =5368 ;/* 800 MHz */ +return 1 ; +} +#endif #if defined (GRUB_MACHINE_EFI )
@@ -229,13 +236,6 @@ calibrate_tsc_xen (void)#endif -static int -calibrate_tsc_hardcode (void ) -{ - grub_tsc_rate =5368 ;/* 800 MHz */ -return 1 ; -} -void grub_tsc_init (void ) {
Quoted 7 lines · Michael Chang
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko
On 09.11.2015 09:03, Michael Chang wrote:
Attached proof-of-concept. It's all in one file but different methods should probably go in separate files.
Quoted 7 lines
Hi Vladmir,
Thanks for your guidence to the better fix. I built your patch with attach patch on top of yours to fix the errors found in our build service and also some other affected platforms which might also need the similar fix.
Why did you need to move i386-pc ACPI files to core? They are used by acpi module only anyway, so there is no logical reason to do it?
Quoted 16 lines
In the attatched patch, for i386-pc the acpi module was not built into kernel because from your patch seems not use pmtimer on it. That would be help in saving up the kernel image size.
I have tested on x86_64-efi and i386-pc and so far it works as expected. Please note I also manually tweaked the patch to run pmtimer calibration in efi and it also worked.
Thanks,
Michael_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Andrei Borzenkov
Quoted 9 lines · Michael Chang
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko
On 09.11.2015 09:03, Michael Chang wrote:
Attached proof-of-concept. It's all in one file but different methods should probably go in separate files.
Hi Vladmir,
Quoted 8 lines
Quoted 5 lines
Thanks for your guidence to the better fix. I built your patch with attach patch on top of yours to fix the errors found in our build service and also some other affected platforms which might also need the similar fix.
Why did you need to move i386-pc ACPI files to core? They are used by acpi module only anyway, so there is no logical reason to do it?
Because Vladimir's prototype patch has been moved them.
+ i386_coreboot = kern/i386/pc/acpi.c; + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; + i386_multiboot = kern/acpi.c;
My patch was just intended to fix build error and test, Looking into the patch it seems needed by coreboot. I could't tell much that GRUB_MACHINE_MULTIBOOT is missed by accident or not in his patch.
+#elif defined (GRUB_MACHINE_COREBOOT)
+ (void) (calibrate_tsc_pmtimer() || calibrate_tsc_pit () ||calibrate_tsc_hardcode());
+#else
Thanks,
Michael