From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796130973; b=MDokWhfrEufombltoA2fhuM8zeQmnqtJ3cpDcGVDyMeYaHXi1ZkTCqwSfk17UP8KAqgb 9kPo1sWw9I2QfS9isvAwU+3olfG596cFnamMVlChk2hzMOs73mCMCmT2cWtXTS6NdhGYJ PzeoTTfQHgUDQ+qLcePj+0X8/C/fB0k/Px6OspjXLIBkIp1JtnaPFGoKE7iR7nfoafQWi 3BzJuPWLJVw3qys31bZe395W6UuL1vYxWD3J/d/1TzaBJfpFoR2CegOi8Wpyg/xenUagU GtOB26vH3r7GOdjVLcM4jmnJwRWRBThwtq/x6a79a49NGpvorfYsA/l6pulEPI+HPwg== 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=3e2/b2XwLikMePtCR3e02opIwiWxyem66Rtn1WyxpXzJKVjv5w4HFaMwMr7b0gLoPtNt Lm7mSmkTrq/T7q+MO58V4DD2R2el1jtwbksHerwuxGSZ0HsoCREmzz1EwKennyLcU1XTG FRfmj5q6OQpjwijYZxzp1wjQT6wA2YTNPzf5u3Fd8h7rbok0jU9JGJDjEs/L9CWRE6rYw 2DK9mILzrLCKomlTxLIXtJ0KBGyv0K1XP3VVBR51a15aoHK0eK9Rjhx64pPo3IzWb+HmQ yAqa4xJhQ4pOjWRMLmrDGVYJWvYcHv+XyVwFXIe88cgHGKnU4oSM+BMmo1SID3tj0ug== 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.48 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 6DC6A606A327 for ; Tue, 1 Dec 2026 13:16:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6DC6A606A327 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-f48.google.com with SMTP id 5b1f17b1804b1-4bb72b44a97so102057245e9.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=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=lvuhQGIO9zmJDC0aAIago8GdGoSlanmxIMKJXiwVVqIBrlx72huXklel1PGsmuO0+b gr38krUb+0BTmU54LS/yydyWfwZrVetaXMBUB12T+TbZiaOrvRY9HgoHV0N28PaKueOR vpdXxA3xKUK13p8cIbKFFOzhTpq1aruahYOstfmmTwNxpV+xI2Af1CSBtBmZDPMrZLaB 3Db6bRXJU8kR6QiDX2Mcoh9CBaOojX9gPu8TtHxecm5mlCGHde3hVgH6xtpZcIZaKkTT 4JsJRTAjEbquPpNvvh6y0qVp0tcK38Y4Jvx4vvRNK6h/DFel6jiBhf8zpfmAR9f36lvu ShZA== X-Forwarded-Encrypted: i=1; AL+hErHOXgAlpDwk/rA7lddVs6yvHvmk3yXPBoez9mZz61aYqL6OgIRQkydDXneZpjKoEg+baGL4HM08VISjxJg=@vger.kernel.org X-Gm-Message-State: APuU4Z90mwh3HQtm2kuLD6eOvxEuUHCJVQqF2f+n80eRZEO+J07ZmWYG B1HUvgibrJlhoghXX4x7F1Gh+qrO5gspVH7Rd4jRyL/iYor7tHQabPEWYqIhPbB5lxY= X-Gm-Gg: AZFdTZcW6fQUZ8Z2924n5S325KLNXf1BSH2zBkIzyRH2xiypOUQn50Qi3IBIVIMReZ3 cZ4tM4QIQXvgRfmEmExLsyTaN/oyWFhfDiEIdryjpAyKtucQ+FYcjElCOflBlKo74tezJX/NevM vhL7JX+b8uHloaQkTKM95h/0Gyxe1qFXEJjXZawh50dVZ8R/zeE7DlEQDAOjfgol1F+ZQRncD4B +APHq0hMnOJJAy4+QSkJ1u+dXiQbZSJlFtvLzFgHvdPtK4FIKM9eMZsNssMq8SAH0qrFcPiatJs OhQZUeAYAFkvBAKG+ZItVOOepAOcjctKudqqT/3X2D7K+j3HHVwc8Tx8vEmu1tLHr1tJ4DiMWeA U7Frt1HiW22BvaeHcxyndjvqK93Iy81DD2Kbursik7hURVW04TYs5ogWSJu5Ip/ny2jqumjBeE3 NXZ66AFCjlRHpa3GgbaO59ZwZcyaY3GFOGmGtdSvr2RvD98yuuNCQXqizTM3UUno4CgDy+HG1q/ 4lztOCRrymXFgxT+u8TTsGWk6tXperocsHqoTd4SEQM5A3nzIrBruIaDcI1/RCzaFpyga3LX6nN VTaw7MF0scR7RrhvWeyOu/k9M7B2XSzOlYCnqtXwwiwc361Fv1ns0eLnFHupfUoUloNoRefhOeW mj4Wn7n3lXnQ= 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-kernel@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