From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 04 Dec 2026 14:04:18 +0100 Received: from mx1.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::107]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xZSxW-006E9A-0G for lore@lore.pengutronix.de; Fri, 04 Dec 2026 14:04:18 +0100 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPS id 3DEB520285B for ; Fri, 04 Dec 2026 14:04:17 +0100 (CET) Authentication-Results: mx1.white.stw.pengutronix.de; dkim=pass header.d=lists.infradead.org header.s=bombadil.20210309 header.b=Y+DOYY3f; dkim=pass header.d=gmail.com header.s=20260707 header.b=hbIyuOF8; spf=pass (mx1.white.stw.pengutronix.de: domain of "barebox-bounces+lore=pengutronix.de@lists.infradead.org" designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="barebox-bounces+lore=pengutronix.de@lists.infradead.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796389457; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=1gm8SkpXhvRgf+ZWOceaM3ZXrMDFyidG1iaqUDBJkvU=; b=Z8FMVpVRgsV3O06FUlfD0lUertgHc5O2IZQH1jKqmK8r/1YuapiBCXbm++fWqsRcQp1srB x5iTa0OEct1gO996N83NR+mGFMLxMRhuVuAKNzy84b+DFfUJY5ylArts0g19YekQqLBXXy X6iJ+uo19JzgFjxl/30N1rVIU4TEWGyITglvTOcyxaovCg8ksKmnxBO5O2RX7mWrZOFbz5 D/ffzh7xUr89yAsVRll8bSlP05XScmmv1k45kV9rJSV2e91cS9zrHU0a39mDy8XzVYpbWO QKyDCxFmdvXRUagZUf+k2UH9ZLgT/P9KVTkuwBhBLM1hCzEw7dFcTeoIykv1PQ== ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796389457; a=rsa-sha256; cv=none; b=BZ5bmDKWnnWxrvp/RduKDIOhsIJMW1LoI1j6Uoq7qvX9hy8WctyNR49RgKrfkgollJuYF9 LFn5nJmu6E6e2z6c8mi8+3L76a6hUt10ycab07iLJMaBHWnCs+o6niOCdbNCV4bdarUvsM PMHuBfK/BmWiBLIxscs/xRwtBnBOoxzWvyO0Xqw7PZ8z0fPp8TpcwlRGKD2D3rquQkOqlY Wzybm8DcMykOdApHTAcY5PLIIyifTiekh1pK7QZdM9dQWu9VKyjgToGQv2jOia/HiiXsdw ADgTTmCH/3RrDIIS30n9y1K9owX1uuDWusuJBtndNKq2oDiqTBi6rExn+gCO1g== ARC-Authentication-Results: i=1; mx1.white.stw.pengutronix.de; dkim=pass header.d=lists.infradead.org header.s=bombadil.20210309 header.b=Y+DOYY3f; dkim=pass header.d=gmail.com header.s=20260707 header.b=hbIyuOF8; spf=pass (mx1.white.stw.pengutronix.de: domain of "barebox-bounces+lore=pengutronix.de@lists.infradead.org" designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="barebox-bounces+lore=pengutronix.de@lists.infradead.org"; dmarc=pass (policy=none) header.from=gmail.com 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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=1gm8SkpXhvRgf+ZWOceaM3ZXrMDFyidG1iaqUDBJkvU=; b=Y+DOYY3fMrrRB8 zLiLsmK5PB5jin+InqZmWztGzq6H1oThA9FM95KYzV/7SUeHzJ5M7wD8wpm+90t8NaV28IhqeJ6Cc XlMqhlDKuZjRUBnrwAqqhIqMNkoiqQTp7RQ2vPVlFrwoGHu9MW3HmbWDd4Bl9LDjQm0zmJjt42m+8 WVeKBjlGLhca0ETBWm0zvqcVfwOlNW09+RD7qbmRecp1bwWiMl898ErAN4oiyFc/Q4uq31KRUki6m Fgax3WZYVCfsAPVSyrjy2fiY1/Zgu/rG8uP2WPvdYuclIzv3VtptEaLh8HfJsSYC5DtNzeA+J+q5f EqcPyoLCHCAAbymfteXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZSVo-00000000ICh-27Wh; Fri, 04 Dec 2026 12:35:40 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZSVU-00000000IBK-3YdF for barebox@lists.infradead.org; Fri, 04 Dec 2026 12:35:22 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5c378567fefso546982e87.2 for ; Fri, 04 Dec 2026 04:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796387719; x=1796992519; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1gm8SkpXhvRgf+ZWOceaM3ZXrMDFyidG1iaqUDBJkvU=; b=hbIyuOF8pZk6Ahn15O0Hm16L/deBXlMw0uPD6OLQjOjI9qMEjNJF+HLDp2AFub8qZT QC3Q7joe/azyee5PD0i2Ip0G+bbVXx23CDIRZU0gj7l0db2uqXedcAIclN60cx4rado5 OS6ku0YtVk00AIX6/o2QUNZzwPX9GSkrw3mO4XKhzl+aSW7TXq4c/Onysjo1AcmCvnS6 FyR2RwHQ1hzXowyHyRujjbN14+jQTjrlZo/8aDRunV93+nSSPSMx0cja3aJf5yzT3yMy UbJBbWfO3gnt0WNFzhMzBe7JmlP51ncbJ0RXV/qro80/4ZBeTCf5+mbvLpbQtItxTyeo q5ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796387719; x=1796992519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1gm8SkpXhvRgf+ZWOceaM3ZXrMDFyidG1iaqUDBJkvU=; b=gqxtGvbRNnjLXPlWlblf3dXxw0M2ukRI6FatzA7jT66GBiTobOfdyZdCUw6CPOya5a 500UiSv2XIm77Fga4Iq70sN5aw2TSVXbKLsiHpLdOFQ7dnN79nCMpMmSpZPWDQL0llGU MBIxHkRex/iKstF4WAo3gjjXDJdEk68cJrBDBbxPpTzqnck5NId0JvAPJ2KobABzAZS+ d6D4fm6eg3HnUYb10MLdWT2P0Q6ya8f3tGhOOOAIe77yrXJqlbok85OIY78iwEnOOeHM y1hQy4W7GGwnwIcu7FQmueQDkzpaNZ6MHzBKt1F2IiAnCyWfjT0iKuy+qZytI3n7Lun5 CioQ== X-Gm-Message-State: APuU4Z+PvZWRtJg10uKYCPNBGUzV4OBfPP6TQYqabv+xOcbmp6X45Tsm oMc+u/P7774GtjvCk/FVgOVzzWnQqxL9IJoFbVY2Bz2BXaoGrDu+zK03g+Bxfwow X-Gm-Gg: AZFdTZeYxX1tkmIeG7W1dMXTaY6P25hXxBB+wO2ZgIOp2oj9gQUR98VrlGy8q+XnxXl CZvcqUW+Nk1Ijv4o386R/7f1Cenq7QHjWzMmqeknQEFg+1B3VCt/haMuyA8jUOxPr76ZSIYBI9L KizVFHe51Pht0HJmm5aqVS31o0mCq3bROrEO616obTMaIECFL25ZEy/JJ6XJgE1aP58ZS+Rj4oZ djIKU8nPtyOUJxgMKjzB6o1Ws0a6T41454jarat+SX/ZYqadJXCyzOzZVPEyNZ/WrnPEqn0TOoS E7+LaBR2PQ3666QUdQ0wWBL/oBRXuV9xfisnXHBsKj7Uj3Sw1AMZ3D63gIuNxyyAAiYnVG3Uahv 5Hz6tt5cjIQcIH4vwCkG+IU/9nVnE55R1G2M+Aqju2VKmxOtJ0j74BhF7pEJRHCl8EMDR0BCp4M nRWYiAOYXwE26hCgNW1VOKyMXDs6JQPRcM060nRy0/My+oMMQ/KFNTa+6SCYkGMo+fZ7pGg3Dz1 m2Mt/TfggmV6HD0pQJgzP8jj+XxRTPNvEqmHt/k5s7f0Vu+Tqjh2nDBacCJFV9cnK64Oyrmvs48 ffE50hgaeJaxYbU60XpnyMibuEoChzw7rQ== X-Received: by 2002:a05:6512:2c92:b0:5c1:4974:c150 with SMTP id 2adb3069b0e04-5c3861a23e8mr451338e87.51.1796387718585; Fri, 04 Dec 2026 04:35:18 -0800 (PST) Received: from gentoo ([95.161.223.236]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c384aa2ad1sm583268e87.64.2026.12.04.04.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 04:35:17 -0800 (PST) From: Alexander Shiyan To: barebox@lists.infradead.org Cc: Alexander Shiyan Subject: [PATCH 2/4] clk: rockchip: Treat fractional PLL coefficient as two's complement Date: Fri, 4 Dec 2026 15:34:56 +0300 Message-ID: <20261204123458.3787582-3-eagle.alexander923@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204123458.3787582-1-eagle.alexander923@gmail.com> References: <20261204123458.3787582-1-eagle.alexander923@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_043520_913027_2C87DCB5 X-CRM114-Status: GOOD ( 13.41 ) X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The fractional PLL coefficient k is a 16-bit two's complement value, but it was declared as unsigned. Negative coefficients were therefore impossible to express and recalculated rates were off by Fin [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [eagle.alexander923(at)gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [eagle.alexander923(at)gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:130 listed in] [list.dnswl.org] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-Spamd-Result: default: False [-11.41 / 15.00]; KNOWN_LIST_ID(-5.00)[barebox.lists.infradead.org]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_MED(-2.00)[infradead.org:dkim]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+mx:c]; R_DKIM_ALLOW(-0.20)[lists.infradead.org:s=bombadil.20210309,gmail.com:s=20260707]; MAILLIST(-0.20)[mailman]; RCVD_IN_DNSWL_MED(-0.20)[2607:7c80:54:3::133:from]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; RECEIVED_HELO_LOCALHOST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[barebox@lists.infradead.org]; TO_DN_SOME(0.00)[]; ARC_SIGNED(0.00)[pengutronix.de:s=20260414:i=1]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; FREEMAIL_FROM(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; FORGED_SENDER_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[95.161.223.236:received]; TAGGED_FROM(0.00)[lore=pengutronix.de]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:7247, ipnet:2607:7c80:54::/48, country:US]; FROM_NEQ_ENVFROM(0.00)[eaglealexander923@gmail.com,barebox-bounces@lists.infradead.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::130:received]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; DKIM_TRACE(0.00)[lists.infradead.org:+,gmail.com:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 3DEB520285B X-Rspamd-Server: mx1 X-Stat-Signature: at4hqf96u4j6pxds9xo6ithn3f93bos6 The fractional PLL coefficient k is a 16-bit two's complement value, but it was declared as unsigned. Negative coefficients were therefore impossible to express and recalculated rates were off by Fin / (p * 2^s) whenever k was meant to be negative. Declare k as s16 and do the fractional rate arithmetic signed. Fractional PLL rates are not used by any current consumers, so this is a correctness fix that matters for DisplayPort output once it is supported. Ported from Linux commit 581478883477 ("clk: rockchip: Fractional PLL coefficient on RK3588/RK3576 is two's complement"), with the rate table updates split into the following patch. Fixes: 9bc05092e9b3 ("clk: rockchip: Add rk3588 support") Signed-off-by: Alexander Shiyan --- drivers/clk/rockchip/clk-pll.c | 5 ++--- drivers/clk/rockchip/clk.h | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index f07c71462a..1268ec0589 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -916,11 +916,10 @@ static unsigned long rockchip_rk3588_pll_recalc_rate(struct clk_hw *hw, unsigned if (cur.k) { /* fractional mode */ - u64 frac_rate64 = prate * cur.k; + s64 frac_rate64 = (s64)prate * cur.k; postdiv = cur.p * 65536; - do_div(frac_rate64, postdiv); - rate64 += frac_rate64; + rate64 += div_s64(frac_rate64, postdiv); } rate64 = rate64 >> cur.s; diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h index a56a42aaf5..d0e4870acb 100644 --- a/drivers/clk/rockchip/clk.h +++ b/drivers/clk/rockchip/clk.h @@ -589,10 +589,10 @@ struct rockchip_pll_rate_table { }; struct { /* for RK3588 */ - unsigned int m; - unsigned int p; - unsigned int s; - unsigned int k; + unsigned int m; /* main divider, 10 bit unsigned */ + unsigned int p; /* pre-divider, 6 bit unsigned */ + unsigned int s; /* scaler, 3 bit unsigned */ + s16 k; /* fractional part, 16 bit two's complement */ }; }; }; -- 2.56.1