From: Stephen Boyd <sboyd@kernel.org>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
Brian Masney <bmasney@redhat.com>,
Conor Dooley <conor+dt@kernel.org>,
Cristian Marussi <cristian.marussi@arm.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Rob Herring <robh@kernel.org>,
Sebin Francis <sebin.francis@ti.com>,
Sudeep Holla <sudeep.holla@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, arm-scmi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH v9 4/6] clk: Add KUnit tests for assigned-clock-sscs
Date: Tue, 28 Apr 2026 19:38:36 -0700 [thread overview]
Message-ID: <177743031609.5403.8748588339056479001@localhost.localdomain> (raw)
In-Reply-To: <20260312-clk-ssc-v7-1-v9-4-0a9d2e188d9e@nxp.com>
Quoting Peng Fan (OSS) (2026-03-11 23:58:20)
> diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
> index a268d7b5d4cb28ec1f029f828c31107f8e130556..97113b61c2841701a44603ca9935638374000a2e 100644
> --- a/drivers/clk/clk_test.c
> +++ b/drivers/clk/clk_test.c
> @@ -3203,6 +3223,9 @@ static void clk_assigned_rates_assigns_one(struct kunit *test)
> struct clk_assigned_rates_context *ctx = test->priv;
>
> KUNIT_EXPECT_EQ(test, ctx->clk0.rate, ASSIGNED_RATES_0_RATE);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.modfreq_hz, ASSIGNED_SSCS_0_MODFREQ);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.spread_bp, ASSIGNED_SSCS_0_SPREAD);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.method, ASSIGNED_SSCS_0_METHOD);
> }
>
> static void clk_assigned_rates_assigns_multiple(struct kunit *test)
> @@ -3210,7 +3233,13 @@ static void clk_assigned_rates_assigns_multiple(struct kunit *test)
> struct clk_assigned_rates_context *ctx = test->priv;
>
> KUNIT_EXPECT_EQ(test, ctx->clk0.rate, ASSIGNED_RATES_0_RATE);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.modfreq_hz, ASSIGNED_SSCS_0_MODFREQ);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.spread_bp, ASSIGNED_SSCS_0_SPREAD);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.method, ASSIGNED_SSCS_0_METHOD);
> KUNIT_EXPECT_EQ(test, ctx->clk1.rate, ASSIGNED_RATES_1_RATE);
> + KUNIT_EXPECT_EQ(test, ctx->clk1.sscs.modfreq_hz, ASSIGNED_SSCS_1_MODFREQ);
> + KUNIT_EXPECT_EQ(test, ctx->clk1.sscs.spread_bp, ASSIGNED_SSCS_1_SPREAD);
> + KUNIT_EXPECT_EQ(test, ctx->clk1.sscs.method, ASSIGNED_SSCS_1_METHOD);
> }
>
> static void clk_assigned_rates_skips(struct kunit *test)
> @@ -3222,6 +3251,19 @@ static void clk_assigned_rates_skips(struct kunit *test)
> KUNIT_EXPECT_EQ(test, ctx->clk0.rate, test_param->rate0);
> }
>
> +static void clk_assigned_sscs_skips(struct kunit *test)
> +{
> + struct clk_assigned_rates_context *ctx = test->priv;
> + const struct clk_assigned_rates_test_param *test_param = test->param_value;
> +
> + KUNIT_EXPECT_NE(test, ctx->clk0.sscs.modfreq_hz, ASSIGNED_SSCS_0_MODFREQ);
> + KUNIT_EXPECT_NE(test, ctx->clk0.sscs.spread_bp, ASSIGNED_SSCS_0_SPREAD);
> + KUNIT_EXPECT_NE(test, ctx->clk0.sscs.method, ASSIGNED_SSCS_0_METHOD);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.modfreq_hz, test_param->sscs.modfreq_hz);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.spread_bp, test_param->sscs.spread_bp);
> + KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.method, test_param->sscs.method);
> +}
> +
> OF_OVERLAY_DECLARE(kunit_clk_assigned_rates_one);
> OF_OVERLAY_DECLARE(kunit_clk_assigned_rates_one_consumer);
> OF_OVERLAY_DECLARE(kunit_clk_assigned_rates_u64_one);
> @@ -3384,6 +3426,77 @@ KUNIT_ARRAY_PARAM_DESC(clk_assigned_rates_skips,
> clk_assigned_rates_skips_test_params,
> desc)
>
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_without);
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_without_consumer);
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_zero);
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_zero_consumer);
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_null);
> +OF_OVERLAY_DECLARE(kunit_clk_assigned_sscs_null_consumer);
> +
> +/* Test cases that skip changing the sscs due to malformed DT */
> +static const struct clk_assigned_rates_test_param clk_assigned_sscs_skips_test_params[] = {
> + {
> + /*
> + * Test that an assigned-clock-sscs property without an assigned-clocks
> + * property fails when the property is in the provider.
> + */
> + .desc = "provider missing assigned-clocks",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_without),
> + .sscs = {50000, 60000, 3},
> + },
> + {
> + /*
> + * Test that an assigned-clock-rates property without an assigned-clocks
It is?
> + * property fails when the property is in the consumer.
> + */
> + .desc = "consumer missing assigned-clocks",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_without_consumer),
> + .sscs = {50000, 60000, 3},
> + .consumer_test = true,
> + },
> + {
> + /*
> + * Test that an assigned-clock-rates property of zero doesn't
Typo?
> + * set a rate when the property is in the provider.
> + */
> + .desc = "provider assigned-clock-sscs of zero",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_zero),
> + .sscs = {50000, 60000, 3},
> + },
> + {
> + /*
> + * Test that an assigned-clock-rates property of zero doesn't
> + * set a rate when the property is in the consumer.
> + */
> + .desc = "consumer assigned-clock-sscs of zero",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_zero_consumer),
> + .sscs = {50000, 60000, 3},
> + .consumer_test = true,
> + },
> + {
> + /*
> + * Test that an assigned-clocks property with a null phandle
> + * doesn't set a rate when the property is in the provider.
> + */
> + .desc = "provider assigned-clocks null phandle",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_null),
> + .sscs = {50000, 60000, 3},
> + },
> + {
> + /*
> + * Test that an assigned-clocks property with a null phandle
> + * doesn't set a rate when the property is in the consumer.
None of these comments are correct.
> + */
> + .desc = "provider assigned-clocks null phandle",
> + TEST_PARAM_OVERLAY(kunit_clk_assigned_sscs_null_consumer),
> + .sscs = {50000, 60000, 3},
> + .consumer_test = true,
> + },
> +};
> +KUNIT_ARRAY_PARAM_DESC(clk_assigned_sscs_skips,
> + clk_assigned_sscs_skips_test_params,
> + desc)
> +
> static struct kunit_case clk_assigned_rates_test_cases[] = {
> KUNIT_CASE_PARAM(clk_assigned_rates_assigns_one,
> clk_assigned_rates_assigns_one_gen_params),
> @@ -3391,6 +3504,8 @@ static struct kunit_case clk_assigned_rates_test_cases[] = {
> clk_assigned_rates_assigns_multiple_gen_params),
> KUNIT_CASE_PARAM(clk_assigned_rates_skips,
> clk_assigned_rates_skips_gen_params),
> + KUNIT_CASE_PARAM(clk_assigned_sscs_skips,
> + clk_assigned_sscs_skips_gen_params),
> {}
> };
Instead of adding on another case just copy the entire thing,
kunit_case, test_params, etc. and implement the tests you want. Test
code is the opposite of DRY (DAMP?) so don't be afraid to just copy a
bunch of stuff. The reason why that is encouraged is because existing
tests are unchanged, and we don't have to worry that this patch breaks
the existing tests. It also helps the reviewer see the whole picture
because all the test code is in the patch instead of in the context.
For example, clk_assigned_rates_assigns_multiple() is saying that a
clock-assigned-rates property with multiple rates assigns multiple
rates. It's not supposed to be testing ssc. Don't modify it.
next prev parent reply other threads:[~2026-04-29 3:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 6:58 [PATCH v9 0/6] clk: Support spread spectrum and use it in clk-scmi Peng Fan (OSS)
2026-03-12 6:58 ` [PATCH v9 1/6] dt-bindings: clock: Add spread spectrum definition Peng Fan (OSS)
2026-03-12 6:58 ` [PATCH v9 2/6] clk: Introduce clk_hw_set_spread_spectrum Peng Fan (OSS)
2026-03-12 6:58 ` [PATCH v9 3/6] clk: conf: Support assigned-clock-sscs Peng Fan (OSS)
2026-03-12 6:58 ` [PATCH v9 4/6] clk: Add KUnit tests for assigned-clock-sscs Peng Fan (OSS)
2026-04-29 2:38 ` Stephen Boyd [this message]
2026-03-12 6:58 ` [PATCH v9 5/6] clk: scmi: Introduce common header for SCMI clock interface Peng Fan (OSS)
2026-03-12 6:58 ` [PATCH v9 6/6] clk: scmi: Add i.MX95 OEM extension support for SCMI clock driver Peng Fan (OSS)
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=177743031609.5403.8748588339056479001@localhost.localdomain \
--to=sboyd@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=bmasney@redhat.com \
--cc=conor+dt@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=robh@kernel.org \
--cc=sebin.francis@ti.com \
--cc=sudeep.holla@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