All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/12] x86: tsc: Introduce config option for early timer frequency
Date: Sat, 13 Oct 2018 08:06:52 -0700	[thread overview]
Message-ID: <1539443214-19048-11-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1539443214-19048-1-git-send-email-bmeng.cn@gmail.com>

So far the TSC timer driver supports trying hardware calibration first
and using device tree as last resort for its running frequency as the
normal timer.

However when it is used as the early timer, it only supports hardware
calibration and if it fails, the driver just panics. This introduces
a new config option to specify the early timer frequency and it should
be equal to the value described in the device tree.

Without this patch, the travis-ci testing on QEMU x86_64 target fails
each time after it finishes the 'bootefi selftest' as the test.py see
an error was emitted on the console like this:

  TSC frequency is ZERO
  resetting ...
  ### ERROR ### Please RESET the board ###

It's strange that this error is consistently seen on the travis-ci
machine, but only occasionally seen on my local machine (maybe 1 out
of 10). Since QEMU x86_64 target enables BOOTSTAGE support which uses
early timer, with this fix it should work without any failure.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/timer/Kconfig     | 10 ++++++++++
 drivers/timer/tsc_timer.c | 10 ++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index 45a256a..f300f87 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -82,6 +82,16 @@ config X86_TSC_TIMER
 	help
 	  Select this to enable Time-Stamp Counter (TSC) timer for x86.
 
+config X86_TSC_TIMER_EARLY_FREQ
+	int "x86 TSC timer frequency when it is used as the early timer"
+	depends on X86_TSC_TIMER
+	default 1000000000
+	help
+	  Sets the TSC timer frequency when TSC is used as the ealy timer
+	  and the frequency can neither be calibrated via some hardware
+	  ways, nor got from device tree at the time when device tree is
+	  not available yet.
+
 config OMAP_TIMER
 	bool "Omap timer support"
 	depends on TIMER
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 6473de2..5dc6f9e 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -341,7 +341,7 @@ static int tsc_timer_get_count(struct udevice *dev, u64 *count)
 	return 0;
 }
 
-static void tsc_timer_ensure_setup(bool stop)
+static void tsc_timer_ensure_setup(bool early)
 {
 	if (gd->arch.tsc_base)
 		return;
@@ -362,10 +362,12 @@ static void tsc_timer_ensure_setup(bool stop)
 		if (fast_calibrate)
 			goto done;
 
-		if (stop)
-			panic("TSC frequency is ZERO");
-		else
+		if (early) {
+			gd->arch.clock_rate = CONFIG_X86_TSC_TIMER_EARLY_FREQ;
+			return;
+		} else {
 			return;
+		}
 
 done:
 		gd->arch.clock_rate = fast_calibrate * 1000000;
-- 
2.7.4

  parent reply	other threads:[~2018-10-13 15:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13 15:06 [U-Boot] [PATCH 00/12] x86: Attempt to bring qemu-x86_64 target in travis-ci build/testing Bin Meng
2018-10-13 15:06 ` [U-Boot] [PATCH 01/12] x86: Specify -march=core2 to build 64-bit U-Boot proper Bin Meng
2018-10-13 15:06 ` [U-Boot] [PATCH 02/12] x86: Ensure no instruction sets of MMX/SSE are generated in 64-bit build Bin Meng
2018-10-13 15:49   ` Heinrich Schuchardt
2018-10-13 15:06 ` [U-Boot] [PATCH 03/12] x86: doc: Mention qemu-x86_64 support Bin Meng
2018-10-13 15:53   ` Heinrich Schuchardt
2018-10-13 15:06 ` [U-Boot] [PATCH 04/12] x86: doc: Remove stale sections of 64-bit support Bin Meng
2018-10-13 15:56   ` Heinrich Schuchardt
2018-10-13 15:06 ` [U-Boot] [PATCH 05/12] x86: qemu: enable CONFIG_SPL_DM_RTC Bin Meng
2018-10-19  3:25   ` Simon Glass
2018-10-13 15:06 ` [U-Boot] [PATCH 06/12] x86: detect unsupported relocation types Bin Meng
2018-10-13 15:06 ` [U-Boot] [PATCH 07/12] x86: put global data pointer into the .data section Bin Meng
2018-10-19  3:26   ` Simon Glass
2018-10-13 15:06 ` [U-Boot] [PATCH 08/12] efi_loader: fix relocation on x86_64 Bin Meng
2018-10-13 15:06 ` [U-Boot] [PATCH 09/12] x86: Fix the mystery of printch() during 64-bit boot Bin Meng
2018-10-13 16:20   ` Heinrich Schuchardt
2018-10-13 15:06 ` Bin Meng [this message]
2018-10-13 16:44   ` [U-Boot] [PATCH 10/12] x86: tsc: Introduce config option for early timer frequency Heinrich Schuchardt
2018-10-13 16:50     ` Bin Meng
2018-10-13 15:06 ` [U-Boot] [PATCH 11/12] x86: quark: Specify X86_TSC_TIMER_EARLY_FREQ Bin Meng
2018-10-13 16:49   ` Heinrich Schuchardt
2018-10-13 15:06 ` [U-Boot] [PATCH 12/12] WIP: travis: Add qemu-x86_64 target for test.py testing Bin Meng
2018-10-13 15:52   ` Bin Meng
2018-10-13 16:52     ` Bin Meng

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=1539443214-19048-11-git-send-email-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.