From patchwork Sun Sep 17 22:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9DA4CD37B4 for ; Sun, 17 Sep 2023 22:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EDR9vLM/2IEe2GsmOAJBY2f/Squcr/GeJCPET+rOX4w=; b=uQFSeMgGpcn81q w6TShRJygxJc2Yoy/b2fpozaS8Sc4iKl8OT0o1etPoS3xOPRUOg7sO947zwesijCXLyqDlQzAKprz 4ki9V0o1LSoiyl822nmyRIkVg1jZ6/ojJPywv4VlfMbpB1kTaDE3eYB3N8ZqbIbBZSPugiYSqMtYC 1ycYuMYP1fMOIVIOYnL1Mus2DXNCozASR9MkfdyuVtqJa8H0EaY85R6Qv6t/iOFqPHit+fFj2ZvpK zA2ynQEiegVj2oEvw9j6mLX/LlinuIPsdYwPoU24gZUb/a7yWB/XpPysyQXLbFPfiymokfOs3sj1T zJoY4u4tri49BXmyD3ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0Rb-00E54X-1j; Sun, 17 Sep 2023 22:40:47 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RU-00E4zB-07 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:42 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31dcf18f9e2so3774721f8f.0 for ; Sun, 17 Sep 2023 15:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990438; x=1695595238; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hHjjAyqptO8IMOlepeu6XUuPt7GkOQwtq9aZ8x05FNg=; b=LCv/ge62sNkcVul0H2Hw12FIQQqUH5Uy5reDJItIoTd5buHt5N52Dmjc6DbRevo7ln ZCVvsiONaACdq+qg8njHhaAaSohSx3gNUcPFyJ7aruDlj0LSQcyW6vz3IE82VMAKqM8k 9FeB5hY0E3v/gGVo8dXwHha2RfzJrPStPGAN9sL4DiNSBsLI475S2ZYewhQhLDk5lsqo 9dFeiVTJTR7GAnOXoelEoEWFAErrvK0I09+Fbr2aK6vESJcaMxSeiLZLHRb4yBbS8jvH rSBmR6/pLXb0byCmcBZTjDC+/7NkwLyQc7WOVVgDZOcvxKh+elwM/Uh7q5FWmtyyzelr i8ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990438; x=1695595238; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hHjjAyqptO8IMOlepeu6XUuPt7GkOQwtq9aZ8x05FNg=; b=hjSmAr06vxewubJAWYZNiXRDDVwUAAoy+MvffsEzFW+t0++moNRqoUvE0WiGbbGIpw hn/z+q+R6NX2AckvSEizQZUndJfzXyMSiF4QcsAQC9BciLKswyKc7KhxhhjeNIgaKoRG eDbRoJLUX10qF5KTQeJV7ZOpU1rsfDWyx1i/2xfdS5/qqmr5c08iLDPXgWH0PKv7z5Wy 0CTsK9hfhkkxbr++KME8a0xS2Wd1UuMoTdVUyngfEnGvsarPLdSYS88+cUzHHCZTlrIo pzoB5gxTWQItI9qQ2k7uRvqvjqSqKfJdj+GNn1KspiDa+4YNU4jQvERi2x8Bw4AdVhj6 1bkA== X-Gm-Message-State: AOJu0Yyq1nyfptciCbc9ni+qFtu0DPw9FXmBXbT1IAeotEeiU6v9Q546 YzivIfSf/6+F0fBunmptxYDkIps5ow7QLA== X-Google-Smtp-Source: AGHT+IFLk9i3F2eGbtKSIJ4+EO4UrKuGZHKBpH4MGvrG0hpgnN6SI7Pfgpa0h7Kabz110ICpPDUFwA== X-Received: by 2002:adf:ce09:0:b0:31f:e74e:8265 with SMTP id p9-20020adfce09000000b0031fe74e8265mr6156359wrn.56.1694990438311; Sun, 17 Sep 2023 15:40:38 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:38 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:04 +0200 Subject: [PATCH 08/13] clk: divider: stop early if an optimal divider is found MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-8-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154040_074565_37B06BBB X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara During finding the best divider, the current implementation asks the parent for the best rate for all its available dividers. If there are a lot of supported divider values and the maximum divider is far from the target rate, this can lead to many iterations. Depending on the parent, the process of calculating the best fitting rate can be quite complex. Therefore, return early if an optimal divider has been found. Signed-off-by: Benjamin Bara --- drivers/clk/clk-divider.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index a2c2b5203b0a..61b40dfb4e6f 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -332,6 +332,15 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent, bestdiv = i; best = now; *best_parent_rate = parent_rate; + if (now == rate) + /* + * Calculating fitting PLL parameters, which + * might be done in parent's round_rate, can be + * time-consuming. Therefore, the lowest parent + * rate which gives us the exact required rate + * is already optimal. + */ + return i; } }