From patchwork Sun Feb 12 14:11:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 55913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1930896wrn; Sun, 12 Feb 2023 06:54:39 -0800 (PST) X-Google-Smtp-Source: AK7set/ix0xLDKqnp5ujLzVVpfgnTwtSP86pvfJP5/IZPFoyVlEuEpFHP1qGC1G94lhkP1EDMcvR X-Received: by 2002:a17:907:1b08:b0:8af:5752:26e4 with SMTP id mp8-20020a1709071b0800b008af575226e4mr10170587ejc.68.1676213678854; Sun, 12 Feb 2023 06:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676213678; cv=none; d=google.com; s=arc-20160816; b=pwqdf5JILxtBWRfqrNAP0ylWE63SCokxZnLwQ5atVvFl9XvkAlWAVA5YqunPc5ETzs wJwn1a8nYwU5xT6jGYdDhkrq5kU3ii/Q2dM87uGTmwHkD/EmmZisOIYxBKdFH+SESMhd +AjYDsuHJVJamYPxcrdeb1LU0smjHUNII2rfr8KXlCVFx8JA75f0Cb09zh8feYcVstzT kyIQw6aTIvfA45uFW3nraHGrVrbLPie/KyALGwXbC/EOS4qyHPmBAn+NpScjFzebva9w 1WWEsgTTM4E0GX2kYc/4My/xMOCr1cxMP1QUFK9Z+d9uVgmTSf4gYc4B5SNZcEoW6zvh GhnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=l7UOl4NYk9B7qVNddOU8MEoSC7g2f7fPGFeV4m2K3jw=; b=uxZzm/jKHzry3ahQN7TXlokqsq3BHgBVeO46XO0Y78e0Yk6g3XP6SLd/y1lISxZxA8 BVtV4fPODHDdRpVR0MU/D+ie25sqn4jFj5Cm4irUtuz+jzj5RoO9mwelHZYSgYZPQOTG w2/vsKHB5n3vMPTCTSut075c3JcNbzqXxIg1+rdYNmVOmucE0ekd5/nB3+KYFdT76UAl UcLQdwK/uC3POKWqmPK1VGHsZYBv2h3R3kkZiy1rQoSILsq45NrG+6H97X9TS/GdzxL4 5DNjwetCGFO8Cfe5DtPdUMD5xthnAjgxJ+lW8ZA/uugmqo/1ihmscKb3rhh3ZHVqh9pD kQag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b="HC5VzDU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oh10-20020a17090784ca00b0088a6700e203si9502372ejc.128.2023.02.12.06.54.09; Sun, 12 Feb 2023 06:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b="HC5VzDU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjBLOMG (ORCPT + 99 others); Sun, 12 Feb 2023 09:12:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjBLOMC (ORCPT ); Sun, 12 Feb 2023 09:12:02 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056B6F77D; Sun, 12 Feb 2023 06:12:02 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 3BA1DD38CF; Sun, 12 Feb 2023 14:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1676211090; bh=qFK6KiGkL2Ya37v4r7g08gVdvQ3WQ3Zqy1iFF42jPdE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HC5VzDU/7oVhktaUl5K/8a0J1ijbpNVD36QUZjlqGNHwGD5jKpZujIwxf1Bm3V+Xu GsF/PYnLzj0JrFvC4NC6wGuSi60h48B5/brIGiOhitoBxifK911M4jgenPxFp/jabf t+mcd1cC4pC0WiAL9t5FyqGwG3YzGAFprjPoCMe4= From: Luca Weiss Date: Sun, 12 Feb 2023 15:11:09 +0100 Subject: [PATCH 2/2] clk: qcom: clk-hfpll: switch to .determine_rate MIME-Version: 1.0 Message-Id: <20230212-clk-qcom-determine_rate-v1-2-b4e447d4926e@z3ntu.xyz> References: <20230212-clk-qcom-determine_rate-v1-0-b4e447d4926e@z3ntu.xyz> In-Reply-To: <20230212-clk-qcom-determine_rate-v1-0-b4e447d4926e@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Bjorn Andersson , Andy Gross , Konrad Dybcio , Michael Turquette , Stephen Boyd , Christian Marangi Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1899; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=qFK6KiGkL2Ya37v4r7g08gVdvQ3WQ3Zqy1iFF42jPdE=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj6POQHw2eHpO2tucbsPLIsE0wWtIoMbeD9jIxo SytZgYbKcOJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY+jzkAAKCRBy2EO4nU3X Vi4rD/9aHBRishQyFuZrmzfeCFOYgln9UKcBbsJrygK4Vbwnqb4xslopUl9KlyBR58kEWbD0Xc/ RKvsoc9Szll8iLmYrEvsiJsLTiDHwqQFXjvyq54Sawq7W40gTPKeI4ziM0SPr5TBrDpEVT+1aDj FMbOXk0KpnkFdCcnxvmz6kYx/Q47Afqnd73nwJsIqd64CEZhPtSzKbIXOuOgkRZiY8BzCsYSHA4 hmguo8kbjK86zg3qia6SEPKX0QnwuV+fL1LCLhk2RORfA0zA0BU2h8xkJt0JVRYTvw5xOscoOES Xniy6uLAWFETt9e5kr5npADuAJYGjYWHcc22nc9a0To5vR+EnqwR9ipLW8TCC3ol0V5H1ueyWyX 7itGwlOR9WKAJgwAKvlUUHZN4hu1+XMkDu53gFPXl0zJLUcr4mt9Zz7iEouhqykV+lK347Y0gFZ +Zm83dRyrn6PmHg2pMgJP/eusBBOwWeREVPz3qurX2QRXcMKS1Fpr7KDWACeTa8xX1H/CVD9AVq c9ALLqnTW5SyUfPNuuc8bKFYWQPGxfteAAgEmfFmFyapK4Av+UNO8r7IJiT3YCOCsgrK2LUA1Hw s2WIT5czzWQqvIzHbtWyqNuA3g5YBEnxoUW8vOdQkkshCVUfPyfaS8szTNerLFtAzt6Xbv9+A2I c05/x4oM7rXP0Nw== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757637434545342877?= X-GMAIL-MSGID: =?utf-8?q?1757637434545342877?= .determine_rate is meant to replace .round_rate. The former comes with a benefit which is especially relevant on 32-bit systems: since .determine_rate uses an "unsigned long" (compared to a "signed long" which is used by .round_rate) the maximum value on 32-bit systems increases from 2^31 (or approx. 2.14GHz) to 2^32 (or approx. 4.29GHz). Signed-off-by: Luca Weiss Tested-by: Christian Marangi --- drivers/clk/qcom/clk-hfpll.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/clk/qcom/clk-hfpll.c b/drivers/clk/qcom/clk-hfpll.c index 7dd17c184b69..86f728dc69e5 100644 --- a/drivers/clk/qcom/clk-hfpll.c +++ b/drivers/clk/qcom/clk-hfpll.c @@ -128,20 +128,20 @@ static void clk_hfpll_disable(struct clk_hw *hw) spin_unlock_irqrestore(&h->lock, flags); } -static long clk_hfpll_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static int clk_hfpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { struct clk_hfpll *h = to_clk_hfpll(hw); struct hfpll_data const *hd = h->d; unsigned long rrate; - rate = clamp(rate, hd->min_rate, hd->max_rate); + req->rate = clamp(req->rate, hd->min_rate, hd->max_rate); - rrate = DIV_ROUND_UP(rate, *parent_rate) * *parent_rate; + rrate = DIV_ROUND_UP(req->rate, req->best_parent_rate) * req->best_parent_rate; if (rrate > hd->max_rate) - rrate -= *parent_rate; + rrate -= req->best_parent_rate; - return rrate; + req->rate = rrate; + return 0; } /* @@ -241,7 +241,7 @@ const struct clk_ops clk_ops_hfpll = { .enable = clk_hfpll_enable, .disable = clk_hfpll_disable, .is_enabled = hfpll_is_enabled, - .round_rate = clk_hfpll_round_rate, + .determine_rate = clk_hfpll_determine_rate, .set_rate = clk_hfpll_set_rate, .recalc_rate = clk_hfpll_recalc_rate, .init = clk_hfpll_init,