* How to read time stamp from HPET timer from device driver?
@ 2010-07-13 9:36 Samuel Xu
2010-07-13 9:39 ` Samuel Xu
0 siblings, 1 reply; 6+ messages in thread
From: Samuel Xu @ 2010-07-13 9:36 UTC (permalink / raw)
To: platform-driver-x86
HI:
I am a freshman for HPET timer. Previously, I use TSC counter, to use
rdtsc to get the time stamp. elapsed cycle can be counter from 2 time
stamps.
As a advanced replacement of TSC, I suppose HPET timer can be
conveniently to read time stamp from both kernel mode user and user
mode apps.
While I failed to find a way to get time stamp value of HPET in Linux
kenerl (I am doing a driver and want to know elapsed cycle from driver
code).
Anyone can help me?
Thanks!
Samuel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to read time stamp from HPET timer from device driver?
2010-07-13 9:36 How to read time stamp from HPET timer from device driver? Samuel Xu
@ 2010-07-13 9:39 ` Samuel Xu
2010-07-13 13:08 ` Thadeu Lima de Souza Cascardo
0 siblings, 1 reply; 6+ messages in thread
From: Samuel Xu @ 2010-07-13 9:39 UTC (permalink / raw)
To: platform-driver-x86
I tried hpet_readl() from my driver code, while hit compiling error.
is it a correct API for kernel driver to invoke? any more hint?
2010/7/13 Samuel Xu <samuel.xu.tech@gmail.com>:
> HI:
> I am a freshman for HPET timer. Previously, I use TSC counter, to use
> rdtsc to get the time stamp. elapsed cycle can be counter from 2 time
> stamps.
> As a advanced replacement of TSC, I suppose HPET timer can be
> conveniently to read time stamp from both kernel mode user and user
> mode apps.
> While I failed to find a way to get time stamp value of HPET in Linux
> kenerl (I am doing a driver and want to know elapsed cycle from driver
> code).
>
> Anyone can help me?
>
> Thanks!
>
> Samuel
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to read time stamp from HPET timer from device driver?
2010-07-13 9:39 ` Samuel Xu
@ 2010-07-13 13:08 ` Thadeu Lima de Souza Cascardo
2010-07-13 13:34 ` Samuel Xu
0 siblings, 1 reply; 6+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-07-13 13:08 UTC (permalink / raw)
To: Samuel Xu; +Cc: platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]
On Tue, Jul 13, 2010 at 05:39:11PM +0800, Samuel Xu wrote:
> I tried hpet_readl() from my driver code, while hit compiling error.
> is it a correct API for kernel driver to invoke? any more hint?
>
What are you trying to do exactly? Using TSC or HPET is not
platform-independent. You may take a look at hrtimers.
Regards,
Cascardo.
> 2010/7/13 Samuel Xu <samuel.xu.tech@gmail.com>:
> > HI:
> > I am a freshman for HPET timer. Previously, I use TSC counter, to use
> > rdtsc to get the time stamp. elapsed cycle can be counter from 2 time
> > stamps.
> > As a advanced replacement of TSC, I suppose HPET timer can be
> > conveniently to read time stamp from both kernel mode user and user
> > mode apps.
> > While I failed to find a way to get time stamp value of HPET in Linux
> > kenerl (I am doing a driver and want to know elapsed cycle from driver
> > code).
> >
> > Anyone can help me?
> >
> > Thanks!
> >
> > Samuel
> >
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to read time stamp from HPET timer from device driver?
2010-07-13 13:08 ` Thadeu Lima de Souza Cascardo
@ 2010-07-13 13:34 ` Samuel Xu
2010-07-13 14:03 ` Thadeu Lima de Souza Cascardo
2010-07-15 16:39 ` Thomas Renninger
0 siblings, 2 replies; 6+ messages in thread
From: Samuel Xu @ 2010-07-13 13:34 UTC (permalink / raw)
To: Thadeu Lima de Souza Cascardo; +Cc: platform-driver-x86
Hi, Cascardo:
Thanks for reply! I just want to get the guide on some sample code of
HPET usage invoked from kernel mode driver.
Any directly guide?
Thanks!
2010/7/13 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>:
> On Tue, Jul 13, 2010 at 05:39:11PM +0800, Samuel Xu wrote:
>> I tried hpet_readl() from my driver code, while hit compiling error.
>> is it a correct API for kernel driver to invoke? any more hint?
>>
>
> What are you trying to do exactly? Using TSC or HPET is not
> platform-independent. You may take a look at hrtimers.
>
> Regards,
> Cascardo.
>
>> 2010/7/13 Samuel Xu <samuel.xu.tech@gmail.com>:
>> > HI:
>> > I am a freshman for HPET timer. Previously, I use TSC counter, to use
>> > rdtsc to get the time stamp. elapsed cycle can be counter from 2 time
>> > stamps.
>> > As a advanced replacement of TSC, I suppose HPET timer can be
>> > conveniently to read time stamp from both kernel mode user and user
>> > mode apps.
>> > While I failed to find a way to get time stamp value of HPET in Linux
>> > kenerl (I am doing a driver and want to know elapsed cycle from driver
>> > code).
>> >
>> > Anyone can help me?
>> >
>> > Thanks!
>> >
>> > Samuel
>> >
>> --
>> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQIcBAEBAgAGBQJMPGVTAAoJEEWxSg7udFZIZHoQAKj0xOvvtE5pEZqau1OnFz1t
> q15VC2q/OYQRRjAT5kRFEfWk7NcCaJmw4Y0TdrOjEW9YpYnZARksH2UwFA8myf9g
> WOUpRe0o3HcuiutlxB321bI7mpJLHAaxpFwB8/10iXGjrH0LUQeOWkNo5smd9RQK
> 1WfQ6BVEOqeyfY9ISnwzqhZQMu3AG0DbqnZQe6QtvE4Epg4L8ZeROL1piJqLGtlv
> IGQ4fn+Pdu9+VXpmVl4Uzc/bLF1j2HTTKwwHO0KHTYZty40K8NnbCPJJp00KTfnN
> TYVdEEgWzvIrJmB7hlrdl5gmjs9KYmOe3lpkRdotCzca9VNxFLvyi6ogkE/qiLpY
> Au8wts22+qikxAkHdDfFdlnYAiiguGCJvku2usCtkEbTxsYWHKp/maP8xcNDE52H
> HHwKmkKuYA/m+ML7kKmE7goDHjFvG0SZcm8Gjj4ghxbobhzQ6XGxzsGpJ9GwYz/E
> JqAiqob3lD8TljWXPGN839pi0KHBivH71p9UoCC856G3GL4nXahsBSwMMg3KWj5i
> avvQSCR838LK7qesKYak3xgjmLl9vRWVQwbx1vIlgjpOsBnmhUttUOKFy1eb4THz
> EX080354M5mVfXsoiDVqUy3W5PwL1Yna9AaMVk+05lKg6OR/b0cMC6PFocGkgxRM
> Okd0gXuUGv5IIy38UGSO
> =BMoU
> -----END PGP SIGNATURE-----
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to read time stamp from HPET timer from device driver?
2010-07-13 13:34 ` Samuel Xu
@ 2010-07-13 14:03 ` Thadeu Lima de Souza Cascardo
2010-07-15 16:39 ` Thomas Renninger
1 sibling, 0 replies; 6+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-07-13 14:03 UTC (permalink / raw)
To: Samuel Xu; +Cc: platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 3201 bytes --]
On Tue, Jul 13, 2010 at 09:34:50PM +0800, Samuel Xu wrote:
> Hi, Cascardo:
> Thanks for reply! I just want to get the guide on some sample code of
> HPET usage invoked from kernel mode driver.
> Any directly guide?
> Thanks!
>
You asked if this is the right API. And the answer depends on what do
you want to use it for.
Do you want to count CPU cycles for the purpose of performance analysis?
Take a look at perf!
Do you need to keep track of time to communicate with some
soft-real-time device (like audio devices)? Use hrtimers.
Do you want a piece of software that only works on PCs that have HPET
device available without any given reason? I can't help you more than
pointing you to Documentation/timers/hpet.txt, which does not point to
an API. So you are better off reading source code. hpet_readl is not
exported. Try 'grep EXPORT arch/x86/kernel/hpet.c'.
Regards,
Cascardo.
> 2010/7/13 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>:
> > On Tue, Jul 13, 2010 at 05:39:11PM +0800, Samuel Xu wrote:
> >> I tried hpet_readl() from my driver code, while hit compiling error.
> >> is it a correct API for kernel driver to invoke? any more hint?
> >>
> >
> > What are you trying to do exactly? Using TSC or HPET is not
> > platform-independent. You may take a look at hrtimers.
> >
> > Regards,
> > Cascardo.
> >
> >> 2010/7/13 Samuel Xu <samuel.xu.tech@gmail.com>:
> >> > HI:
> >> > I am a freshman for HPET timer. Previously, I use TSC counter, to use
> >> > rdtsc to get the time stamp. elapsed cycle can be counter from 2 time
> >> > stamps.
> >> > As a advanced replacement of TSC, I suppose HPET timer can be
> >> > conveniently to read time stamp from both kernel mode user and user
> >> > mode apps.
> >> > While I failed to find a way to get time stamp value of HPET in Linux
> >> > kenerl (I am doing a driver and want to know elapsed cycle from driver
> >> > code).
> >> >
> >> > Anyone can help me?
> >> >
> >> > Thanks!
> >> >
> >> > Samuel
> >> >
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> >
> > iQIcBAEBAgAGBQJMPGVTAAoJEEWxSg7udFZIZHoQAKj0xOvvtE5pEZqau1OnFz1t
> > q15VC2q/OYQRRjAT5kRFEfWk7NcCaJmw4Y0TdrOjEW9YpYnZARksH2UwFA8myf9g
> > WOUpRe0o3HcuiutlxB321bI7mpJLHAaxpFwB8/10iXGjrH0LUQeOWkNo5smd9RQK
> > 1WfQ6BVEOqeyfY9ISnwzqhZQMu3AG0DbqnZQe6QtvE4Epg4L8ZeROL1piJqLGtlv
> > IGQ4fn+Pdu9+VXpmVl4Uzc/bLF1j2HTTKwwHO0KHTYZty40K8NnbCPJJp00KTfnN
> > TYVdEEgWzvIrJmB7hlrdl5gmjs9KYmOe3lpkRdotCzca9VNxFLvyi6ogkE/qiLpY
> > Au8wts22+qikxAkHdDfFdlnYAiiguGCJvku2usCtkEbTxsYWHKp/maP8xcNDE52H
> > HHwKmkKuYA/m+ML7kKmE7goDHjFvG0SZcm8Gjj4ghxbobhzQ6XGxzsGpJ9GwYz/E
> > JqAiqob3lD8TljWXPGN839pi0KHBivH71p9UoCC856G3GL4nXahsBSwMMg3KWj5i
> > avvQSCR838LK7qesKYak3xgjmLl9vRWVQwbx1vIlgjpOsBnmhUttUOKFy1eb4THz
> > EX080354M5mVfXsoiDVqUy3W5PwL1Yna9AaMVk+05lKg6OR/b0cMC6PFocGkgxRM
> > Okd0gXuUGv5IIy38UGSO
> > =BMoU
> > -----END PGP SIGNATURE-----
> >
> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to read time stamp from HPET timer from device driver?
2010-07-13 13:34 ` Samuel Xu
2010-07-13 14:03 ` Thadeu Lima de Souza Cascardo
@ 2010-07-15 16:39 ` Thomas Renninger
1 sibling, 0 replies; 6+ messages in thread
From: Thomas Renninger @ 2010-07-15 16:39 UTC (permalink / raw)
To: Samuel Xu; +Cc: Thadeu Lima de Souza Cascardo, platform-driver-x86
On Tuesday 13 July 2010 03:34:50 pm Samuel Xu wrote:
> Hi, Cascardo:
> Thanks for reply! I just want to get the guide on some sample code of
> HPET usage invoked from kernel mode driver.
You must not use hpet directly to keep track of the time.
There is HW which does not have an hpet, or the kernel may choose a better
(faster, eventually broken hpet timers workarounds, whatever...)
time source to retrieve the time.
> Any directly guide?
Have a look at: include/linux/time.h
An example making a bit use of it is:
drivers/cpufreq/cpufreq_ondemand.c
grepping for time shows some examples.
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-15 16:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-13 9:36 How to read time stamp from HPET timer from device driver? Samuel Xu
2010-07-13 9:39 ` Samuel Xu
2010-07-13 13:08 ` Thadeu Lima de Souza Cascardo
2010-07-13 13:34 ` Samuel Xu
2010-07-13 14:03 ` Thadeu Lima de Souza Cascardo
2010-07-15 16:39 ` Thomas Renninger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox