All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] clock: Get rid of clock_get_ns()
@ 2020-12-08 18:15 Peter Maydell
  2020-12-08 18:15 ` [PATCH 1/4] clock: Introduce clock_ticks_to_ns() Peter Maydell
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Peter Maydell @ 2020-12-08 18:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Damien Hedde, Luc Michel, Aleksandar Rikalo, Philippe Mathieu-Daudé

This patchseries makes some changes to the clock API:
 * Remove clock_get_ns()
 * Add clock_ticks_to_ns() to return number of nanoseconds
   it will take the clock to tick N times
 * clock_display_freq() to return prettily-formatted string
   for showing humans the approximate clock frequency

This is based on discussions we had about these APIs a little while
back.  The core driver here is that the clock objects internally
store the period in units of 2^-32 ns, so both clock_get_ns() and
clock_get_hz() are inherently returning a rounded-off result, which
can be badly inaccurate for fast clocks or if you want to multiply it
by a large tick count.

Ideally I'd like to get rid of clock_get_hz() as well, but
that looks trickier than handling clock_get_ns().

Patch 4 borrows a lot of the concept from one of Philippe's that he
sent out previously.

NB: tested with 'make check' and 'make check-acceptance' only.

thanks
-- PMM

Peter Maydell (4):
  clock: Introduce clock_ticks_to_ns()
  target/mips: Don't use clock_get_ns() in clock period calculation
  clock: Remove clock_get_ns()
  clock: Define and use new clock_display_freq()

 docs/devel/clocks.rst  | 37 +++++++++++++++++++++++++++++++++----
 include/hw/clock.h     | 41 ++++++++++++++++++++++++++++++++++++++---
 hw/core/clock.c        |  6 ++++++
 softmmu/qdev-monitor.c |  6 +++---
 target/mips/cpu.c      |  4 ++--
 5 files changed, 82 insertions(+), 12 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2020-12-11 14:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 18:15 [PATCH 0/4] clock: Get rid of clock_get_ns() Peter Maydell
2020-12-08 18:15 ` [PATCH 1/4] clock: Introduce clock_ticks_to_ns() Peter Maydell
2020-12-08 23:39   ` Richard Henderson
2020-12-09  8:49     ` Luc Michel
2020-12-09 14:11       ` Richard Henderson
2020-12-09 14:26         ` Peter Maydell
2020-12-09 15:05           ` Richard Henderson
2020-12-10 20:47     ` Peter Maydell
2020-12-11  1:36       ` Richard Henderson
2020-12-08 18:15 ` [PATCH 2/4] target/mips: Don't use clock_get_ns() in clock period calculation Peter Maydell
2020-12-08 23:41   ` Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-08 18:15 ` [PATCH 3/4] clock: Remove clock_get_ns() Peter Maydell
2020-12-08 23:43   ` Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-08 18:15 ` [PATCH 4/4] clock: Define and use new clock_display_freq() Peter Maydell
2020-12-08 23:50   ` Richard Henderson
2020-12-09  8:50   ` Luc Michel
2020-12-11 13:50 ` [PATCH 0/4] clock: Get rid of clock_get_ns() Philippe Mathieu-Daudé
2020-12-11 14:01   ` Peter Maydell

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.