From: Brian Masney <bmasney@redhat.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>,
Thomas Gleixner <tglx@linutronix.de>,
Michael Turquette <mturquette@baylibre.com>,
Alberto Ruiz <aruiz@redhat.com>
Subject: Re: [PATCH v2 03/10] clk: test: introduce a few specific rate constants for mock testing
Date: Fri, 6 Jun 2025 10:28:19 -0400 [thread overview]
Message-ID: <aEL7A_YeC8b4Wj48@x1> (raw)
In-Reply-To: <20250606-fabulous-fortunate-chamois-ab4c98@houat>
On Fri, Jun 06, 2025 at 10:56:57AM +0200, Maxime Ripard wrote:
> On Wed, May 28, 2025 at 07:16:49PM -0400, Brian Masney wrote:
> > Some of the mock tests care about the relationship between two
> > different rates, and the specific numbers are important, such as for
> > mocking a divider.
> >
> > Signed-off-by: Brian Masney <bmasney@redhat.com>
>
> It's not obvious to me why they are important, actually. The relation
> between the two is, but a divider (and our tests) should work with any
> parent rate, so I guess we can expect it to be opaque.
I agree as well.
> Can you expand on why it's important?
I personally find that having specific numbers in some (but not) of the
tests make the tests clearer that specific functionality within the clk
core is exercised. For example, assume we have a parent that can do any
rate, and two children that are dividers. We could have a test like the
following:
clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_1);
clk_set_rate(ctx->child2_clk, DUMMY_CLOCK_RATE_2);
KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_1);
KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_2);
/*
* Make something to figure out what the ideal parent rate should be
* and test that as well?
*/
So if we set child1 and child2 to 16 MHz and 32 MHz, then that exercises
one path through the clk core. However, it will currently fail if we set
the children to 32 MHz and 48 MHz. I have this working on a WIP branch
and one of my new tests looks similar to:
clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_32_MHZ);
clk_set_rate(ctx->child2_clk, DUMMY_CLOCK_RATE_48_MHZ);
// This should test that it's a multiple of 96 MHz
KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_96_MHZ);
KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_32_MHZ);
KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_48_MHZ);
Based on the work in my WIP branch, I think we need to make some of the
divider only clk tests parameterized, and have a table with various
specific frequencies so that various edge cases within the clk core are
tested by the frequency combinations.
I think that instead of having a list of DUMMY_CLOCK_RATE_XXX_MHZ
defines, a single define like this will suffice:
#define clk_dummy_rate_mhz(rate) ((rate) * 1000 * 1000)
Brian
next prev parent reply other threads:[~2025-06-06 14:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=aEL7A_YeC8b4Wj48@x1 \
--to=bmasney@redhat.com \
--cc=arnd@arndb.de \
--cc=aruiz@redhat.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/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