staticint clk_dummy_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{ /* Just return the same rate without modifying it */ return 0;
}
staticint clk_dummy_maximize_rate(struct clk_hw *hw, struct clk_rate_request *req)
{ /* * If there's a maximum set, always run the clock at the maximum * allowed.
*/ if (req->max_rate < ULONG_MAX)
req->rate = req->max_rate;
return 0;
}
staticint clk_dummy_minimize_rate(struct clk_hw *hw, struct clk_rate_request *req)
{ /* * If there's a minimum set, always run the clock at the minimum * allowed.
*/ if (req->min_rate > 0)
req->rate = req->min_rate;
staticconststruct clk_ops clk_dummy_single_parent_ops = { /* * FIXME: Even though we should probably be able to use * __clk_mux_determine_rate() here, if we use it and call * clk_round_rate() or clk_set_rate() with a rate lower than * what all the parents can provide, it will return -EINVAL. * * This is due to the fact that it has the undocumented * behaviour to always pick up the closest rate higher than the * requested rate. If we get something lower, it thus considers * that it's not acceptable and will return an error. * * It's somewhat inconsistent and creates a weird threshold * between rates above the parent rate which would be rounded to * what the parent can provide, but rates below will simply * return an error.
*/
.determine_rate = __clk_mux_determine_rate_closest,
.set_parent = clk_dummy_single_set_parent,
.get_parent = clk_dummy_single_get_parent,
};
/* * Test that the actual rate matches what is returned by clk_get_rate()
*/ staticvoid clk_test_get_rate(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that, after a call to clk_set_rate(), the rate returned by * clk_get_rate() matches. * * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't * modify the requested rate, which is our case in clk_dummy_rate_ops.
*/ staticvoid clk_test_set_get_rate(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that, after several calls to clk_set_rate(), the rate returned * by clk_get_rate() matches the last one. * * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't * modify the requested rate, which is our case in clk_dummy_rate_ops.
*/ staticvoid clk_test_set_set_get_rate(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that clk_round_rate and clk_set_rate are consistent and will * return the same frequency.
*/ staticvoid clk_test_round_set_get_rate(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong set_rate; long rounded_rate;
/* * Test suite for a basic rate clock, without any parent. * * These tests exercise the rate API with simple scenarios
*/ staticstruct kunit_suite clk_test_suite = {
.name = "clk-test",
.init = clk_test_init,
.exit = clk_test_exit,
.test_cases = clk_test_cases,
};
staticint clk_uncached_test_init(struct kunit *test)
{ struct clk_dummy_context *ctx; int ret;
ret = clk_hw_register(NULL, &ctx->hw); if (ret) return ret;
return 0;
}
/* * Test that for an uncached clock, the clock framework doesn't cache * the rate and clk_get_rate() will return the underlying clock rate * even if it changed.
*/ staticvoid clk_test_uncached_get_rate(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that for an uncached clock, clk_set_rate_range() will work * properly if the rate has changed in hardware. * * In this case, it means that if the rate wasn't initially in the range * we're trying to set, but got changed at some point into the range * without the kernel knowing about it, its rate shouldn't be affected.
*/ staticvoid clk_test_uncached_updated_rate_set_range(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* We change the rate behind the clock framework's back */
ctx->rate = DUMMY_CLOCK_RATE_1 + 1000;
KUNIT_ASSERT_EQ(test,
clk_set_rate_range(clk,
DUMMY_CLOCK_RATE_1,
DUMMY_CLOCK_RATE_2),
0);
/* * Test suite for a basic, uncached, rate clock, without any parent. * * These tests exercise the rate API with simple scenarios
*/ staticstruct kunit_suite clk_uncached_test_suite = {
.name = "clk-uncached-test",
.init = clk_uncached_test_init,
.exit = clk_test_exit,
.test_cases = clk_uncached_test_cases,
};
/* * Test that for a clock with a multiple parents, clk_has_parent() * actually reports all of them as parents.
*/ staticvoid
clk_test_multiple_parents_mux_has_parent(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent;
/* * Test that for a clock with a multiple parents, if we set a range on * that clock and the parent is changed, its rate after the reparenting * is still within the range we asked for. * * FIXME: clk_set_parent() only does the reparenting but doesn't * reevaluate whether the new clock rate is within its boundaries or * not.
*/ staticvoid
clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); struct clk *parent1, *parent2; unsignedlong rate; int ret;
kunit_skip(test, "This needs to be fixed in the core.");
/* * Test suite for a basic mux clock with two parents, with * CLK_SET_RATE_PARENT on the child. * * These tests exercise the consumer API and check that the state of the * child and parents are sane and consistent.
*/ staticstruct kunit_suite
clk_multiple_parents_mux_test_suite = {
.name = "clk-multiple-parents-mux-test",
.init = clk_multiple_parents_mux_test_init,
.test_cases = clk_multiple_parents_mux_test_cases,
};
/* * Test that, for a mux whose current parent hasn't been registered yet, * calling clk_set_parent() to a valid parent will properly update the * mux parent and its orphan status.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent, *new_parent; int ret;
/* * Test that, for a mux that started orphan but got switched to a valid * parent, calling clk_drop_range() on the mux won't affect the parent * rate.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent_drop_range(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; unsignedlong parent_rate, new_parent_rate; int ret;
/* * Test that, for a mux that started orphan but got switched to a valid * parent, the rate of the mux and its new parent are consistent.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; unsignedlong parent_rate, rate; int ret;
/* * Test that, for a mux that started orphan but got switched to a valid * parent, calling clk_put() on the mux won't affect the parent rate.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent_put(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk *clk, *parent; unsignedlong parent_rate, new_parent_rate; int ret;
/* * Test that, for a mux that started orphan but got switched to a valid * parent, calling clk_set_rate_range() will affect the parent state if * its rate is out of range.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; unsignedlong rate; int ret;
/* * Test that, for a mux that started orphan but got switched to a valid * parent, calling clk_set_rate_range() won't affect the parent state if * its rate is within range.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_untouched(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; unsignedlong parent_rate, new_parent_rate; int ret;
/* * Test that, for a mux whose current parent hasn't been registered yet, * calling clk_set_rate_range() will succeed, and will be taken into * account when rounding a rate.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_range_round_rate(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); long rate; int ret;
ret = clk_set_rate_range(clk, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2);
KUNIT_ASSERT_EQ(test, ret, 0);
/* * Test that, for a mux that started orphan, was assigned and rate and * then got switched to a valid parent, its rate is eventually within * range. * * FIXME: Even though we update the rate as part of clk_set_parent(), we * don't evaluate whether that new rate is within range and needs to be * adjusted.
*/ staticvoid
clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(struct kunit *test)
{ struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); struct clk *parent; unsignedlong rate; int ret;
kunit_skip(test, "This needs to be fixed in the core.");
/* * Test suite for a basic mux clock with two parents. The default parent * isn't registered, only the second parent is. By default, the clock * will thus be orphan. * * These tests exercise the behaviour of the consumer API when dealing * with an orphan clock, and how we deal with the transition to a valid * parent.
*/ staticstruct kunit_suite clk_orphan_transparent_multiple_parent_mux_test_suite = {
.name = "clk-orphan-transparent-multiple-parent-mux-test",
.init = clk_orphan_transparent_multiple_parent_mux_test_init,
.test_cases = clk_orphan_transparent_multiple_parent_mux_test_cases,
};
/* * Test that for a clock with a single parent, clk_has_parent() actually * reports it as a parent.
*/ staticvoid
clk_test_single_parent_mux_has_parent(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent = clk_hw_get_clk(&ctx->parent_ctx.hw, NULL);
/* * Test that for a clock that can't modify its rate and with a single * parent, if we set disjoints range on the parent and then the child, * the second will return an error. * * FIXME: clk_set_rate_range() only considers the current clock when * evaluating whether ranges are disjoints and not the upstream clocks * ranges.
*/ staticvoid
clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); struct clk *parent; int ret;
kunit_skip(test, "This needs to be fixed in the core.");
ret = clk_set_rate_range(parent, 1000, 2000);
KUNIT_ASSERT_EQ(test, ret, 0);
ret = clk_set_rate_range(clk, 3000, 4000);
KUNIT_EXPECT_LT(test, ret, 0);
}
/* * Test that for a clock that can't modify its rate and with a single * parent, if we set disjoints range on the child and then the parent, * the second will return an error. * * FIXME: clk_set_rate_range() only considers the current clock when * evaluating whether ranges are disjoints and not the downstream clocks * ranges.
*/ staticvoid
clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL); struct clk *parent; int ret;
kunit_skip(test, "This needs to be fixed in the core.");
ret = clk_set_rate_range(clk, 1000, 2000);
KUNIT_ASSERT_EQ(test, ret, 0);
ret = clk_set_rate_range(parent, 3000, 4000);
KUNIT_EXPECT_LT(test, ret, 0);
}
/* * Test that for a clock that can't modify its rate and with a single * parent, if we set a range on the parent and then call * clk_round_rate(), the boundaries of the parent are taken into * account.
*/ staticvoid
clk_test_single_parent_mux_set_range_round_rate_parent_only(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; long rate; int ret;
/* * Test that for a clock that can't modify its rate and with a single * parent, if we set a range on the parent and a more restrictive one on * the child, and then call clk_round_rate(), the boundaries of the * two clocks are taken into account.
*/ staticvoid
clk_test_single_parent_mux_set_range_round_rate_child_smaller(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; long rate; int ret;
/* * Test that for a clock that can't modify its rate and with a single * parent, if we set a range on the child and a more restrictive one on * the parent, and then call clk_round_rate(), the boundaries of the * two clocks are taken into account.
*/ staticvoid
clk_test_single_parent_mux_set_range_round_rate_parent_smaller(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *parent; long rate; int ret;
/* * Test suite for a basic mux clock with one parent, with * CLK_SET_RATE_PARENT on the child. * * These tests exercise the consumer API and check that the state of the * child and parent are sane and consistent.
*/ staticstruct kunit_suite
clk_single_parent_mux_test_suite = {
.name = "clk-single-parent-mux-test",
.init = clk_single_parent_mux_test_init,
.test_cases = clk_single_parent_mux_test_cases,
};
ret = clk_hw_register(NULL, &ctx->parent_ctx.hw); if (ret) return ret;
return 0;
}
/* * Test that a mux-only clock, with an initial rate within a range, * will still have the same rate after the range has been enforced. * * See: * https://lore.kernel.org/linux-clk/7720158d-10a7-a17b-73a4-a8615c9c6d5c@collabora.com/
*/ staticvoid clk_test_orphan_transparent_parent_mux_set_range(struct kunit *test)
{ struct clk_single_parent_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate, new_rate;
/* * Test suite for a basic mux clock with one parent. The parent is * registered after its child. The clock will thus be an orphan when * registered, but will no longer be when the tests run. * * These tests make sure a clock that used to be orphan has a sane, * consistent, behaviour.
*/ staticstruct kunit_suite clk_orphan_transparent_single_parent_test_suite = {
.name = "clk-orphan-transparent-single-parent-test",
.init = clk_orphan_transparent_single_parent_mux_test_init,
.exit = clk_single_parent_mux_test_exit,
.test_cases = clk_orphan_transparent_single_parent_mux_test_cases,
};
/* * Test that, for a clock whose parent used to be orphan, * clk_set_rate_range() won't affect its rate if it is already within * range. * * See (for Exynos 4210): * https://lore.kernel.org/linux-clk/366a0232-bb4a-c357-6aa8-636e398e05eb@samsung.com/
*/ staticvoid
clk_orphan_two_level_root_last_test_set_range(struct kunit *test)
{ struct clk_single_parent_two_lvl_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate; int ret;
/* * Test suite for a basic, transparent, clock with a parent that is also * such a clock. The parent's parent is registered last, while the * parent and its child are registered in that order. The intermediate * and leaf clocks will thus be orphan when registered, but the leaf * clock itself will always have its parent and will never be * reparented. Indeed, it's only orphan because its parent is. * * These tests exercise the behaviour of the consumer API when dealing * with an orphan clock, and how we deal with the transition to a valid * parent.
*/ staticstruct kunit_suite
clk_orphan_two_level_root_last_test_suite = {
.name = "clk-orphan-two-level-root-last-test",
.init = clk_orphan_two_level_root_last_test_init,
.exit = clk_orphan_two_level_root_last_test_exit,
.test_cases = clk_orphan_two_level_root_last_test_cases,
};
/* * Test that clk_set_rate_range won't return an error for a valid range * and that it will make sure the rate of the clock is within the * boundaries.
*/ staticvoid clk_range_test_set_range(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that users can't set multiple, disjoints, range that would be * impossible to meet.
*/ staticvoid clk_range_test_multiple_disjoints_range(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *user1, *user2;
/* * Test that if our clock has some boundaries and we try to round a rate * lower than the minimum, the returned rate will be within range.
*/ staticvoid clk_range_test_set_range_round_rate_lower(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); long rate;
/* * Test that if our clock has some boundaries and we try to set a rate * higher than the maximum, the new rate will be within range.
*/ staticvoid clk_range_test_set_range_set_rate_lower(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that if our clock has some boundaries and we try to round and * set a rate lower than the minimum, the rate returned by * clk_round_rate() will be consistent with the new rate set by * clk_set_rate().
*/ staticvoid clk_range_test_set_range_set_round_rate_consistent_lower(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); long rounded;
/* * Test that if our clock has some boundaries and we try to round a rate * higher than the maximum, the returned rate will be within range.
*/ staticvoid clk_range_test_set_range_round_rate_higher(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); long rate;
/* * Test that if our clock has some boundaries and we try to set a rate * higher than the maximum, the new rate will be within range.
*/ staticvoid clk_range_test_set_range_set_rate_higher(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that if our clock has some boundaries and we try to round and * set a rate higher than the maximum, the rate returned by * clk_round_rate() will be consistent with the new rate set by * clk_set_rate().
*/ staticvoid clk_range_test_set_range_set_round_rate_consistent_higher(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); long rounded;
/* * Test that if our clock has a rate lower than the minimum set by a * call to clk_set_rate_range(), the rate will be raised to match the * new minimum. * * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't * modify the requested rate, which is our case in clk_dummy_rate_ops.
*/ staticvoid clk_range_test_set_range_get_rate_raised(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that if our clock has a rate higher than the maximum set by a * call to clk_set_rate_range(), the rate will be lowered to match the * new maximum. * * This assumes that clk_ops.determine_rate or clk_ops.round_rate won't * modify the requested rate, which is our case in clk_dummy_rate_ops.
*/ staticvoid clk_range_test_set_range_get_rate_lowered(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test suite for a basic rate clock, without any parent. * * These tests exercise the rate range API: clk_set_rate_range(), * clk_set_min_rate(), clk_set_max_rate(), clk_drop_range().
*/ staticstruct kunit_suite clk_range_test_suite = {
.name = "clk-range-test",
.init = clk_test_init,
.exit = clk_test_exit,
.test_cases = clk_range_test_cases,
};
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), the core will reevaluate whether a new rate is * needed each and every time. * * With clk_dummy_maximize_rate_ops, this means that the rate will * trail along the maximum as it evolves.
*/ staticvoid clk_range_test_set_range_rate_maximized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), across multiple users, the core will reevaluate * whether a new rate is needed each and every time. * * With clk_dummy_maximize_rate_ops, this means that the rate will * trail along the maximum as it evolves.
*/ staticvoid clk_range_test_multiple_set_range_rate_maximized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *user1, *user2; unsignedlong rate;
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), across multiple users, the core will reevaluate * whether a new rate is needed, including when a user drop its clock. * * With clk_dummy_maximize_rate_ops, this means that the rate will * trail along the maximum as it evolves.
*/ staticvoid clk_range_test_multiple_set_range_rate_put_maximized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *user1, *user2; unsignedlong rate;
/* * Test suite for a basic rate clock, without any parent. * * These tests exercise the rate range API: clk_set_rate_range(), * clk_set_min_rate(), clk_set_max_rate(), clk_drop_range(), with a * driver that will always try to run at the highest possible rate.
*/ staticstruct kunit_suite clk_range_maximize_test_suite = {
.name = "clk-range-maximize-test",
.init = clk_maximize_test_init,
.exit = clk_test_exit,
.test_cases = clk_range_maximize_test_cases,
};
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), the core will reevaluate whether a new rate is * needed each and every time. * * With clk_dummy_minimize_rate_ops, this means that the rate will * trail along the minimum as it evolves.
*/ staticvoid clk_range_test_set_range_rate_minimized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); unsignedlong rate;
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), across multiple users, the core will reevaluate * whether a new rate is needed each and every time. * * With clk_dummy_minimize_rate_ops, this means that the rate will * trail along the minimum as it evolves.
*/ staticvoid clk_range_test_multiple_set_range_rate_minimized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *user1, *user2; unsignedlong rate;
/* * Test that if we have several subsequent calls to * clk_set_rate_range(), across multiple users, the core will reevaluate * whether a new rate is needed, including when a user drop its clock. * * With clk_dummy_minimize_rate_ops, this means that the rate will * trail along the minimum as it evolves.
*/ staticvoid clk_range_test_multiple_set_range_rate_put_minimized(struct kunit *test)
{ struct clk_dummy_context *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *user1, *user2; unsignedlong rate;
/* * Test suite for a basic rate clock, without any parent. * * These tests exercise the rate range API: clk_set_rate_range(), * clk_set_min_rate(), clk_set_max_rate(), clk_drop_range(), with a * driver that will always try to run at the lowest possible rate.
*/ staticstruct kunit_suite clk_range_minimize_test_suite = {
.name = "clk-range-minimize-test",
.init = clk_minimize_test_init,
.exit = clk_test_exit,
.test_cases = clk_range_minimize_test_cases,
};
staticconststruct clk_leaf_mux_set_rate_parent_determine_rate_test_case
clk_leaf_mux_set_rate_parent_determine_rate_test_cases[] = {
{ /* * Test that __clk_determine_rate() on the parent that can't * change rate doesn't return a clk_rate_request structure with * the best_parent_hw pointer pointing to the parent.
*/
.desc = "clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent",
.determine_rate_func = __clk_determine_rate,
},
{ /* * Test that __clk_mux_determine_rate() on the parent that * can't change rate doesn't return a clk_rate_request * structure with the best_parent_hw pointer pointing to * the parent.
*/
.desc = "clk_leaf_mux_set_rate_parent__clk_mux_determine_rate_proper_parent",
.determine_rate_func = __clk_mux_determine_rate,
},
{ /* * Test that __clk_mux_determine_rate_closest() on the parent * that can't change rate doesn't return a clk_rate_request * structure with the best_parent_hw pointer pointing to * the parent.
*/
.desc = "clk_leaf_mux_set_rate_parent__clk_mux_determine_rate_closest_proper_parent",
.determine_rate_func = __clk_mux_determine_rate_closest,
},
{ /* * Test that clk_hw_determine_rate_no_reparent() on the parent * that can't change rate doesn't return a clk_rate_request * structure with the best_parent_hw pointer pointing to * the parent.
*/
.desc = "clk_leaf_mux_set_rate_parent_clk_hw_determine_rate_no_reparent_proper_parent",
.determine_rate_func = clk_hw_determine_rate_no_reparent,
},
};
/* * Test that when a clk that can't change rate itself calls a function like * __clk_determine_rate() on its parent it doesn't get back a clk_rate_request * structure that has the best_parent_hw pointer point to the clk_hw passed * into the determine rate function. See commit 262ca38f4b6e ("clk: Stop * forwarding clk_rate_requests to the parent") for more background.
*/ staticvoid clk_leaf_mux_set_rate_parent_determine_rate_test(struct kunit *test)
{ struct clk_leaf_mux_ctx *ctx = test->priv; struct clk_hw *hw = &ctx->hw; struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk_rate_request req; unsignedlong rate; conststruct clk_leaf_mux_set_rate_parent_determine_rate_test_case *test_param;
/* * Test suite for a clock whose parent is a pass-through clk whose parent is a * mux with multiple parents. The leaf and pass-through clocks have the * CLK_SET_RATE_PARENT flag, and will forward rate requests to the mux, which * will then select which parent is the best fit for a given rate. * * These tests exercise the behaviour of muxes, and the proper selection * of parents.
*/ staticstruct kunit_suite clk_leaf_mux_set_rate_parent_test_suite = {
.name = "clk-leaf-mux-set-rate-parent",
.init = clk_leaf_mux_set_rate_parent_test_init,
.exit = clk_leaf_mux_set_rate_parent_test_exit,
.test_cases = clk_leaf_mux_set_rate_parent_test_cases,
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.