Message ID | 20230506162403.375212-1-aford173@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1173286vqo; Sat, 6 May 2023 10:31:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4laF6OueQKnsV8zpk1GXizxIOncY9IekTd96/vJiuBSxsbZ9LuZ+ycnaBHwofWBjmi4xdU X-Received: by 2002:a05:6a20:2590:b0:f6:51ff:9c27 with SMTP id k16-20020a056a20259000b000f651ff9c27mr7160587pzd.42.1683394296629; Sat, 06 May 2023 10:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683394296; cv=none; d=google.com; s=arc-20160816; b=fTrVcvdyc/QVOJiw8pxzY3+/+jbOvrbaLMhwB0iVt0f8Fnfl5pR2ygUQ702o7tZngd TspqQXtfJRNdfEJf66fFSQgWQO5rs8Tiy2T6mE5iMvQNM6mvOsf/agV1ut/f5lzFGdos Kb18GO586NoKtNAWsVee8N3tfNUYieq8afYsT9dRsjrSg0u1tl8ge+pAxEAzjf4SU8jP uyX1ZKMF9KLjnM6GpCjVqEvI2HDqBIeH0OBf6LzWWv2kBCiIYRGfUK/cEOFU6wFs+nVH gTtg9LnR/1j73MWHBIU6qMZN65CJY3jbiOpbhePgELAlA9+M2e2tMTFHt9z/jkf3QcTj cP3A== 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=khKwz5sXanssBqWJenlghMda3UHcmI6p3o8gOauYeXA=; b=qv8L/Pie5JYZMTItAdh7G/2HRo6DiZ3oG2bYF8HT0rUlIYkF8EJl92xO1+EnajNNCF jmVhz4UgWxYQP3MI1FI2yeAL5cXr/G/iC0fFXAdmiiQOziODUxqwn01LTLXrl4wL1LYm yVlI/2Ucy9LoHOSGnSc8CyuqhwIt1OeqeoIQslZ6YjH2G/ZyIJGFf9pSDy/8x6JhQf3W d2946fbjUJXYa1FDPZEG5d9R4D4LURe6D4LomiW51mEBYyx6X8V786qYs8dyxWHk97tK D6aoWRpqpk+oaaqwjML68JxPa122wS2DoKPpGwKz2siEhhZmzVW3bDLhDUiX3Ruei0Cx nsOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BdGRwKhK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i70-20020a638749000000b0050fbc594e1asi4650755pge.207.2023.05.06.10.31.21; Sat, 06 May 2023 10:31:36 -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=@gmail.com header.s=20221208 header.b=BdGRwKhK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjEFQYX (ORCPT <rfc822;baris.duru.linux@gmail.com> + 99 others); Sat, 6 May 2023 12:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEFQYV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 6 May 2023 12:24:21 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA3983FA; Sat, 6 May 2023 09:24:20 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3313fe59a61so7276885ab.0; Sat, 06 May 2023 09:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683390259; x=1685982259; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=khKwz5sXanssBqWJenlghMda3UHcmI6p3o8gOauYeXA=; b=BdGRwKhKrrUyt6L9ZQXOuIokSqZqRMKA9//i4NwFM1VS2LQmER3HKVI4ix2inR6aoq 6Ld05QVYpf1UErA/8+rFNXUL2bTXCIIJZD4V7iWOeTMrbrPPpQEv7V6+vsj89qeEqjI0 2udttB1VdSvsMd3jk6fc4NjrkjsH7gL6wVOPieoprEO5xqKu+fnl4T6APoKeC9fjc0rQ blI5oIflfjiXq32uvEyrND6+/QXz71tMJjXE7hTiLUP3eIAQdDfGElWFvWcWmbbF5k/H AnESyD2zRB6TeDcm7OEBM8r9BhOTm8+SHZH8Ry7/nrMRqX1tBvHtWEpkNi3wolRfezRs naXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683390259; x=1685982259; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=khKwz5sXanssBqWJenlghMda3UHcmI6p3o8gOauYeXA=; b=Rfw9gKX7SXz87xzA8hwUNsJDBhC2zHaRuBIgwsRhhRh8LZtRPQZuxn3KoAEiNmDqtv XcCg+CUJu25VyyZprryf4puTIEGCjRBn66DZY8+kSA3Av3jyoZbwec9lYJpaPGjMGwd7 Vo0RvJB1PJvgRpOng8k+xLR6RXuFx78og/KCWqqS6F+ntJDASHWfvB88HL2dryUXsVSh 72yr4oA0lRZmWaXE5vj/TfuTpxJkdRth+3xqx+smMA6XlPOhwegb37eKJbHYC83kqswa x5dcj67XacU/HwwAPf5Mw7vSPzndbvUH5mbTbd68uxKwZM7GQIjsJrhkw6EqbV8zsjJG PHpQ== X-Gm-Message-State: AC+VfDzB0PXzhpfc39S4FXlMkUjhx/QlKg/3FI+3h+ZGpGBZnjti/3sq 3UDPHMcj+kUTo2HKMj35d+00LTGjNkv+rA== X-Received: by 2002:a92:c530:0:b0:332:e5aa:f9b5 with SMTP id m16-20020a92c530000000b00332e5aaf9b5mr3345093ili.15.1683390259422; Sat, 06 May 2023 09:24:19 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:75c9:74af:40b2:789b]) by smtp.gmail.com with ESMTPSA id eq4-20020a0566384e2400b00411bc1340c0sm754892jab.8.2023.05.06.09.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 09:24:18 -0700 (PDT) From: Adam Ford <aford173@gmail.com> To: linux-clk@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford <aford173@gmail.com>, Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix Kernel Team <kernel@pengutronix.de>, Fabio Estevam <festevam@gmail.com>, NXP Linux Team <linux-imx@nxp.com>, linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] clk: imx: composite-8m: Add imx8m_divider_determine_rate Date: Sat, 6 May 2023 11:24:03 -0500 Message-Id: <20230506162403.375212-1-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765166858183443004?= X-GMAIL-MSGID: =?utf-8?q?1765166858183443004?= |
Series |
clk: imx: composite-8m: Add imx8m_divider_determine_rate
|
|
Commit Message
Adam Ford
May 6, 2023, 4:24 p.m. UTC
Currently, certain clocks, are derrived as a divider from their
parent clock. For some clocks, even when CLK_SET_RATE_PARENT
is set, the parent clock is not which can lead to some relatively
inaccurate clock values for child clocks.
Unlike imx/clk-composite-93 and imx/clk-divider-gate, it
cannot rely on calling a standard clock function, because
the 8m composite clocks have a pre-divider and post-divider.
Because of this, a custom determine_rate function is
necessary to determine the maximum clock division which is
equivalent to pre-divider * the post-divider in most cases.
With this added, the system can attempt to adjust the parent rate
when the proper flags are set which can lead to a more precise clock
value.
For example. When trying to get a pixel clock of 31.500MHz
on an imx8m Nano, the clocks divided the 594MHz down, but
left the parent rate untouched which caused a calulation error.
Before:
video_pll 594000000
video_pll_bypass 594000000
video_pll_out 594000000
disp_pixel 31263158
disp_pixel_clk 31263158
Variance = -236842 Hz
After this patch:
video_pll 31500000
video_pll_bypass 31500000
video_pll_out 31500000
disp_pixel 31500000
disp_pixel_clk 31500000
Variance = 0 Hz
All other clocks rates and parent were the same.
Similar results on imx8mm were found.
Unlike the previous attempt, when tested with imx8mp, no clock
rate or parent changes were found.
Fixes: 690dccc4a0bf ("Revert "clk: imx: composite-8m: Add support to determine_rate"")
Signed-off-by: Adam Ford <aford173@gmail.com>
Comments
Hi Adam, kernel test robot noticed the following build warnings: [auto build test WARNING on clk/clk-next] [also build test WARNING on v6.3 next-20230505] [cannot apply to abelvesa/clk/imx linus/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Adam-Ford/clk-imx-composite-8m-Add-imx8m_divider_determine_rate/20230507-002453 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230506162403.375212-1-aford173%40gmail.com patch subject: [PATCH] clk: imx: composite-8m: Add imx8m_divider_determine_rate config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230507/202305070143.iTqgbS75-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/d92df3b38fc20beb735cb3b75f118b45d1ae304b git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Adam-Ford/clk-imx-composite-8m-Add-imx8m_divider_determine_rate/20230507-002453 git checkout d92df3b38fc20beb735cb3b75f118b45d1ae304b # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/clk/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202305070143.iTqgbS75-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/clk/imx/clk-composite-8m.c:122:5: warning: no previous prototype for 'imx8m_divider_determine_rate' [-Wmissing-prototypes] 122 | int imx8m_divider_determine_rate(struct clk_hw *hw, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/imx8m_divider_determine_rate +122 drivers/clk/imx/clk-composite-8m.c 121 > 122 int imx8m_divider_determine_rate(struct clk_hw *hw, 123 struct clk_rate_request *req) 124 { 125 struct clk_divider *divider = to_clk_divider(hw); 126 int prediv_value; 127 int div_value; 128 129 /* if read only, just return current value */ 130 if (divider->flags & CLK_DIVIDER_READ_ONLY) { 131 u32 val; 132 133 val = readl(divider->reg); 134 prediv_value = val >> divider->shift; 135 prediv_value &= clk_div_mask(divider->width); 136 137 div_value = val >> PCG_DIV_SHIFT; 138 div_value &= clk_div_mask(PCG_DIV_WIDTH); 139 140 return divider_ro_determine_rate(hw, req, divider->table, 141 PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, 142 divider->flags, prediv_value * div_value); 143 } 144 145 return divider_determine_rate(hw, req, divider->table, 146 PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, 147 divider->flags); 148 } 149
Hi Adam, kernel test robot noticed the following build warnings: [auto build test WARNING on clk/clk-next] [also build test WARNING on v6.3 next-20230505] [cannot apply to abelvesa/clk/imx linus/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Adam-Ford/clk-imx-composite-8m-Add-imx8m_divider_determine_rate/20230507-002453 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230506162403.375212-1-aford173%40gmail.com patch subject: [PATCH] clk: imx: composite-8m: Add imx8m_divider_determine_rate config: powerpc-randconfig-r012-20230507 (https://download.01.org/0day-ci/archive/20230507/202305070235.r9bEq3U8-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/d92df3b38fc20beb735cb3b75f118b45d1ae304b git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Adam-Ford/clk-imx-composite-8m-Add-imx8m_divider_determine_rate/20230507-002453 git checkout d92df3b38fc20beb735cb3b75f118b45d1ae304b # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/clk/imx/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202305070235.r9bEq3U8-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/clk/imx/clk-composite-8m.c:122:5: warning: no previous prototype for function 'imx8m_divider_determine_rate' [-Wmissing-prototypes] int imx8m_divider_determine_rate(struct clk_hw *hw, ^ drivers/clk/imx/clk-composite-8m.c:122:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int imx8m_divider_determine_rate(struct clk_hw *hw, ^ static 1 warning generated. vim +/imx8m_divider_determine_rate +122 drivers/clk/imx/clk-composite-8m.c 121 > 122 int imx8m_divider_determine_rate(struct clk_hw *hw, 123 struct clk_rate_request *req) 124 { 125 struct clk_divider *divider = to_clk_divider(hw); 126 int prediv_value; 127 int div_value; 128 129 /* if read only, just return current value */ 130 if (divider->flags & CLK_DIVIDER_READ_ONLY) { 131 u32 val; 132 133 val = readl(divider->reg); 134 prediv_value = val >> divider->shift; 135 prediv_value &= clk_div_mask(divider->width); 136 137 div_value = val >> PCG_DIV_SHIFT; 138 div_value &= clk_div_mask(PCG_DIV_WIDTH); 139 140 return divider_ro_determine_rate(hw, req, divider->table, 141 PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, 142 divider->flags, prediv_value * div_value); 143 } 144 145 return divider_determine_rate(hw, req, divider->table, 146 PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, 147 divider->flags); 148 } 149
diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index cbf0d7955a00..fd49385bd2ae 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -119,10 +119,39 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw, return ret; } +int imx8m_divider_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_divider *divider = to_clk_divider(hw); + int prediv_value; + int div_value; + + /* if read only, just return current value */ + if (divider->flags & CLK_DIVIDER_READ_ONLY) { + u32 val; + + val = readl(divider->reg); + prediv_value = val >> divider->shift; + prediv_value &= clk_div_mask(divider->width); + + div_value = val >> PCG_DIV_SHIFT; + div_value &= clk_div_mask(PCG_DIV_WIDTH); + + return divider_ro_determine_rate(hw, req, divider->table, + PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, + divider->flags, prediv_value * div_value); + } + + return divider_determine_rate(hw, req, divider->table, + PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, + divider->flags); +} + static const struct clk_ops imx8m_clk_composite_divider_ops = { .recalc_rate = imx8m_clk_composite_divider_recalc_rate, .round_rate = imx8m_clk_composite_divider_round_rate, .set_rate = imx8m_clk_composite_divider_set_rate, + .determine_rate = imx8m_divider_determine_rate, }; static u8 imx8m_clk_composite_mux_get_parent(struct clk_hw *hw)