From patchwork Sat Jun 17 10:29:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Oltmanns X-Patchwork-Id: 10926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1896606vqr; Sat, 17 Jun 2023 03:34:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4yJKnLf9a/S3BF2/zSebF6rfpZEH5Aqu29GPaxPSKDbZioyyYQFzURT4GtdL4DvE775qwL X-Received: by 2002:a92:c802:0:b0:33b:4d0c:e947 with SMTP id v2-20020a92c802000000b0033b4d0ce947mr2518445iln.0.1686998051818; Sat, 17 Jun 2023 03:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686998051; cv=none; d=google.com; s=arc-20160816; b=MDtYaDgYC8/nWOlDSpXmYPF1ZU1s6RTsPuBRoz1QyPluwp5RNv3WoYPro7NlZdf3S0 55iaXAZ7eoXXQ0K6lU3Q9NxGv+mTowGDteHef1fLkVlIgAugJVxVQxc1b0lsneiJM/0H lzLGMwSMYiXiNHCIP/4Lt+yZ6vYxfqfG6Yw6uiMli76bqepj1W/r4UfmuV2MhOU7TV5E bZjs1HVavnw2muM4dFw4m73PvoKJ6OItRQDlmzVox3rkhCn6M6VJKv52SjqtEjdHSoe9 I8PKQtEAEq0PhAsQ+1AkJTb8o5UbYeLdQRD3iJEHtW1Yi5fNYH8fFfXzsrQE0iEOZxZH IkKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=K5wyhgjHKxMK2UvxF9fHePQ3wWFGU8riLfzYADKKQ7w=; b=r0Ze/F9EP1YYXlk+zp2UJujjvb/2QsF4BBLNEpegIT5bSxuFynHBhbNz1fTqdMGyLv HWtTvdmczkw8RsfI3gZJ3+BZengU/E2MMG8U8bGtr5GRY2TGIfBMDI6PTxMx3/XuhO5b pFtz1dmac9oQde7v+qnOSpzc59uDrf0NDFE8AR6TCRftGCR0+GaVoJ5nb92WiHKHDkUm PEgqytRgYs8xkZvLsyESt+RisoAqxGAl+zG+sEp5/tVt855xK/DuEn3mY/E1NujK456d kae4xxIotRTRCdzi6uCNqQwVvCEgoGbEm1UKZydRVaFU8pKfjTtHy3daTLazyTgdJadA 6Tlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=jVNb4i6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h28-20020a63385c000000b00553851380besi2309342pgn.397.2023.06.17.03.33.53; Sat, 17 Jun 2023 03:34:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oltmanns.dev header.s=MBO0001 header.b=jVNb4i6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oltmanns.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346158AbjFQK3s (ORCPT + 99 others); Sat, 17 Jun 2023 06:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235819AbjFQK3m (ORCPT ); Sat, 17 Jun 2023 06:29:42 -0400 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314741FFE; Sat, 17 Jun 2023 03:29:40 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-101.mailbox.org (Postfix) with ESMTPS id 4Qjshw1bbRz9skk; Sat, 17 Jun 2023 12:29:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1686997776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=K5wyhgjHKxMK2UvxF9fHePQ3wWFGU8riLfzYADKKQ7w=; b=jVNb4i6S+RfjnA2Ucr3rrz1VKTNbDFjsM2au3KKHy6p1vZyQGFUCDdr0hVxUF5BJGu1/fj FjxseDFXiX1CCx8snkYz3t20VD3RYuit4UnTeiq92Q4RkzXEPh95gku2uWRW0J1Y+s+cm7 wbRnCXqrymdIzPGU/AyM6cXi/YITQWhDVmwJwKzbSlhs2f7ALPIp9Wryl3rFDiBDeDnonh yoRNcBFRCGu3bJ2SGp0Bv9nxGUCRRRNPgfJwGRepABfJVYZC0ThxNwcB6zRNLUjnyXeleC S2twfTK902N9R2ok8O8/77wsuyPcP9c3i8HtLwTxkU2MakLAtBjDBgPjle/8og== From: Frank Oltmanns To: Michael Turquette , Stephen Boyd Cc: Frank Oltmanns , "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 , Elaine Zhang Subject: [PATCH v4 0/2] clk: fractional-divider: Improve approximation when zero based and export Date: Sat, 17 Jun 2023 12:29:17 +0200 Message-ID: <20230617102919.27564-1-frank@oltmanns.dev> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4Qjshw1bbRz9skk X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768945668763524249?= X-GMAIL-MSGID: =?utf-8?q?1768945668763524249?= The fractional divider approximation does not utilize the full available range for clocks that are flagged CLK_FRAC_DIVIDER_ZERO_BASED. This patchset aims to fix that. It also adds test cases for the edge cases of fractional divider clocks with and without the CLK_FRAC_DIVIDER_ZERO_BASED flag to highlight the changes. Finally, it also exports clk_fractional_divider_general_approximation so that the test cases (but also other users like rockchip clk driver) can be compiled as a module. Unfortunately, I have no boards to test this patch. So all we have are the unit tests. It seems the only user of this flag in mainline is drivers/clk/imx/clk-composite-7ulp.c, therefore I'm cc-ing get_maintainers.pl --git-blame -f drivers/clk/imx/clk-composite-7ulp.c in the hopes of a wider audience. Thank you for considering this contribution, Frank V3: https://lore.kernel.org/all/20230614185521.477924-1-frank@oltmanns.dev/ V2: https://lore.kernel.org/lkml/20230613083626.227476-1-frank@oltmanns.dev/ V1: https://lore.kernel.org/lkml/20230529133433.56215-1-frank@oltmanns.dev/ Changes in V4 (since V3): - Export clk_fractional_divider_general_approximation so that users (e.g., the testcases) can be compiled as modules. - Change test cases so that they test clk_fractional_divider_general_approximation again (like in V2) instead of clk_fd_round_rate (like in V3), but keeping the structure of V3 with separate file and individual test cases for each edge case. Changes in V3 (since V2): - Completely reworked the test cases - Moved tests to separate file as per Stephen's request - Move each edge case into their individual test case as per Stephen's request - Test clk_fd_round_rate instead of clk_fractional_divider_general_approximation as testing the latter broke builds Changes in V2 (since V1): - Added test case as requested by Stephen Boyd - Fixed commit message as the Cc: was missing a closing bracket, so that the original mail unfortunately did not go out to A. s. Dong. Frank Oltmanns (2): clk: fractional-divider: Improve approximation when zero based and export clk: fractional-divider: tests: Add test suite for edge cases drivers/clk/.kunitconfig | 1 + drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-fractional-divider.c | 27 +++- drivers/clk/clk-fractional-divider_test.c | 161 ++++++++++++++++++++++ 5 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 drivers/clk/clk-fractional-divider_test.c