From: Laszlo Ersek <lersek@redhat.com>
To: grub-devel@gnu.org, vkuznets@redhat.com, decui@microsoft.com,
pjones@redhat.com, lersek@redhat.com
Subject: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
Date: Wed, 26 Nov 2014 09:59:21 +0100 [thread overview]
Message-ID: <1416992361-4167-1-git-send-email-lersek@redhat.com> (raw)
HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
services instead.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Notes:
Please note that I'm not subscribed to the list.
grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
index 3a4cae6..e499648 100644
--- a/grub-core/kern/i386/tsc.c
+++ b/grub-core/kern/i386/tsc.c
@@ -26,9 +26,14 @@
#include <grub/i386/tsc.h>
#include <grub/i386/cpuid.h>
#ifdef GRUB_MACHINE_XEN
-#include <grub/xen.h>
+# include <grub/xen.h>
#else
-#include <grub/i386/pit.h>
+# ifdef GRUB_MACHINE_EFI
+# include <grub/efi/efi.h>
+# include <grub/efi/api.h>
+# else
+# include <grub/i386/pit.h>
+# endif
#endif
#include <grub/cpu/io.h>
@@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
#ifndef GRUB_MACHINE_XEN
static void
-grub_pit_wait (grub_uint16_t tics)
+grub_stall (grub_uint16_t tics)
{
+# ifdef GRUB_MACHINE_EFI
+ grub_uint64_t microseconds;
+
+ microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
+ efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
+# else
/* Disable timer2 gate and speaker. */
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
@@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
GRUB_PIT_SPEAKER_PORT);
+# endif
}
#endif
@@ -119,7 +131,7 @@ calibrate_tsc (void)
grub_uint64_t end_tsc;
tsc_boot_time = grub_get_tsc ();
- grub_pit_wait (0xffff);
+ grub_stall (0xffff);
end_tsc = grub_get_tsc ();
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
--
1.8.3.1
next reply other threads:[~2014-11-26 13:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 8:59 Laszlo Ersek [this message]
2014-11-26 13:42 ` [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Andrei Borzenkov
2014-11-26 13:49 ` Laszlo Ersek
2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-12-03 18:59 ` Andrei Borzenkov
2015-11-27 17:55 ` Andrei Borzenkov
2015-11-28 5:25 ` Elliott, Robert (Persistent Memory)
2015-11-28 6:02 ` Andrei Borzenkov
2015-11-30 16:31 ` Vitaly Kuznetsov
2015-11-30 16:50 ` Andrei Borzenkov
2015-11-30 17:34 ` Andrei Borzenkov
2015-11-30 18:19 ` Vitaly Kuznetsov
2015-12-01 3:11 ` Michael Chang
2015-12-01 8:34 ` Vitaly Kuznetsov
2015-12-01 15:54 ` Andrei Borzenkov
2015-12-02 11:02 ` Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416992361-4167-1-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=decui@microsoft.com \
--cc=grub-devel@gnu.org \
--cc=pjones@redhat.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).