clk: Improve clock range handling
Status from this message: Applied to drm/drm-misc (drm-misc-next).
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest12 patches 9 repliesApplied
- v612 patches 16 repliesSuperseded
- v511 patches 0 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v4 | 10 patches | 20 replies | Superseded | |
| v3 | 10 patches | 5 replies | Superseded |
Changes in v7 from the cover letter
- Removed unused header
- Used more fitting KUNIT macros
- Enhanced some comments
- Reworded a commit message
Patches in v7 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/12 | clk: Fix clk_hw_get_clk() when dev is NULLdrivers/ | +2 | 0 replies | |
| 2/12 | clk: Introduce Kunit Tests for the frameworkdrivers/ drivers/ drivers/ +1 more | +796 | 0 replies | |
| 3/12 | clk: Enforce that disjoints limits are invaliddrivers/ | +24 | 0 replies | |
| 4/12 | clk: Always clamp the rounded ratedrivers/ drivers/ | +34 | 0 replies | |
| 5/12 | clk: Use clamp instead of open-coding our owndrivers/ | +1 | 0 replies | |
| 6/12 | clk: Always set the rate on clk_set_range_ratedrivers/ drivers/ | +49 | 4 replies | |
| 7/12 | clk: Add clk_drop_rangedrivers/ include/ | +13 | 0 replies | |
| 8/12 | clk: bcm: rpi: Add variant structuredrivers/ | +46 | 0 replies | |
| 9/12 | clk: bcm: rpi: Set a default minimum ratedrivers/ | +26 | 0 replies | |
| 10/12 | clk: bcm: rpi: Run some clocks at the minimum rate alloweddrivers/ | +37 | 0 replies | |
| 11/12 | drm/vc4: Add logging and commentsdrivers/ | +11 | 1 reply | |
| 12/12 | drm/vc4: hdmi: Remove clock rate initializationdrivers/ | +0 | 1 reply |
Reviews trailers per patch
2 of 12 patches have a Reviewed-by or Acked-by.
| Patch | Daniel Latypov | Dmitry Osipenko | Thomas Zimmermann |
|---|---|---|---|
| 1/12 | |||
| 2/12 | T-b | ||
| 3/12 | |||
| 4/12 | |||
| 5/12 | |||
| 6/12 | T-b | ||
| 7/12 | |||
| 8/12 | |||
| 9/12 | |||
| 10/12 | |||
| 11/12 | A-b | ||
| 12/12 | A-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.
Cover letter [PATCH v7 00/12] clk: Improve clock range handling
Hi,
This is a follow-up of the discussion here:
https://lore.kernel.org/linux-clk/20210319150355.xzw7ikwdaga2dwhv@gilmour/
and here:
https://lore.kernel.org/all/[email protected]/
While the initial proposal implemented a new API to temporarily raise and lower clock rates based on consumer workloads, Stephen suggested an alternative approach implemented here.
The main issue that needed to be addressed in our case was that in a situation where we would have multiple calls to clk_set_rate_range, we would end up with a clock at the maximum of the minimums being set. This would be expected, but the issue was that if one of the users was to relax or drop its requirements, the rate would be left unchanged, even though the ideal rate would have changed.
So something like
clk_set_rate(user1_clk, 1000);clk_set_min_rate(user1_clk, 2000);clk_set_min_rate(user2_clk, 3000);clk_set_min_rate(user2_clk, 1000);
Would leave the clock running at 3000Hz, while the minimum would now be 2000Hz.
This was mostly due to the fact that the core only triggers a rate change in clk_set_rate_range() if the current rate is outside of the boundaries, but not if it's within the new boundaries.
That series changes that and will trigger a rate change on every call, with the former rate being tried again. This way, providers have a chance to follow whatever policy they see fit for a given clock each time the boundaries change.
This series also implements some kunit tests, first to test a few rate related functions in the CCF, and then extends it to make sure that behaviour has some test coverage.
Let me know what you think
Maxime
Changes from v6:
- Removed unused header
- Used more fitting KUNIT macros
- Enhanced some comments
- Reworded a commit message
Changes from v5:
- Changed clk_hw_create_clk for clk_hw_get_clk since the former isn't exported to modules.
- Added fix for clk_hw_get_clk
Changes from v4:
- Rename the test file
- Move all the tests to the first patch, and fix them up as fixes are done
- Improved the test conditions
- Added more tests
- Improved commit messages
- Fixed a regression where two disjoints clock ranges would now be accepted
Changes from v3:
- Renamed the test file and Kconfig option
- Add option to .kunitconfig
- Switch to kunit_kzalloc
- Use KUNIT_EXPECT_* instead of KUNIT_ASSERT_* where relevant
- Test directly relevant calls instead of going through a temporary variable
- Switch to more precise KUNIT_ASSERT_* macros where relevant
Changes from v2:
- Rebased on current next
- Rewrote the whole thing according to Stephen reviews
- Implemented some kunit tests
Changes from v1:
- Return NULL in clk_request_start if clk pointer is NULL
- Test for clk_req pointer in clk_request_done
- Add another user in vc4
- Rebased on top of v5.15-rc1
Maxime Ripard (12):
clk: Fix clk_hw_get_clk() when dev is NULL
clk: Introduce Kunit Tests for the framework
clk: Enforce that disjoints limits are invalid
clk: Always clamp the rounded rate
clk: Use clamp instead of open-coding our own
clk: Always set the rate on clk_set_range_rate
clk: Add clk_drop_range
clk: bcm: rpi: Add variant structure
clk: bcm: rpi: Set a default minimum rate
clk: bcm: rpi: Run some clocks at the minimum rate allowed drm/vc4: Add logging and comments
drm/vc4: hdmi: Remove clock rate initialization
drivers/clk/.kunitconfig | 1 + drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/bcm/clk-raspberrypi.c | 125 ++++- drivers/clk/clk.c | 76 ++- drivers/clk/clk_test.c | 795 ++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.c | 13 - drivers/gpu/drm/vc4/vc4_kms.c | 11 + include/linux/clk.h | 11 + 9 files changed, 985 insertions(+), 55 deletions(-) create mode 100644 drivers/clk/clk_test.c
Signature · 1 line
2.35.1