All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vesa Jääskeläinen" <chaac@nic.fi>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [RFC] High resolution time support using x86 TSC
Date: Fri, 04 Jul 2008 19:10:00 +0300	[thread overview]
Message-ID: <486E4B58.60306@nic.fi> (raw)
In-Reply-To: <20080704085831.4bfa826b@gibibit.com>

Colin D Bennett wrote:
> On Thu, 03 Jul 2008 20:52:53 +0200
> Marco Gerards <mgerards@xs4all.nl> wrote:
> 
>> Hi Colin,
>>
>> Colin D Bennett <colin@gibibit.com> writes:
>>
>>> +	* kern/i386/linuxbios/init.c (grub_get_time_ms):
>>> +	Define grub_get_time_ms() to always return 0.  This should
>>> be fixed
>>> +	when RTC functionality is implemented.
>>> +	(grub_time_init): Define this required function as a
>>> no-op. Inserted
>>> +	a comment to remind us delete this function when proper
>>> time support 
>>> +	is added to i386-linuxbios.
>>> +
>>> +	* kern/main.c (grub_main): Call grub_time_init() right
>>> after
>>> +	grub_machine_init().
>> I think this should go into grub_machine_init?  Why didn't you just
>> add it there?
> 
> Originally, I had grub_machine_init() call grub_tsc_calibrate(), but
> these are comments Vesa made to me about that code:
> 
> Vesa Jääskeläinen <dachaac@gmail.com> wrote
> on Mon, 16 Jun 2008 20:34:54 +0300:
> 
>> Colin D Bennett wrote:
>>> This week I implemented high resolution timer support using the x86
>>> TSC (see attached patch <grub_tsc_2008-06-10.patch>).  It is
>>> calibrated at GRUB startup using the RTC as a reference. The core
>>> TSC function is ``grub_get_tsc()`` -- corresponding to
>>> ``grub_get_rtc()``, but returning a uint64 value representing the
>>> number of CPU cycles elapsed since boot.
>>>
>>> In most situations, you will want to use ``grub_get_time_ms()`` to
>>> get the system time in milliseconds based on the TSC value.  The
>>> calibration function ``grub_tsc_calibrate()``, calculates the
>>> proper scale factor and absolute offset so that the millisecond
>>> value represents real time.
>>>
>>> The ``grub_get_time_ms()`` function is implemented for non-x86
>>> platforms to simply call ``grub_get_time_ms_generic()`` (defined in
>>> kern/misc.c), which uses the RTC to get the time in milliseconds.  
>> We would probably want to leave that generic out from kernel, and let 
>> every platform either use this generic code or implement their own 
>> mechanism to do the job. Perhaps we should make own folder for
>> generic stuff that can be included for arch specific build if there
>> is no better replacement.
>>
>> How about calling function like grub_time_init() which would then be 
>> platform specific? Then platform can implement whatever way to
>> calibrate (if needed) as long as it provides this grub_get_time_ms()
>> function (also being platform specific). This would make
>> initialization non-specific to arch while leaving more room for
>> implementation.
> 
> Therefore, I thought this was the right way to do it.  Do you want me
> to instead call grub_time_init() from grub_machine_init()?

Hi Colin,

That is Ok.

My comment was more of calling directly tsc_calibrate which is not 
generic function at all. You can call grub_time_init() and in there you 
decide that you use tsc (and then call tsc_calibrate) or something else 
depending what is available. This way time handling stuff can be reside 
easily on one module and it is easy to provide generic function to other 
platforms.

Thanks,
Vesa Jääskeläinen



  reply	other threads:[~2008-07-04 16:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-23 14:54 [RFC] High resolution time support using x86 TSC Colin D Bennett
2008-07-03 18:52 ` Marco Gerards
2008-07-04 15:58   ` Colin D Bennett
2008-07-04 16:10     ` Vesa Jääskeläinen [this message]
2008-07-04 17:26   ` Colin D Bennett
2008-07-20 18:21     ` Marco Gerards
2008-07-04 18:28   ` [RFC] TSC patch v2 Colin D Bennett
2008-07-04 19:49     ` Vesa Jääskeläinen
2008-07-04 20:38       ` Colin D Bennett
2008-07-04 20:48         ` Vesa Jääskeläinen
2008-07-20 18:45     ` Marco Gerards
2008-07-28 17:05       ` [PATCH] High resolution time/TSC patch v3 Colin D Bennett
2008-07-28 17:59         ` Robert Millan
2008-07-31 19:08         ` Marco Gerards
2008-07-31 19:24           ` Robert Millan
2008-07-31 20:07             ` Marco Gerards
2008-07-31 20:35               ` Robert Millan
2008-08-03 19:48         ` Robert Millan
2008-08-03 23:53           ` TSC on coreboot (Re: [PATCH] High resolution time/TSC patch v3) Robert Millan
2008-08-04  2:14             ` Colin D Bennett
2008-08-04  9:09               ` Robert Millan
2008-08-04 20:21             ` Marco Gerards
2008-08-05 11:59         ` [PATCH] High resolution time/TSC patch v3 Marco Gerards
2008-08-05 20:24           ` Robert Millan

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=486E4B58.60306@nic.fi \
    --to=chaac@nic.fi \
    --cc=grub-devel@gnu.org \
    /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.