From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796130973; b=pIKnatgUrDEIjROkSU549the3OOROw7mgJB9mnwSoMjznJp7/kl9Lj0q0NQ4oDWtz6Q3 ZbgKvnvBVyScL3fyGgwU1mdJEmoBk2Hzu/TOurr90G1God4xzzUPe898LdQqFCFV+p7Mp DB/boBKkcnvvOnT0YcRD/6qGkX0b8u3J4LlQnd06KqJxNh1DmMUQwUudhGeBtfg8lqCN5 9Exnk9yD4PzbedYGAI/bVAQpas6U3yJhIil+Zv9GSYeIsa7jyM6vIG7OyxTjQqKVJcelx 1PqqVG9nHNfP31ciDQVQxvFiYylQw90BsgGyq6aSolNWTr6GGtDe/Nj0nhM4DXmyPxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130973; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=Oue6WrLNY+1atY0uh9AFbKFcmTMgvmyazSPVBJoBKBQ=; b=xhcHfRjsbBdBjluM1QBDO+32OhCoEqtfQC5mw0f+UeO9R8mzduNmSItdAR1UXPSkfR3e rX0ImoyNB5+FfcQCtlKvuhNtvFv0NZHlHe2Aq0QZjVnm3za12j8qGErUc7kYFlDBOJrD9 vOUAcBq9eTfoCcJydD7hlt5COfFOd6Xze/zA+jxQvmELfkU4WlEjHpvQq2aDpS0Qm9J2S ZiEgdv0yyio7x+kMne3igIzLyIOUHjsAQ9CJAxho71zbfAVKO0Hn9LuhNg55NrxWK7qPu 73Rv3DC4HrC5R5u8wOue8Wf9LkOh6IfKUol2Cs1hZmUFwMO0yAioNBOGL1DbblbTrpg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=XKshC+NE; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 158A0606A320 for ; Tue, 1 Dec 2026 13:16:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 158A0606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=XKshC+NE Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso118223045e9.1 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=vger.kernel.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=XKshC+NEGtdo3RV4ME0wjwxtE2IgsmNAIUbF+lagGqJaxT9uFzq1zntDl6c5YvXj6h QBMOPfQa47oCCe9hpPxGT48388mIAmVBxwAV0nEtEgPnQUMUpIKZmEs381D+gZ+uMPul mn9pM+gVCkcQD5N+DF1wttl8kz4DbduG04Yhr/nsJGtAVeglmqnSev6Of/dgUAkLrhUU NChbOkkcCZ/LdN7rxBPkpKe1AjH22d/0kbVEceIPFkU6GPJYMJlGgF7ANV3z6v2QkXgc t8NXUGKvUzaRsRjDAPY2gtvLicdQY6eDQJqfKP6RoeXHFak5JbokK/fJ9Cq/6a9CM/hh e1Mw== 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+1atY0uh9AFbKFcmTMgvmyazSPVBJoBKBQ=; b=bwKDEdTr1igHXMtz/IuNU2KveUa5o0QFTOhdvviP2bTGu7qGPaaXaqeh6ageoxS+/p TAIIzQ8uPscWsgXG3meqhQBZnTZGsGMyjzbdbC6MMJVyS1/vez1OjVjPQ5e5rP92awv+ 0QiKCGpeeQbf0a01qoxkw4dVucNdzMzjetfxIjkbIQZQtrQALp1Us6XBDXWrlr7XTjuC U9kIlyEZnphMpA1L3gpZEnLxd3bv/Hq6l1Bw+pZHrJQPUNvsUp9MGSiurYTN5XLHBnm5 iXw+P75p02DOOSP9R9vjNTjn399FJHP5XewZotDZdj4tDtVcd+X3H1UijsrnLExTGJQi Yp4g== X-Forwarded-Encrypted: i=1; AL+hErGoEImpSzfhr9H6iN4nmOswlxkHa+jVPD89DogkD6bjJUWze5PioKxg7hOtE/eh+HQu0sW98APQrd8=@vger.kernel.org X-Gm-Message-State: APuU4Z/ZZMUtfBlJsKtSSYu7d1uVDvElNvkhX8DrX9fdpAUtd4kh96b2 AuHtpFCRrL5nf+NtzicL/0yeDJgVhhog1ZjPC6o/FpUgHBAnWpUc/ALFzl46OgFaaBE= X-Gm-Gg: AZFdTZfNuZwGiWqgVj3c4I8hS/Hj9gDHCXuWbvSOhAjsiIb3dFnyugWUXFy847TpLxM tFXJ4PEOJhbt69+joh44z1kawGqlEpX3gyjvliwwBAU/T1GSVRhFePPTmZLf1urQyZVHLb5bx9i oqDg+pIRbIc1VCMqv974t5macgdnuT/HGGh2Jd0pnuEL0eGQHMtOs9c6XxRFr34xLSGFmmzZRdf GmNsDuVgum9xKjWjNg1m41GgMMnGYFxEDnjw5JA0xWD3vfpZT/a2eTYYCY0do9XH5MrCVGLjXIz K7CsyvP6uSKIu6Y5khSXKP3NnCyx9xLrgSuCSwDRCXZMVOFXNb6wAUgCw5RVFir7sB1XNLgpzBK h3tIcuP91Ny2jGc3BF+YuilQqwD0v2ShsDtWkrDUNWchNt+ptUJixmk5/iB8dcegyviWRdtrrNp B6vUXOy9mWt7qYjlHgIqVJqqyY147W1s+H2vQnKTNSfs7Qc9GLmqgLVNFmtWkjA+2rCsJ5czWw7 +ebUaGCT2Z24J3wYEqlR060dSK98h6BK5TJVguv3G2yEkVtsEVoZUrTwrylCws77dxDzXV2vYnF mvbZCl2eoEmNnc0O/eKHgYiuhe8dTBRENpP/TEwcIHKpy7xb9E6d94sJvEJRwYa+qOxyjvvfy8E pBVQ5NbHJQEA= 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-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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> 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