From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 784CB606A329 for ; Tue, 1 Dec 2026 13:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LgrAFJp/; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=URVXayNG 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ZG9Xp7iMHt8doSe8AqSbf4RZh8wo6AovvcZ7X4sjtTc=; b=LgrAFJp/eycLPiniPs2ZQSS6CE ciKEtX0D+TJkE4roemDGMzm63rd2DPjbsYCHqyb+HLq5FO3MAdbzYJwhxeLe3O1TEri5gAo7Nd/Bv OeDptqcnzdd4dBrMkl3ov+kU+5To0XmVDGrCegSw/C8ut2T27H2GpQZJlLrfBHX3F1iRUPpUTGiQk Y4WHmYV30ToReaqVhPB988WW52DLLRxek8FgkS3SLQQfutTkghGLEEjCKKuMJX2Bjny33QJ7NcRwW HzdnKjl+eP51IiZ6D66BcaVYa4TNmfD1+a6KCBhLaspDE7yUoJBLOHbb4zcQ4zJaGzfAN5mVBfmGr J2pvYYsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNiR-00000008D5P-3vOB; Tue, 01 Dec 2026 13:16:15 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNiO-00000008D49-1nlJ for linux-amlogic@lists.infradead.org; Tue, 01 Dec 2026 13:16:15 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4a35ac4475dso83685055e9.2 for ; Tue, 01 Dec 2026 05:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796130970; x=1796735770; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Oue6WrLNY+1atY0uh9AFbKFcmTMgvmyazSPVBJoBKBQ=; b=URVXayNGmEYyZul/rlod/JDkWgzDKuguHDD3GBB5hH8QeMHaw3F1JF4BJaR+bQiFLh QANZDt43aiO2A7/FRyJpNoKHlAdDFLkAs6rRHfr7pmQdoYtJbZGog56sxKjhcW9LAeLD aaLd02XpbExo0WRZCb0vMKUCuAhEQ2sUXwTDNM1Qc/jwnPtCZHUrvi7Qo7P3KaRHmkW9 iHK6pqi50HqyAGlya8vqJLSz1n5jmXg7RlEtpPGChXIjunJDEdDhgbdLnHeAuJ0HTcNs 3Jdq8szg35QVPDysAqREaJfusQ20HT1Nsqmi1BqMN49lYgRdoO6qgHyMzancSwWcpmmx Exmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796130970; x=1796735770; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Oue6WrLNY+1atY0uh9AFbKFcmTMgvmyaz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b sigu5pybrNxKq8V3/iFIJyxqTa1/Ox+9/ypg836Lwz9hSAf4W/TEH3NDciuXKym1WRWHhBKeNnW GGKaaMgNPfPoUIozvFmUaeyWgEKa0zUB3+OPw4cmb05/1TNn9SaIgXK61vRXbvy3tsCY/oG2uja Z3rZ2RYInzPLaVJxvk+M6PiOlm+zu24ulGqxh4xyvQnNR5lzEyyKqFEIAw7Pa+dHWaQvJdumI0y v361S883k6hk= X-Received: by 2002:a05:600c:19d0:b0:4bb:c483:ecaf with SMTP id 5b1f17b1804b1-4bbc483edc0mr131237525e9.4.1796130970401; Tue, 01 Dec 2026 05:16:10 -0800 (PST) Received: from macbook (host-95-246-144-141.retail.telecomitalia.it. [95.246.144.141]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884865a2sm1058738525e9.3.2026.12.01.05.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 05:16:09 -0800 (PST) Date: Tue, 1 Dec 2026 14:16:06 +0100 From: Carlo Caione To: jian.hu@amlogic.com Cc: Stephen Boyd , Brian Masney , Jerome Brunet , Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH RFC RFT v3 13/13] clk: meson: pll: Remove the dedicated n parameter Message-ID: References: <20261201-meson_refactor_n-v3-0-f85a4460fd80@amlogic.com> <20261201-meson_refactor_n-v3-13-f85a4460fd80@amlogic.com> X-Archived-By: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20261201-meson_refactor_n-v3-13-f85a4460fd80@amlogic.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_051612_492998_824B3306 X-CRM114-Status: GOOD ( 29.81 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, Dec 01, 2026 at 16:56:26 +0100, Jian Hu via B4 Relay wrote: > From: Jian Hu Hi Jian, > The Meson PLL framework models the PLL pre-divider (N) using a dedicated > field in struct meson_clk_pll_data. Since the common clock framework > already provides a generic divider implementation, there is no need to > keep PLL-specific support for it. > > Remove the dedicated n parameter from the framework and simplify the PLL > rate calculation accordingly. > > The parent rate is now negotiated on every rate request: the middle of the > multiplier range is tried first, then the boundary the computed multiplier > overflowed, and the request is rejected if the multiplier still does not fit. > > The PLL tables are arrays of struct pll_params_table entries, which only > carry a multiplier now that the pre-divider is gone. Replace them with > 0-terminated arrays of unsigned int. > > Signed-off-by: Jian Hu > --- > drivers/clk/meson/axg.c | 10 +- > drivers/clk/meson/clk-pll.c | 241 +++++++++++++++++++++++++------------------- > drivers/clk/meson/clk-pll.h | 14 +-- > drivers/clk/meson/g12a.c | 7 +- > drivers/clk/meson/meson8b.c | 58 ++--------- > 5 files changed, 150 insertions(+), 180 deletions(-) > [...] > + /* > + * The pre-divider is a regular clock now, so the parent rate must be > + * negotiated. Aim for the middle of the multiplier range first, so a > + * divider parent, which can only round down, still leaves the > + * multiplier within [m_min, m_max]. > + */ > + ret = meson_clk_get_pll_parent_rate(req, > + DIV_ROUND_UP(m_min + m_max, 2), > + &parent_rate, &m, pll); > if (ret) > return ret; > > - round = __pll_params_to_rate(req->best_parent_rate, m, n, 0, pll); > + /* Parent rounded too far: retry from the other end of the range */ > + if (m > m_max) > + ret = meson_clk_get_pll_parent_rate(req, m_min, &parent_rate, > + &m, pll); > + else if (!m || m < m_min) > + ret = meson_clk_get_pll_parent_rate(req, m_max, &parent_rate, > + &m, pll); > + if (ret) > + return ret; > + > + if (!m || m < m_min || m > m_max) > + return -EINVAL; > + Doesn't the m > m_max check prevent the upper clamp in meson_clk_get_pll_range() from doing its job? I'm asking this because on S7 GP0, a 4 GHz VCO request used to round to 3191999909 Hz while with this v3 I get -EINVAL on the board (I have a test for that since my work on S7). I think it also affects the output divider because comparing the callbacks in software an 800 MHz request used to give 797999978 Hz but now rounds to 0. The /1 and /2 candidates need a VCO below its minimum and /4 asks for 3.2 GHz which previously got clamped. With this v3 none of the candidates work and the same happens at 400 and 1600 MHz. In theory (and on my tests on S7) dropping just m > m_max restores the old results in the fixed-parent cases I checked. I'd keep the lower check because removing it makes an S7 GP0 VCO request of 1 GHz succeed at 1608 MHz whereas it used to fail. > + /* > + * -ENODATA only means the multiplier was clamped to one of the range > + * boundaries, which is a usable setting. > + */ > + ret = meson_clk_get_pll_mult(req->rate, parent_rate, &m, pll); > + if (ret && ret != -ENODATA) > + return ret; > + > + req->best_parent_rate = parent_rate; > + round = __pll_params_to_rate(parent_rate, m, 0, pll); > > if (!MESON_PARM_APPLICABLE(&pll->frac) || req->rate == round) { > req->rate = round; > @@ -270,8 +305,8 @@ static int meson_clk_pll_determine_rate(struct clk_hw *hw, > * The rate provided by the setting is not an exact match, let's > * try to improve the result using the fractional parameter > */ > - frac = __pll_params_with_frac(req->rate, req->best_parent_rate, m, n, pll); > - req->rate = __pll_params_to_rate(req->best_parent_rate, m, n, frac, pll); > + frac = __pll_params_with_frac(req->rate, parent_rate, m, pll); > + req->rate = __pll_params_to_rate(parent_rate, m, frac, pll); > > return 0; > } Ciao, -- Carlo Caione _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic