From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 1/2] x86: Add TSC-specific timer functions
Date: Fri, 20 Apr 2018 15:25:08 +0300 [thread overview]
Message-ID: <1524227108.21176.462.camel@linux.intel.com> (raw)
In-Reply-To: <269698c303c3da454b34f149d4a3562fc57091f2.1523570597.git.ivan.gorinov@intel.com>
On Thu, 2018-04-12 at 15:12 -0700, Ivan Gorinov wrote:
> Coreboot timestamp functions and Quark memory reference code use
> get_tbclk() to get TSC frequency. This will not work if another
> early timer is selected.
>
> Add tsc_rate_mhz() function and use it in the code that specifically
> needs to get TSC rate regardless of currently selected early timer.
> void delay_n(uint32_t ns)
> {
> /* 1000 MHz clock has 1ns period --> no conversion required
> */
> - uint64_t final_tsc = rdtsc();
> + uint64_t start_tsc = rdtsc();
> + uint64_t ticks;
>
> - final_tsc += ((get_tbclk_mhz() * ns) / 1000);
> -
> - while (rdtsc() < final_tsc)
> - ;
> + ticks = (tsc_rate_mhz() * ns) / 1000;
> + while (rdtsc() - start_tsc < ticks);
I would rather preserve existing style.
> }
> /* Delay number of microseconds */
> -void delay_u(uint32_t ms)
> +void delay_u(uint32_t us)
> {
> /* 64-bit math is not an option, just use loops */
> - while (ms--)
> + while (us--)
> delay_n(1000);
> }
This is a separate change.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2018-04-20 12:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 22:11 [U-Boot] [PATCH v6 0/2] timer: Add High Precision Event Timers (HPET) support Ivan Gorinov
2018-04-12 22:12 ` [U-Boot] [PATCH v6 1/2] x86: Add TSC-specific timer functions Ivan Gorinov
2018-04-20 12:25 ` Andy Shevchenko [this message]
2018-04-20 18:00 ` Ivan Gorinov
2018-04-23 8:22 ` Andy Shevchenko
2018-04-23 7:38 ` Bin Meng
2018-04-23 7:53 ` Bin Meng
2018-04-23 23:56 ` Ivan Gorinov
2018-04-24 8:41 ` Bin Meng
2018-04-26 3:42 ` Bin Meng
2018-04-30 23:13 ` Simon Glass
2018-04-12 22:12 ` [U-Boot] [PATCH v6 2/2] timer: Add High Precision Event Timers (HPET) support Ivan Gorinov
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=1524227108.21176.462.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.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.