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 CE271606A31A for ; Tue, 1 Dec 2026 13:16:26 +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=zCNicSRr; dkim=pass (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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Oue6WrLNY+1atY0uh9AFbKFcmTMgvmyazSPVBJoBKBQ=; b=zCNicSRr1FUG6uZKvoyU1H/otK WUOsnhQSSzZJ51MDdWZ7eNt6U4GktYYNoB4+cZYlXBSApHdsfzO89zHN/l26yDLMICJMvEv72ZqAf WZw5Csb/5odbBEM2afqIplGHIuOJBl9KTaiSlNeFbEVDrW85gh3OodsbMf4ariUVqfcVhTIDmGjXK 7VObWKIBU+QIjX8LX9t0jWCdHm+pzPDeE7s8P3El/hG8DCpFR8bFJQnkMV9hAJGmsiHX8yrF67RUX 5aSMsT8dmo0TY6b3d6nN3+cT26WwLyDptqxQk0YAJqN5zwTJ7PXGVf/QxN2RbxsmMrGOYA6ojU9Z2 obSzp7UA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNiR-00000008D5B-3Vyg; Tue, 01 Dec 2026 13:16:15 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNiO-00000008D48-1npS for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 13:16:14 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4bb72b44a97so102057235e9.0 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+1atY0uh9AFbKFcmTMgvmyazSPVBJoBK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E0OxSMZbLXNXgnvOLaDrT5egYfzOvzdjj5qExmuXs2pZJK71oP+nP6KYmt8KBrhG AIkE6GvufbJmWzzHQqZ8Xq5tIPTTCwPedewt2WQjPviL01Zn6zmHVbVSfIYhpskwrtXOp9JU0Et EgOqmTb9YGNPLvOGQEhCbwb3mvLWRaj6nRYSbx6xdCgQ7osuRLcpKPQBXaQuj/qJ6kq1bpitKNc 5/J6JUacmpDo= 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-Type: text/plain; charset=us-ascii 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_492929_AFCAE9E4 X-CRM114-Status: GOOD ( 31.41 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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