From: Ivan Gorinov <ivan.gorinov@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 11:00:47 -0700 [thread overview]
Message-ID: <20180420180047.GB2940@intel.com> (raw)
In-Reply-To: <1524227108.21176.462.camel@linux.intel.com>
On Fri, Apr 20, 2018 at 06:25:08AM -0600, Andy Shevchenko 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.
OK. Existing style does not correctly handle overflow,
but for a 64-bit counter it's a very unlikely event.
next prev parent reply other threads:[~2018-04-20 18:00 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
2018-04-20 18:00 ` Ivan Gorinov [this message]
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=20180420180047.GB2940@intel.com \
--to=ivan.gorinov@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox