linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/10] clk: add kunit tests and correct rate change bug in the clk core
@ 2025-05-28 23:16 Brian Masney
  2025-05-28 23:16 ` [PATCH v2 01/10] clk: add kernel docs for struct clk_core Brian Masney
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Brian Masney @ 2025-05-28 23:16 UTC (permalink / raw)
  To: Stephen Boyd, Maxime Ripard
  Cc: linux-clk, linux-kernel, Arnd Bergmann, Thomas Gleixner,
	Michael Turquette, Alberto Ruiz, Brian Masney

Here's a series that adds various kunit tests to the clk framework,
documents the members of struct clk_core, and adds a fix that does a
better job of preserving the original clock rate when a sibling clock
changes it's rate, and the shared parent's rate.

These tests are centered around inconsistencies and limitations in the
clock framework that may lead to some clocks unknowingly changing rates
during a rate change of their siblings.

The intent of the clock framework is to keep the siblings clock rate
stable during such an operation:

    clk_set_rate(clk, MY_NEW_RATE);

However, it assumes that the sibling can generate that rate in the first
place. In many situations, it can't, and it leads to numerous bugs and
solutions over the years.

https://lore.kernel.org/lkml/20230825-pll-mipi_keep_rate-v1-0-35bc43570730@oltmanns.dev/
https://lore.kernel.org/linux-kernel/20230807-pll-mipi_set_rate_parent-v6-0-f173239a4b59@oltmanns.dev/
https://lore.kernel.org/all/20241114065759.3341908-1-victor.liu@nxp.com/
https://lore.kernel.org/linux-clk/20241121-ge-ian-debug-imx8-clk-tree-v1-0-0f1b722588fe@bootlin.com/

We intend to fix these issues, but first we need to agree and document
what these shortcomings are. These patches are meant to do that, even
though some will be skipped as they are currently broken.

Special thanks to Maxime Ripard for the guidance and feedback on this
project so far.

Changes in v2:
- Combine my two v1 patch series referenced below into one.
- Patch 1: Newly introduced: clk: add kernel docs for struct clk_core
- Patch 2: Simplfy further and there is no need to call clk_recalc() for
  parts of the tree that didn't request a rate change.
- Patch 5:
  - Enable all of the tests since this particular limitation is
    addressed in the clk core with patch 2.
  - Update the div_div_3 test to ensure the dividers on the clock
    are automatically updated as expected.
- Patch 7: Correct test description of
  clk_rate_change_sibling_test_suite.
- Links to v1:
  clk: preserve original rate when a sibling clk changes it's rate
  https://lore.kernel.org/lkml/20250520192846.9614-1-bmasney@redhat.com/

  v1: clk: test: add tests for inconsistencies and limitations in the framework
  https://lore.kernel.org/lkml/20250407131258.70638-1-bmasney@redhat.com/

Signed-off-by: Brian Masney <bmasney@redhat.com>
---
Brian Masney (10):
      clk: add kernel docs for struct clk_core
      clk: preserve original rate when a sibling clk changes it's rate
      clk: test: introduce a few specific rate constants for mock testing
      clk: test: introduce clk_dummy_div for a mock divider
      clk: test: introduce test suite for sibling rate changes on a divider
      clk: test: introduce clk_dummy_gate for a mock gate
      clk: test: introduce test suite for sibling rate changes on a gate
      clk: test: introduce helper to create a mock mux
      clk: test: introduce test variation for sibling rate changes on a mux
      clk: test: introduce test variation for sibling rate changes on a gate/mux

 drivers/clk/clk.c      |  57 ++++-
 drivers/clk/clk_test.c | 605 ++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 573 insertions(+), 89 deletions(-)
---
base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca
change-id: 20250528-clk-wip-v2-813333ab1059

Best regards,
-- 
Brian Masney <bmasney@redhat.com>


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

end of thread, other threads:[~2025-06-10 16:28 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-28 23:16 [PATCH v2 00/10] clk: add kunit tests and correct rate change bug in the clk core Brian Masney
2025-05-28 23:16 ` [PATCH v2 01/10] clk: add kernel docs for struct clk_core Brian Masney
2025-06-06  9:17   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 02/10] clk: preserve original rate when a sibling clk changes it's rate Brian Masney
2025-06-06  8:55   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 03/10] clk: test: introduce a few specific rate constants for mock testing Brian Masney
2025-06-06  8:56   ` Maxime Ripard
2025-06-06 14:28     ` Brian Masney
2025-06-10 16:28       ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 04/10] clk: test: introduce clk_dummy_div for a mock divider Brian Masney
2025-06-06  9:00   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 05/10] clk: test: introduce test suite for sibling rate changes on a divider Brian Masney
2025-06-10 15:39   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 06/10] clk: test: introduce clk_dummy_gate for a mock gate Brian Masney
2025-06-06  8:13   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 07/10] clk: test: introduce test suite for sibling rate changes on a gate Brian Masney
2025-06-10 16:05   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 08/10] clk: test: introduce helper to create a mock mux Brian Masney
2025-06-10 16:20   ` Maxime Ripard
2025-05-28 23:16 ` [PATCH v2 09/10] clk: test: introduce test variation for sibling rate changes on a mux Brian Masney
2025-05-28 23:16 ` [PATCH v2 10/10] clk: test: introduce test variation for sibling rate changes on a gate/mux Brian Masney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).