clk: tests: Add missing test case for ranges

Let's add a test on the rate range after a reparenting. This fails for
now, but it's worth having it to document the corner cases we don't
support yet.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220816112530.1837489-26-maxime@cerno.tech
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by Maxime Ripard and committed by Stephen Boyd 433fb8a6 af1e62f2

+53
+53
drivers/clk/clk_test.c
··· 514 514 clk_put(clk); 515 515 } 516 516 517 + /* 518 + * Test that for a clock with a multiple parents, if we set a range on 519 + * that clock and the parent is changed, its rate after the reparenting 520 + * is still within the range we asked for. 521 + * 522 + * FIXME: clk_set_parent() only does the reparenting but doesn't 523 + * reevaluate whether the new clock rate is within its boundaries or 524 + * not. 525 + */ 526 + static void 527 + clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test) 528 + { 529 + struct clk_multiple_parent_ctx *ctx = test->priv; 530 + struct clk_hw *hw = &ctx->hw; 531 + struct clk *clk = clk_hw_get_clk(hw, NULL); 532 + struct clk *parent1, *parent2; 533 + unsigned long rate; 534 + int ret; 535 + 536 + kunit_skip(test, "This needs to be fixed in the core."); 537 + 538 + parent1 = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL); 539 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1); 540 + KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1)); 541 + 542 + parent2 = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); 543 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2); 544 + 545 + ret = clk_set_rate(parent1, DUMMY_CLOCK_RATE_1); 546 + KUNIT_ASSERT_EQ(test, ret, 0); 547 + 548 + ret = clk_set_rate(parent2, DUMMY_CLOCK_RATE_2); 549 + KUNIT_ASSERT_EQ(test, ret, 0); 550 + 551 + ret = clk_set_rate_range(clk, 552 + DUMMY_CLOCK_RATE_1 - 1000, 553 + DUMMY_CLOCK_RATE_1 + 1000); 554 + KUNIT_ASSERT_EQ(test, ret, 0); 555 + 556 + ret = clk_set_parent(clk, parent2); 557 + KUNIT_ASSERT_EQ(test, ret, 0); 558 + 559 + rate = clk_get_rate(clk); 560 + KUNIT_ASSERT_GT(test, rate, 0); 561 + KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000); 562 + KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); 563 + 564 + clk_put(parent2); 565 + clk_put(parent1); 566 + clk_put(clk); 567 + } 568 + 517 569 static struct kunit_case clk_multiple_parents_mux_test_cases[] = { 518 570 KUNIT_CASE(clk_test_multiple_parents_mux_get_parent), 519 571 KUNIT_CASE(clk_test_multiple_parents_mux_has_parent), 572 + KUNIT_CASE(clk_test_multiple_parents_mux_set_range_set_parent_get_rate), 520 573 {} 521 574 }; 522 575