mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@kernel.org>
To: Brian Masney <bmasney@redhat.com>
Cc: Michael Turquette <mturquette@baylibre.com>,
	 Stephen Boyd <sboyd@kernel.org>, Alberto Ruiz <aruiz@redhat.com>,
	linux-clk@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 7/7] clk: test: introduce additional test case showing v2 rate change + LCM parent
Date: Thu, 19 Mar 2026 10:43:20 +0100	[thread overview]
Message-ID: <20260319-mellow-cautious-bandicoot-01de99@houat> (raw)
In-Reply-To: <20260313-clk-scaling-v6-7-ce89968c5247@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4058 bytes --]

On Fri, Mar 13, 2026 at 12:43:14PM -0400, Brian Masney wrote:
> Add a test case that uses the clk divider with the v2 rate negotiation
> logic, plus the Lowest Common Multiple (LCM) to calculate the optimal
> parent rate. The test ensures that the parent clk rate is set to a rate
> that's acceptable to both children, and the sibling clock is not
> affected.
> 
> The test in this commit use the following simplified clk tree with
> the initial state:
> 
>                      parent
>                      24 MHz
>                     /      \
>               child1        child2
>               24 MHz        24 MHz
> 
> child1 and child2 both divider-only clocks that have CLK_SET_RATE_PARENT
> set, and the parent is capable of achieving any rate.
> 
> child1 requests 32 MHz, and the tree ends up with the correct state:
> 
>                      parent
>                      96 MHz
>                     /      \
>               child1        child2
>               32 MHz        24 MHz
>               div=3          div=4
> 
> Additionally, add a note about why clk_dummy_div_lcm_ops + friends are
> still needed.
> 
> Link: https://lore.kernel.org/linux-clk/aUSWU7UymULCXOeF@redhat.com/
> Link: https://lpc.events/event/19/contributions/2152/
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
>  drivers/clk/clk_test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
> index 40bc01a0259d8d49ca4c1983b6c10a3684a95f0b..00511afe5faa8b2631633ab796ece1bfe6944fb5 100644
> --- a/drivers/clk/clk_test.c
> +++ b/drivers/clk/clk_test.c
> @@ -181,6 +181,14 @@ static const struct clk_ops clk_dummy_div_ops = {
>  	.set_rate = clk_dummy_div_set_rate,
>  };
>  
> +/*
> + * drivers/clk/clk-divider.c has support for v2 rate negotiation, and setting
> + * the parent based on the LCM, however we need to be able to test just setting
> + * the parent rate based on the LCM, and not set the v2 rate negotiation flag.
> + * This is to demonstrate existing functionality in the clk core, and ensure it
> + * stays the same. That's why we need to keep clk_dummy_div_lcm_ops, and can't
> + * just use clk_dummy_div_ops.
> + */
>  static int clk_dummy_div_lcm_determine_rate(struct clk_hw *hw,
>  					    struct clk_rate_request *req)
>  {
> @@ -709,6 +717,18 @@ clk_rate_change_sibling_div_div_test_lcm_ops_v1_params[] = {
>  KUNIT_ARRAY_PARAM_DESC(clk_rate_change_sibling_div_div_test_lcm_ops_v1,
>  		       clk_rate_change_sibling_div_div_test_lcm_ops_v1_params, desc)
>  
> +static const struct clk_rate_change_sibling_div_div_test_param
> +clk_rate_change_sibling_div_div_test_regular_ops_v2_params[] = {
> +	{
> +		.desc = "regular_ops_v2",
> +		.ops = &clk_dummy_div_ops,
> +		.extra_child_flags = CLK_V2_RATE_NEGOTIATION,
> +	},
> +};
> +
> +KUNIT_ARRAY_PARAM_DESC(clk_rate_change_sibling_div_div_test_regular_ops_v2,
> +		       clk_rate_change_sibling_div_div_test_regular_ops_v2_params, desc)
> +
>  static int clk_rate_change_sibling_div_div_test_init(struct kunit *test)
>  {
>  	const struct clk_rate_change_sibling_div_div_test_param *param = test->param_value;
> @@ -836,6 +856,31 @@ static void clk_test_rate_change_sibling_div_div_3_v1(struct kunit *test)
>  	KUNIT_EXPECT_EQ(test, ctx->child2.div, 1);
>  }
>  
> +/*
> + * Test that, for a parent with two divider-only children with CLK_SET_RATE_PARENT
> + * set and one requests a rate incompatible with the existing parent rate, the
> + * sibling rate is not affected, and maintains it's rate.
> + */

I assume that's only true if the v2 negociation is enabled?

> +static void clk_test_rate_change_sibling_div_div_4_v2(struct kunit *test)
> +{
> +	struct clk_rate_change_sibling_div_div_context *ctx = test->priv;
> +	int ret;
> +
> +	ret = clk_set_rate(ctx->child1_clk, 32 * HZ_PER_MHZ);
> +	KUNIT_ASSERT_EQ(test, ret, 0);

If so, we should have an assertion here

Maxime
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

  reply	other threads:[~2026-03-19  9:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 16:43 [PATCH v6 0/7] clk: add support for v1 / v2 clock rate negotiation and kunit tests Brian Masney
2026-03-13 16:43 ` [PATCH v6 1/7] clk: test: introduce clk_dummy_div for a mock divider Brian Masney
2026-03-16 12:09   ` Maxime Ripard
2026-03-13 16:43 ` [PATCH v6 2/7] clk: test: introduce test suite for sibling rate changes on a divider Brian Masney
2026-03-19  9:10   ` Maxime Ripard
2026-03-19 11:08     ` Brian Masney
2026-03-20 13:03       ` Maxime Ripard
2026-03-20 13:08         ` Brian Masney
2026-03-20 14:29           ` Maxime Ripard
2026-03-20 14:34             ` Brian Masney
2026-03-13 16:43 ` [PATCH v6 3/7] clk: introduce new helper clk_hw_get_children_lcm() to calculate LCM of all child rates Brian Masney
2026-03-19  9:16   ` Maxime Ripard
2026-03-13 16:43 ` [PATCH v6 4/7] clk: test: introduce additional test case showing sibling clock rate change Brian Masney
2026-03-19  9:22   ` Maxime Ripard
2026-03-19 15:14     ` Brian Masney
2026-03-13 16:43 ` [PATCH v6 5/7] clk: introduce new flag CLK_V2_RATE_NEGOTIATION for sensitive clocks Brian Masney
2026-03-19  9:35   ` Maxime Ripard
2026-03-19 10:35     ` Brian Masney
2026-03-20 14:31       ` Maxime Ripard
2026-03-20 14:33         ` Maxime Ripard
2026-03-20 14:44           ` Brian Masney
2026-03-13 16:43 ` [PATCH v6 6/7] clk: divider: enable optional support for v2 rate negotiation Brian Masney
2026-03-19  9:36   ` Maxime Ripard
2026-03-13 16:43 ` [PATCH v6 7/7] clk: test: introduce additional test case showing v2 rate change + LCM parent Brian Masney
2026-03-19  9:43   ` Maxime Ripard [this message]
2026-03-19 11:09     ` Brian Masney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260319-mellow-cautious-bandicoot-01de99@houat \
    --to=mripard@kernel.org \
    --cc=aruiz@redhat.com \
    --cc=bmasney@redhat.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®