From patchwork Sun Feb 12 14:11:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 55915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1947604wrn; Sun, 12 Feb 2023 07:39:33 -0800 (PST) X-Google-Smtp-Source: AK7set8oGOMcVHOsuRwDXOMbAqxosadKxdhJc/SDnEHULSzmju+KHQZQGacLxUjACYPsUC9L3Ksm X-Received: by 2002:a50:f614:0:b0:4ab:d0e0:a64 with SMTP id c20-20020a50f614000000b004abd0e00a64mr7632003edn.19.1676216372906; Sun, 12 Feb 2023 07:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676216372; cv=none; d=google.com; s=arc-20160816; b=a2VMBVdjJJibno7kJsBLqF+MvMHutlzzSwc3fL+eKINDW3RVrd9tQIE+97BM9Gj9tg 1Gb51QkK4r73J+ib2UZEKlAB/WrifNF57gx7NwXGnFMJ6YPYpEhJnzOIbMYtzxaXD4oe +InNzyJCSha4R7l5B/Pq+e0SqglV8Q7Z/9Jx5yoBSytK7R0KtgSaon9XteXLpg0ltaqS X6buizVtfri4/s/pCJezLvIfcd7mzR0/ps/BoothYqRLFyc58WJPfg/gQbtkVARym0tT Jub5zNat464l0/FybOGPXq+DZtwyqn8VoMppFpiACbjUyFryQeVawHpVxfxaa6nQOeGs ZHFA== 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=kKpBwcSnbvzEKECCVGX7jc3WeeYHNW5T4I5cSv8N5Eo=; b=DmHIfMYfj2/OXJzXWRFxM6jm+5qhT8dHp2V6Ko0i7HPHvGPo10CM/784X8CrC+VzYl Zouftc8WIGbMfi2kRoZrjNFy7v65Ik6tTIaP9Hcm//TVxzERS9VKuqVFH11aY3KK4ZPD T0At6Te8oeQoLH+08lLgdk0lvBMvb1f1O9OdhMI/qM8GkNJAEZYsWq54I0hzo68qVE46 TXOP6rOb2Mgo3S/0CTGnLnuX0SJr7LHiuHQ4zLWiHB9/jHV+vNY1rmt5BRuhyUSaGOo9 LkiPGKLY0PZd60uJWKWFF3iWi3U5tEEXgDj3UkEst9u6KKxclKPfvRBTWlqTrvE5E1q+ THlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b=l4GcRgRT; 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 i20-20020aa7dd14000000b004acbeceab83si2325549edv.448.2023.02.12.07.39.04; Sun, 12 Feb 2023 07:39:32 -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=l4GcRgRT; 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 S229601AbjBLOLe (ORCPT + 99 others); Sun, 12 Feb 2023 09:11:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjBLOLc (ORCPT ); Sun, 12 Feb 2023 09:11:32 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF20BEFA6; Sun, 12 Feb 2023 06:11:31 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id E3777D38CE; Sun, 12 Feb 2023 14:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1676211090; bh=zgU9o39Da84lHLJi0IKg+G0/E6H+7pf3Yl35nbVnhXM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=l4GcRgRTaw5gtb36Y/l+6sEP23S71FBY0Nl34dDdZt928O1Jdt87HB8yqnXNPAm6z 43ShmMzd0wTZYz7sJCs/jUcXLSAdckLpXehdJGL4FblVF9K18jCex54TjNHJ3asF/9 6rx+sZpRD3CRxZ6c6ZRNZ6cHkVXEBHvKwD/0vGMU= From: Luca Weiss Date: Sun, 12 Feb 2023 15:11:08 +0100 Subject: [PATCH 1/2] clk: qcom: clk-krait: switch to .determine_rate MIME-Version: 1.0 Message-Id: <20230212-clk-qcom-determine_rate-v1-1-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=1744; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=zgU9o39Da84lHLJi0IKg+G0/E6H+7pf3Yl35nbVnhXM=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj6POPcdsS/gifaIu4UFZa8WGjK78dpkq1QvZwa 8ON314kV/uJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY+jzjwAKCRBy2EO4nU3X VtA2D/99YPIAtzECC44BWhqCo45QGJjoJ4lpLfbFdGVWFeF+7Fbc+L0x+OkkABTb7SJpM8I+Z18 Stqw5u9D9i00t9piOAC/DsMuwFWV0XkXLsGFZ68tk9RRvQ9FNJIBvUn+kgdge+yS7IWHhkwLM9f 4mkF9dHrDtX/77CfAe0LPW6npvSvHO589Qn2yHW6bYjAlS4hzmIs/xaHo9T7k7Js9vz0xozoMkU JcXh4nwtTF1Ik17YmWwYMTIuntHG48eCuX41J9MSh8AhftILIyVKkiITjn+WdD9/d0VSdoz7nRS 3P+ZPzajx7KZocYItw5XH2ywMfD24W3vKKG0yBIFAJfBWai0FFugTJv48SUn2tKWPH5AiV5cN5l VoGMpElwv0MH0EPNHqRiPNhMi1CkCuYUJZyioSdPSEsMgX03VxdMaiLTC7ZWBk7rjvqX3VElPYZ CW37nQyxle5X5+x6/+1gnISofaEghd5HSUCDmxGGYOHQAx6Yj5wUgyhClmuX5uLYsHJUj96ay89 YK6Gi2AAPWpxMz8SFhOjZXSZrF4HPUsuclC54eCwwS16V+ROrJPxSwGu0IWaoAhwlfumloOxFaX ENXdG7QuzKhCxW0xleWXsjEqFiIXp6ObMxHNZJwT7Ibo1LkygovQtV30vFeDxkaNQGT5Dl8mGV4 hKmrQS0EtwT/hhw== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1757640259439559681?= X-GMAIL-MSGID: =?utf-8?q?1757640259439559681?= .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-krait.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c index 293a9dfa7151..f5ce403e1e27 100644 --- a/drivers/clk/qcom/clk-krait.c +++ b/drivers/clk/qcom/clk-krait.c @@ -97,11 +97,11 @@ const struct clk_ops krait_mux_clk_ops = { EXPORT_SYMBOL_GPL(krait_mux_clk_ops); /* The divider can divide by 2, 4, 6 and 8. But we only really need div-2. */ -static long krait_div2_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static int krait_div2_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { - *parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), rate * 2); - return DIV_ROUND_UP(*parent_rate, 2); + req->best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), req->rate * 2); + req->rate = DIV_ROUND_UP(req->best_parent_rate, 2); + return 0; } static int krait_div2_set_rate(struct clk_hw *hw, unsigned long rate, @@ -142,7 +142,7 @@ krait_div2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) } const struct clk_ops krait_div2_clk_ops = { - .round_rate = krait_div2_round_rate, + .determine_rate = krait_div2_determine_rate, .set_rate = krait_div2_set_rate, .recalc_rate = krait_div2_recalc_rate, };