Skip to content

clock: Get rid of clock_get_ns()

Peter Maydell qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 6 repliesIn review
  2. v14 patches 15 repliesSuperseded

Changes in v2 from the cover letter

* In patch 1, saturate return value to INT64_MAX (and update docs to explain this and why)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4clock: Introduce clock_ticks_to_ns()docs/devel/clocks.rst include/hw/clock.h+70 -02 replies
2/4target/mips: Don't use clock_get_ns() in clock period calculationtarget/mips/cpu.c+2 -20 replies
3/4clock: Remove clock_get_ns()docs/devel/clocks.rst include/hw/clock.h+13 -100 replies
4/4clock: Define and use new clock_display_freq()docs/devel/clocks.rst hw/core/clock.c include/hw/clock.h +1 more+26 -30 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchRichard HendersonLuc MichelPhilippe Mathieu-Daudé
SeriesR-b T-b R-b
1/4R-b R-b
2/4R-b R-b
3/4R-b R-b
4/4R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/4] clock: Get rid of clock_get_ns()

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.

Changes v1->v2:
* In patch 1, saturate return value to INT64_MAX (and update docs to explain this and why)

Patches 2-4 have been reviewed, only patch 1 needs review.

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  | 51 ++++++++++++++++++++++++++++++++++++----
 include/hw/clock.h     | 53 +++++++++++++++++++++++++++++++++++++++---
 hw/core/clock.c        |  6 +++++
 softmmu/qdev-monitor.c |  6 ++---
 target/mips/cpu.c      |  4 ++--
 5 files changed, 108 insertions(+), 12 deletions(-)
Signature · 1 line
2.20.1