From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9567FC7EE29 for ; Tue, 13 Jun 2023 08:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date: In-reply-to:Subject:Cc:To:From:References:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=A4OcG7res0IOKvGNSmg3qtQWfhWUmcZiysqZpTnNamM=; b=SzpcC7v9zZfIssiCpdHVEAyI4B ycjXdqjxajLLms48BB/7ZgLm95mVGXNjRBaHCu6kpY37qmJMUiLn9FT92EYsfsD5Dlf/iokWft23a 84R+yiN9uMBDO3H2Kq9LT1iSCnCzScXyjKTTPALUHvoaUDKvX1ZjSBzSj0yjvGTRJ6pXuFXbmPE2P qoqMxbtNSTs1kg3TCgRI391U8EwVQSxQEmGmLdfRccNY2FRuXPCYHY+ANetHIxJKnJJRaHGLrDIwM 0xGvpE0keeGozqZon5YHCcAQtWwkFCNY0YSSk1v4WytVNMhBcpiagaGcieua/PZvkodKkCeWzu6UY bI21HYMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q8ziV-007QjE-0Z; Tue, 13 Jun 2023 08:49:31 +0000 Received: from mout-p-102.mailbox.org ([80.241.56.152]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q8ziS-007QhO-0b for linux-arm-kernel@lists.infradead.org; Tue, 13 Jun 2023 08:49:29 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4QgMg82g5cz9sdK; Tue, 13 Jun 2023 10:49:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1686646164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dKOsikHuaIxLmnX7LMFU7lxyfkWIITufUYLJEhwma08=; b=Tg0prYrFLmm3TK1RL2DIhXYXPzA4ERHcq6g/Qv2oJ9RXJ2jCrCHxQ6/l+Qj+AybFvdKTfj g1ku6Q9T4pExxcTpo/xUnNyjeNsxMfadlxigEiqdgLLUIK2d7FVDXqW2HhclLuGZzzTtmg /j/CCKMlE+T+Gk3oPa1Vn/yEqSotGkeI7CTog/PPYrhMaerAEyZnSdWzwpFgTHTZEKLQ9J FEzNuAgRcsBddjDAKxnec9F2Pd1mKGLU86CFysrlVrTe9kChjXMKk0dcQ+j6kfQmRuq10e ve+utR9jq6Oz6orV3YSMI+nhRSoWlX4kxqp8qcc84KxdyXpIamPbal1vD7ElDQ== References: <20230613083626.227476-1-frank@oltmanns.dev> <20230613083626.227476-3-frank@oltmanns.dev> From: Frank Oltmanns To: Stephen Boyd Cc: Michael Turquette , "A.s. Dong" , Abel Vesa , Fabio Estevam , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, NXP Linux Team , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo Subject: Re: [PATCH v2 2/2] clk: tests: Add tests for fractional divisor approximation In-reply-to: <20230613083626.227476-3-frank@oltmanns.dev> Date: Tue, 13 Jun 2023 10:49:20 +0200 Message-ID: <871qif21db.fsf@oltmanns.dev> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4QgMg82g5cz9sdK X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230613_014928_421513_2012CE5D X-CRM114-Status: GOOD ( 20.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Stephen, On 2023-06-13 at 10:36:26 +0200, Frank Oltmanns wrote: > In light of the recent discovery that the fractional divisor > approximation does not utilize the full available range for clocks that > are flagged CLK_FRAC_DIVIDER_ZERO_BASED, implement tests for the edge > cases of this clock type. > > Signed-off-by: Frank Oltmanns > Link: https://lore.kernel.org/lkml/20230529133433.56215-1-frank@oltmanns.dev > --- > drivers/clk/clk_test.c | 69 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 68 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c > index f9a5c2964c65..b247ba841cbd 100644 > --- a/drivers/clk/clk_test.c > +++ b/drivers/clk/clk_test.c > @@ -8,6 +8,9 @@ > /* Needed for clk_hw_get_clk() */ > #include "clk.h" > > +/* Needed for clk_fractional_divider_general_approximation */ > +#include "clk-fractional-divider.h" > + > #include > > #define DUMMY_CLOCK_INIT_RATE (42 * 1000 * 1000) > @@ -2394,6 +2397,69 @@ static struct kunit_suite clk_mux_notifier_test_suite = { > .test_cases = clk_mux_notifier_test_cases, > }; > > + > +/* > + * Test that clk_fractional_divider_general_approximation will work with the > + * highest available numerator and denominator. > + */ > +static void clk_fd_test_round_rate_max_mn(struct kunit *test) > +{ > + struct clk_fractional_divider *fd; > + struct clk_hw *hw; > + unsigned long rate, parent_rate, m, n; > + > + fd = kunit_kzalloc(test, sizeof(*fd), GFP_KERNEL); > + KUNIT_ASSERT_NOT_NULL(test, fd); > + > + fd->mwidth = 3; > + fd->nwidth = 3; > + > + hw = &fd->hw; > + > + rate = DUMMY_CLOCK_RATE_1; > + > + // Highest denominator, no flags > + parent_rate = 10 * DUMMY_CLOCK_RATE_1; > + clk_fractional_divider_general_approximation(hw, rate, &parent_rate, &m, &n); > + KUNIT_EXPECT_EQ(test, m, 1); > + KUNIT_EXPECT_EQ(test, n, 7); > + > + // Highest numerator, no flags > + parent_rate = DUMMY_CLOCK_RATE_1 / 10; > + clk_fractional_divider_general_approximation(hw, rate, &parent_rate, &m, &n); > + KUNIT_EXPECT_EQ(test, m, 7); > + KUNIT_EXPECT_EQ(test, n, 1); The two calls above aim at proving that the change does not break existing functionality. > + > + // Highest denominator, zero based > + parent_rate = 10 * DUMMY_CLOCK_RATE_1; > + fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED; > + clk_fractional_divider_general_approximation(hw, rate, &parent_rate, &m, &n); > + KUNIT_EXPECT_EQ(test, m, 1); > + KUNIT_EXPECT_EQ(test, n, 8); > + > + // Highest numerator, zero based > + parent_rate = DUMMY_CLOCK_RATE_1 / 10; > + clk_fractional_divider_general_approximation(hw, rate, &parent_rate, &m, &n); > + KUNIT_EXPECT_EQ(test, m, 8); > + KUNIT_EXPECT_EQ(test, n, 1); > +} > + > +static struct kunit_case clk_fd_test_cases[] = { > + KUNIT_CASE(clk_fd_test_round_rate_max_mn), > + {} > +}; > + > +/* > + * Test suite for a fractional divider clock. > + * > + * These tests exercise the fractional divider API: clk_recalc_rate, > + * clk_set_rate(), clk_round_rate(). > + */ > +static struct kunit_suite clk_fd_test_suite = { > + .name = "clk-fd-test", > + .test_cases = clk_fd_test_cases, > +}; Unfortunately, the style of the tests does not really match with the style of the existing tests, because those where all aimed at the framework itself and not at specific functions. Please let me know, if you require any changes. Thanks, Frank > + > kunit_test_suites( > &clk_leaf_mux_set_rate_parent_test_suite, > &clk_test_suite, > @@ -2406,6 +2472,7 @@ kunit_test_suites( > &clk_range_maximize_test_suite, > &clk_range_minimize_test_suite, > &clk_single_parent_mux_test_suite, > - &clk_uncached_test_suite > + &clk_uncached_test_suite, > + &clk_fd_test_suite > ); > MODULE_LICENSE("GPL v2"); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel