From patchwork Fri May 5 11:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232471 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 1C498C77B7F for ; Fri, 5 May 2023 11:27:22 +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=oWk+/cuHttKVyHSC9k4xXBPjHqN/TAfXNQI7ud0iIt8=; b=MfZSawVdIWe+gw bOF+5dH0H4IwJlttOQ53awQmfQWjaxoztO7zSCnD4NPaj9EDqyL/THWS62QTMzXniR8phxQ14R9pG RVGQlMQeuXuNHsw0OPky6RktcFPuY345qNr7Eta8i4fIZjl55SH4lQ13aUIYgrAxv8xO6BqlR1USM ZCy7VXOU69EkFLhAcypiBJBOmUeH6PqSe/5YYayd+zuuWALkcdRhQaAcwUmAMuZ0LZBEuyB/j5lh1 1YHasCYFb9DR8SGnpvOvoKtC3WRYxYKHz/X0mqAmpRWKuSVyD46AjDpAWMKH9WhcanbEnh1SbFoJI k1+YURvuRBfXAAbTVD3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putZm-00AfAt-1T; Fri, 05 May 2023 11:26:14 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putZj-00Af9v-2C; Fri, 05 May 2023 11:26:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3F82932004ED; Fri, 5 May 2023 07:26:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 05 May 2023 07:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683285968; x=1683372368; bh=zDqPNVgxehdt+d+0Rr42EJ6LftKM559oonN ommq2qIk=; b=pri8FCY7oZTJqHbi2yKilVa/a87CJh0hm26FnYT/Y9UaMQ4QgnT eSAcyopl73fFZiMfMffKlhPNzTscgugu64vB++SmkKBXCiWDEb8oGiHJm+4Xny3t PrrC4PTYGnMNaUosaJG3e+wRgT/RF3ng8irnxPz14C+oun3hCwSVJ1UevIWM/thu URIBS5wsmPhYF7cFPXheRfOxOL6iAutSUnbnvxP85db3MFIX8Nua4O2Kw0Mu2Ktf L8Z6iBvm4Fj2PfaBu4EoJOHHZEoML2DbeHDN1whE+lsLOqjUzea1os9iTrnmy/Qh Vqv6zr/lv71m6/AmbsTjhlkEWE6LnEKkCxg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683285968; x=1683372368; bh=zDqPNVgxehdt+d+0Rr42EJ6LftKM559oonN ommq2qIk=; b=PdOMyPVVipeA0qRMHSr+TbHLmCh0kmuAQ0g3GNqaiVEVI412zLR ijs3R8kan4JhUAZAjb9d37P08J4H2G0C4rgXcNAPktAHSi/IngM2PgpBr/iHemHt 2VnKKDVWvPUCcC0shAxUYzP8EWCgD3kn5HD25deHB8z8LCsR5WQzt53jAF8qr8Kn //u9pPj9WAUlQwGQBkPwjDt2k8P4Hmxn82STRLunFGU9SwTic27P/reGqpLsgwnN GO08RxFI/bkg45Z8fHIqJZZv7h5glXas6NhoPRgA/haCJualiLPF7oNbfVM/r21K cjcztixjxi90/NsKvnR7k9nGQq4DwxohOVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:26:08 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:10 +0200 Subject: [PATCH v4 08/68] clk: actions: composite: Add a determine_rate hook for pass clk MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-8-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , linux-actions@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2251; i=maxime@cerno.tech; h=from:subject:message-id; bh=hcjjYUL7EJDA0vLr7YhiayUeo8EOv+6/jhAeGWoQsRM=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxfJ7fG4/nRTTkirY7FNxPaXGbz2UwxM7y0/fMP3cfxn xpv2HaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiIxjOGf2r3D9zJV68U8JgfKTFZj7 WAWf/yD0+XGNbiHaf/q8iIJzL8s5G7c+p1zlm/dvb2wgxj1ocukuKi7kaT9me5f/zTcvAEAwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042611_748518_3EC6E478 X-CRM114-Status: GOOD ( 15.31 ) 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 The Actions "Pass" clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: "Andreas Färber" Cc: Manivannan Sadhasivam Cc: linux-actions@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/actions/owl-composite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/actions/owl-composite.c b/drivers/clk/actions/owl-composite.c index 101706e0c66f..e7784f9e5bf6 100644 --- a/drivers/clk/actions/owl-composite.c +++ b/drivers/clk/actions/owl-composite.c @@ -189,6 +189,7 @@ const struct clk_ops owl_comp_fix_fact_ops = { const struct clk_ops owl_comp_pass_ops = { /* mux_ops */ + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = owl_comp_get_parent, .set_parent = owl_comp_set_parent, From patchwork Fri May 5 11:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232472 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 23759C7EE22 for ; Fri, 5 May 2023 11:27:23 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=87/AYbA5zGrDjsEZym0v2gQOJdu8FWwIvYxfxHjQ6s8=; b=QSMhru1zfUQUu+ LkxwOzga06WGwfOMVJ0GkJNYyDX31/0NB4frS9LgJZkQ5oh3kAITYUk20ZtpuN01X4UJbI57HqlRa 7qYHyRWOLNUpMcRt9UIWTtOntPEC2S1QpWEbxy8f8rypkIZPpCsFePinsu/5b8At3/rMVQpHuIKUG dzcwX3vonT58RRqYd3vbXwWoonboV+LrLcE6EGZ48PDR4bTWJigAvWIuOj9W54RF+Vbdp3bFBWhbS SRpwgo+2iK2iayZ4MYQnVMFcYhCm9w08E8J/FKyOO9Ii8CZAPiFJuaQgNf8Kb3bEAKegAlYUOMu/C DdD/ESnnbnRKbHv+Qg6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putZp-00AfBe-05; Fri, 05 May 2023 11:26:17 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putZl-00AfAU-1E for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:26:14 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 5D98E3200A52; Fri, 5 May 2023 07:26:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 05 May 2023 07:26:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683285971; x=1683372371; bh=m1472fUUYrOyi0qUKoAVXtkZC+K8EvbFPKp eLfxLubU=; b=fpwsbb5lKPLNI7c/qNIPRgSDx0XoUyspS0B5SnZ/0vhrAoEfGM6 aQ1TDIe+eMlLH0+EJmmMnxDy9rd+EGRA6PbqoiQ5sX/NaS3vyx9epQ5S3JmzDZ8s tBEGPIOZA+4mle3kSIT/JTWCKr/+UO+yKerQ3NPiiEO5Noy3LY8GuXGjKisgtjcH hpis+Yyg6KJFZFbbmFeHRJFStx9tov0jEnbuhbt20uJNz4OXPV07omL1X8sIyMst XFN87RutrZRqFB2VpDuig+erbbwrWa5OoQgPjWwMTkD8OXKSqBZgiAFxeKAU/Q7B h1Tl2gSq6p4Dy/xD0IzeH8gQ95vTVnLwAsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683285971; x=1683372371; bh=m1472fUUYrOyi0qUKoAVXtkZC+K8EvbFPKp eLfxLubU=; b=YRWl3QNiuTiEZ48r8tvAIs4j05BqYHsuVj+RbxhQ790wIJaFS0r CtD+vUtZUlaTIftC8NAPUCDC1eKGsSqtX5ChYhTZROA81O4T868O3UJZc+VbYIpx 5LjWDk3lBvkmgHi1QT5jO0pIO7bJPgtoHGInMRdMKunua4dHZj6lpfjW1nKCcuWF 4/f0tckUAbxB6LMY96A1RS4Kv2FzgNkC9vYj5txJI4Pd0XDHL60fecIBRPbhL7V6 ouwIfoj8KFHJG9Ru8ufKLxjIE+5Hdo0eUysr9Uq+k55T7927+AJGlbrsyFJqov6d tGhixYfOy7oLE5NPQNQhm95/XQIwk5NSK2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:26:11 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:11 +0200 Subject: [PATCH v4 09/68] clk: at91: main: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-9-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2380; i=maxime@cerno.tech; h=from:subject:message-id; bh=H9KRPCBcjEpoRfMcvh/lzMCqJMQ8acMLWyrCaLBibMo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxfVnr+w79OKe/psdqxlidpxlXEX/ab4R368c/aJ18MP S9XXdpSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAixxgZ/oe08q/2sRJ/zNO++GXkBb 4FoXtumXwVt7h5Xfn9Gtu2Q7YM/51jra9wLnFfvn56ud4yk8byX5vrZS8FaZpOkCi+OeONNQ8A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042613_445606_B88F52E5 X-CRM114-Status: GOOD ( 16.36 ) 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: , Cc: Alexandre Belloni , linux-clk@vger.kernel.org, Maxime Ripard , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The SAM9x5 main clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: Nicolas Ferre Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/at91/clk-main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c index 8601b27c1ae0..4966e0f9e92c 100644 --- a/drivers/clk/at91/clk-main.c +++ b/drivers/clk/at91/clk-main.c @@ -533,6 +533,7 @@ static const struct clk_ops sam9x5_main_ops = { .prepare = clk_sam9x5_main_prepare, .is_prepared = clk_sam9x5_main_is_prepared, .recalc_rate = clk_sam9x5_main_recalc_rate, + .determine_rate = clk_hw_determine_rate_no_reparent, .set_parent = clk_sam9x5_main_set_parent, .get_parent = clk_sam9x5_main_get_parent, .save_context = clk_sam9x5_main_save_context, From patchwork Fri May 5 11:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232473 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 2587FC77B7F for ; Fri, 5 May 2023 11:27:27 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=T8n744qY8NuWNwiq+dSowMzkJyhZh7ZQexcCJAfCQGM=; b=u9vIg8tfpD2joE 0h1GVKSUzt6h7ZqevF389okYWVeV+envwryofIIwsvZV/RCJLkbImqLTM5GkGzi2KDml5vZAyVgMi /NurdxWg+RngxVg2e/1GyFokdkIVrbPXhCUtx5m9a2WU6vWcW2IL4a7y7RDW+5mCP7SQ7Ct22UmJR Hdy1mjBxK1KX5RA66S7rIWhNN6sbuzg9rYRuusyA8ERiI+WpuCJqn59qxt5MVj3EETBK0cUJYPO3N P+1vKQ0oRR6+fJmSp4cCkJzY2+5Rwa4t/onmpzmDFHGNbMsyyDh9axVNEEYpN+uf0YI2tat0kjbhr KtHUunfpv39mpD7dytug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putZr-00AfC2-15; Fri, 05 May 2023 11:26:19 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putZo-00AfBM-1T for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:26:17 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 6FC36320097D; Fri, 5 May 2023 07:26:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:26:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683285975; x=1683372375; bh=O1uJgpJMayji6JMJSLcGXhOP/LAFTEB2pdj giPGnU64=; b=xKU+SFOyOwOv5zXf0CfVJzPrB0Fg1bgGd9IuImeKAG1OjITAmlO B6slUsSGqqNBrH/sTRzEXlVTm37c+dB/CzMxK9mGirI3fqzrujdCYIRVjIX7CJ6T QYE1oAJIxJfOxM6wxCb3zYWO4JKlWckNBEyryH8GHyQRXoLQjGTFoEiSnzYmE4t7 lbxvrWxpHnWjJ71kR/2IwYF9L+L4o6x/wz+cGlSNvz1KvOAYFp/eZD9EuDY3+ejo 5rmvl1gZdmTQoDDjHKNoCFNtur2JFgQQoiuLHmBqbDYmjiHQxWMbQivrq3sBFs8K GtLGLIvlI0NBw1eN6CnLXSEM/EE/6tid1dA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683285975; x=1683372375; bh=O1uJgpJMayji6JMJSLcGXhOP/LAFTEB2pdj giPGnU64=; b=HED1Wvu026OSR41+pxYEuHt1M0mQL44w6Uqr9+VRRiI1cdDYsxu aId3YzcN9jI/B9spRdMwgVVN6yCJLJYU+YeBF6Cb22vgaRc4XEN9tq8Lvsz+LiBO 5B5yzDldBfZ74wmWl1YiQMGeGwwdch20zidMnabdEXSwNjCTuwytBZPTW5UVLWC9 6lXZJ36i951P13atDfrNeLIaKiQZ15ndKHRzIvNAlKNMl/xkPFG/E7Z0/NBVW87N 98tg4hCBL0ZjfK1ld5nKhTsA/FbqzlMAQr8HtVT8O2Mds+Kg2amin/vlkVWDMd55 XWQzuLIXEMPdIaKM8z4imC8lignzkLP0T2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:26:14 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:12 +0200 Subject: [PATCH v4 10/68] clk: at91: sckc: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-10-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2248; i=maxime@cerno.tech; h=from:subject:message-id; bh=8nOL4GYSumNmGHVS7LxATd09NwDbg4eZjT+yvgBhj5o=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxf51+zPufCl3N04K7maQ2v2g+iDxQ9C2Cp05rsIrX6h I7+uo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABOZF8bwz/713oeVvyz3BNxaddvoh+ qyixc9Mlj/qzz1LWU1u9UmsJaRoVX7TCKvyuZ/FbHFPIycp4U+Hp9rOymfxfYzu8w8veRebgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042616_522987_C145E6D1 X-CRM114-Status: GOOD ( 16.51 ) 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: , Cc: Alexandre Belloni , linux-clk@vger.kernel.org, Maxime Ripard , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The SAM9x5 slow clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: Nicolas Ferre Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/at91/sckc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c index fdc9b669f8a7..a2d86c377827 100644 --- a/drivers/clk/at91/sckc.c +++ b/drivers/clk/at91/sckc.c @@ -310,6 +310,7 @@ static u8 clk_sam9x5_slow_get_parent(struct clk_hw *hw) } static const struct clk_ops sam9x5_slow_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .set_parent = clk_sam9x5_slow_set_parent, .get_parent = clk_sam9x5_slow_get_parent, }; From patchwork Fri May 5 11:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232474 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 65792C77B7F for ; Fri, 5 May 2023 11:27:31 +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=ydYZXtABQK+oRb5Jn4Btrw/DzS4a4zBLlYto+hFUPxc=; b=XuOTxzcz4lKIh2 UPnJujBmHpjW9T6uqJ0Kk68BgDGICyUqEBABZU2VycuHiL4YGZEwaWwOkKlmu6o31sPjQp0be7TFE n8qu1616CsgBM3pmbFglnXwEq1A+WyXyU53FFcyPoPuOgBFtU6+1jH+4TkMIA5ifHGvD0C21JPkWs j8qz1mThVrSLb78I7UFjVdAqXjXr69KAWGfOTIZiLFQC92jhzBfQusc3RhTqWstvdQW59KsftKj/k JswMZavvKqCqE3aVrMPW1uI+KIvKV+T4HAs7k6eUD/jJRGl2zW+5hnQAllvIEk1UPExhJz+q+hdVC bKmYzjqL5w59AD0R7RwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putaJ-00AfJQ-0I; Fri, 05 May 2023 11:26:47 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putaG-00AfIC-1p for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:26:45 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 823463200A69; Fri, 5 May 2023 07:26:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 05 May 2023 07:26:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286003; x=1683372403; bh=LVfz7LD5avQVdWRjATmJJMIFpWciQ3yMgiu 6oJ3/+m4=; b=kevcOMA2cmUTFrxAm3zFFeXPgMIJuhhU4/26H9W+NuHOe3WQICv FboMKloZoVC9Ht8qX77U4t8JTD45LmG0Rvpm/xLaGxE5tRtZeTqvD5JarQv7LO7T xnPIBMREXgxok9Ushp+6xeBAxglo/UsVcnAvOJzqmnY3PDghi7VRpdBIhcX8ldfg C1eE+4INIdFDlX/F8K1znRQEMer8W/gAIhogaAwIZfJkbdMc2nDawrA/c4ShHNuA zF858fYB3Y4QFEOsvpastGAHnGma/qRs34W1P3xfYI05TnXsXkBNMoIQ4tl2pcgW cUR/Q+V8xKWYCNvpGOywMR/Mj3UoAbp79hw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286003; x=1683372403; bh=LVfz7LD5avQVdWRjATmJJMIFpWciQ3yMgiu 6oJ3/+m4=; b=CYTOFlrpJPssqlSa5rep07WHqNnOxgVJLQOs654XB3W4kY6sKpa 1L2Oku81eE9x769e5Q0oy9Q/JZHQ7C22KBFYXZK30FL39qJma+w1hgoii2vqY9zn 4eZFsxPWD8BymQZiYDrlzz3oWIKjX5/k5osjTC04GVRkAnte8JdCNChC+WGbVsHc rkJAaqMOk4nPrV9LHBe5SUoODGgVRfT7sPsMbFA6Xbok6igWv9ZwHsvL3MIRF+5f WVIsX1XGDMmnJ4ZvQuEtND8m/k7+12rQxvxHZO+cSaXNCo9JfxqxGCs+9sKMgLj0 YurveA0pA++wU/UqxZIoBntBqSShYalcIIA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:26:42 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:22 +0200 Subject: [PATCH v4 20/68] clk: stm32f4: mux: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-20-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Alexandre Torgue , Maxime Coquelin , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2028; i=maxime@cerno.tech; h=from:subject:message-id; bh=EiQTKXTxWl310eP7gvoXbVwd4WahDHb5ImRJPMpg1x8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxf/OyKwslul+tjbacI6e77szq8Ml903Ofj82sL9a3Z1 5nH5dZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAi/zcz/LN6+mjn3uNb+3/y2swVFg y9FezIINh36HHo8Rs9KitMzSQZ/lmWnGl5L3u8paby+/KLX1n/Z69PXvC/rfZfEOuMqFlcX9kA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042644_663408_F41DFBD3 X-CRM114-Status: GOOD ( 15.99 ) 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 The STM32F4 mux clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. However, the upstream device trees seem to use assigned-clock-parents on that clock to force the parent at boot time, so it's likely that the author intent was to force the parent through the device tree and prevent any reparenting but through an explicit call to clk_set_parent(). This case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. Cc: Alexandre Torgue Cc: Maxime Coquelin Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Maxime Ripard --- drivers/clk/clk-stm32f4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index 473dfe632cc5..07c13ebe327d 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -1045,6 +1045,7 @@ static int cclk_mux_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops cclk_mux_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = cclk_mux_get_parent, .set_parent = cclk_mux_set_parent, }; From patchwork Fri May 5 11:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232475 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 737FCC77B7F for ; Fri, 5 May 2023 11:27:59 +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=Sd8+YBOaNjqAQk1EL+k1D/hBxARb14rRDO0sbBSn5fg=; b=nEthER/tNNsqsC 9cRXdgog7KlJE9n7Yx9YXhrgOLrBD4Zh1wLMl5PlX9azvotgejdJwV7ydv52XI/guTvuuJV8eWgCC KeJk9s3S7cT1fDL9bafT91heusWrND49PocWpyaG0myzFqrW4yyxkH9gHkUiVw6HcMBkIBG2blwBi A5Z/ID3VhBegy4R7eK7IdLTr15BWIzwolvELvX1mnEkL6UrN2Ypi1lY3QAIYY6Aci+edaSqD2goEc MekJ6Y9iUnarqDHynVbVjDrG0/vBT9OT3IhgLY5T78U8A/JD0dxAXyQq316MN2RtuL7xcSBoNPGSQ FvRPkrmiALr1hvaiD8GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putab-00AfPe-17; Fri, 05 May 2023 11:27:05 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putaY-00AfOW-0z for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:03 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id EE5C53200A44; Fri, 5 May 2023 07:27:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 05 May 2023 07:27:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286020; x=1683372420; bh=Qyq+AHQ9GHxhGyLxWc/N8kBcBOrBM32CeXG 8zDV0M1M=; b=JHiOc+MLo+ysRvzfqhjEdNtwkTSikprpQNAzPhEALKA/RdlmS4c 889j5n0N6EVuul36lbQ9uGj6mgBznOY+eei6LHXaf+2pGuZhNeW+cQMBTuX9yt9w VBAaxgkODqXNPDtqM+9IlexIWv63jisq0FskLaO8+fWYNW+3236bnM8OfCMu3lPv MH8jPvJJzW2NF4J+1S23p1kMELYpQK2pm0HQwWf0sxOufTVS8P36HfyKc+GcbHqU oLy+i2q+it8n3c5VQ/ZkVs2g/aWP8Qneg0LugfznpGkH52TKuSO+bfJglGj5hFjl QQLVKbS/td5eJzJRvqHTrvMPHovV9zA1m5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286020; x=1683372420; bh=Qyq+AHQ9GHxhGyLxWc/N8kBcBOrBM32CeXG 8zDV0M1M=; b=ZjZc2ZrGxzto6uTPvfKgKVAZsrtKwjH3S6+AF3RJ1mPxF59yFMx tcZltmibg0WlwA8qhW/g/D3CFTJHegktrgeQR1s0Jd8+9yiUIqRgIQKEzBSD6ato ll+i9NQdJKKgtWB2Gua15Ul6UjO4/X069T9qBpe8Y6n3PJG4emDvEtbwlKEe9a2+ ThowDglUC4g2y1eJSUZ6y48GtVV/Ch6mghDfIE6Mu8OZbWISYa5DavbAwGpcnwRw Scb3B8QX1BKgPnOLf1dEIjb027DLDyaiFleABc9ep1ZWO85acyzXnh8xBQam/+F0 03wncn8X0elmexvpghNzsNcgTCLJyi/O4RQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:26:59 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:28 +0200 Subject: [PATCH v4 26/68] clk: imx: busy: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-26-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Abel Vesa , Fabio Estevam , Peng Fan , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2391; i=maxime@cerno.tech; h=from:subject:message-id; bh=XoSYRvlmzcByeBERHtmIUCUrRDIlqhQZ050GFdHYKNg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxd/minzp/bDbWevnBi3sGS+bafMo/7M+bPj33H9Ov/p ypOTO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjAR04+MDJNnTDbgnskZso7JY/5eFf 4f+2dfnhqUG63Jnr8nd2KRxhaGv7JRbWbL3m5hWK6w/fGUTV07Vu3Ws9JLv/dhz5XUrOqGGDYA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042702_372142_11CFC2B6 X-CRM114-Status: GOOD ( 17.05 ) 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 The iMX busy clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Abel Vesa Cc: Fabio Estevam Cc: Peng Fan Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team Cc: Pengutronix Kernel Team Signed-off-by: Maxime Ripard --- drivers/clk/imx/clk-busy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/imx/clk-busy.c b/drivers/clk/imx/clk-busy.c index 6f17311647f3..f163df952ccc 100644 --- a/drivers/clk/imx/clk-busy.c +++ b/drivers/clk/imx/clk-busy.c @@ -148,6 +148,7 @@ static int clk_busy_mux_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops clk_busy_mux_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_busy_mux_get_parent, .set_parent = clk_busy_mux_set_parent, }; From patchwork Fri May 5 11:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232476 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 B0653C7EE22 for ; Fri, 5 May 2023 11:28:03 +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=GY81mb00wC4xI3NDJsb9Hann6jZa0HgQOdlKMxoS/oI=; b=J0r9dAbi2xUA0E 7Vkn57UZtGkD4JiPh3haID47wHrct9so8m9rAEKxqsooH1rEfqQ5H9WEkK7jItzbPeWFDka2SiS82 /rWz5vA/0o5PvryiTmsbLr8k/nPD2Usdpd6Mp3Y6opU4qFrPmDTst5tge34ALSPrq8l1fpAo9SF5I hvRZUF9bu3KfMSPYyk5bXW0tAsPg3eb4dGQRrrRswtK6OJnu2+1dnLd8pGQYV0FDlsMf9JwbnIcgh r+nQfula7LawuHf5Yz9ukMEKTmXXfYYDsOQZtD8EDWwhekWXKzOaunaHGvOo4BgvbQ8C9jklQTL8L urEBk3LCgR2zKUrWAlPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putae-00AfRc-2p; Fri, 05 May 2023 11:27:08 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putab-00AfPr-2g for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:07 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 848DE32008FB; Fri, 5 May 2023 07:27:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:27:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286024; x=1683372424; bh=9GaGoMGjEvM3nBtYXQHVW2cO1D65NmKSgYW AE7A71G0=; b=iuzOh4epA/+cZ/jT4D1/ya4lHkR9D4ldeGEEV+g9SofjsWkK1MQ 0xDlRdBddjvfIjHbrYa6v0Wn8jdxw6CRlxZUg5XlgRt6yJu6CpJtP+l6TkiPeD9E msuVypBB7yweyQC4TjlQRQUcXxUP+XiTaR23UMaERI3QPD/xY1aSoKn3t7uX/K+c jD2hPI0MryRi04STZKANsxy48v33aU5q1VTqHE0XQ82oTOi5ZfTYeygnYYJGhlLR YTHMpDV6RSBklioB23M7zqYDHaMqUJ0bfn9XUinGteN5+BiG7zOo+lxWrLdKTqQg Nw4rtdZ/lhpyOJrGAgbUkjbj6csi6TaW8QQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286024; x=1683372424; bh=9GaGoMGjEvM3nBtYXQHVW2cO1D65NmKSgYW AE7A71G0=; b=NoVfxEM3t3n5K9hegXzp46B91Aa0cKg6to74dgiULO+vckbvLap FgDGOqeK8TWWmGfbSZfq2+f05g8OZAVx+qAx2Yn4yuB1aMrZZl7s1A7ZdScMGuOJ QknUn6uXVFu8caiQEjOdRFnIrNu4h8K2N7D8ka/sTvKy72faTIyEXRgFTFiTk7lL y1b0eNzUd+zD1WPJgDhUmS18caILVU8F+Is/WFnGTyaL5/WPtDaA6NpmvAhulO/w K2SQUQPfMnLI5+TsjOrXlMnUtGCYwLN4M/11a8saghTe4aF0qLbfcZVypYYzECEB XBKmLn8ajKxtcKj8ZffhPdrKiKJ/P/4DPwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:03 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:29 +0200 Subject: [PATCH v4 27/68] clk: imx: fixup-mux: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-27-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Abel Vesa , Fabio Estevam , Peng Fan , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2211; i=maxime@cerno.tech; h=from:subject:message-id; bh=fVDmwUo+ONYakLHIku1FGCJ/Cp1OnwLFtksw10VZRy8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxdX1nH/5i4VvBVRx6GwIye/VFO78nKMHefJplmXFpZy rgvuKGVhEONikBVTZIkRNl8Sd2rW6042vnkwc1iZQIYwcHEKwERO5DEyXGwV0ZimHperz759Rv9uv4 VF/k65z57kbWrt/dw7oe33Xob/Gc6e6875RojWRyUUzl5fL8Hyfufud60LY+9+LJ3RtrWECwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042705_910689_13BB0E92 X-CRM114-Status: GOOD ( 16.41 ) 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 The iMX fixup mux clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. However, the upstream device trees seem to use assigned-clock-parents on that clock to force the parent at boot time, so it's likely that the author intent was to force the parent through the device tree and prevent any reparenting but through an explicit call to clk_set_parent(). This case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. Cc: Abel Vesa Cc: Fabio Estevam Cc: Peng Fan Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team Cc: Pengutronix Kernel Team Signed-off-by: Maxime Ripard --- drivers/clk/imx/clk-fixup-mux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/imx/clk-fixup-mux.c b/drivers/clk/imx/clk-fixup-mux.c index c82401570c84..b48701864ef0 100644 --- a/drivers/clk/imx/clk-fixup-mux.c +++ b/drivers/clk/imx/clk-fixup-mux.c @@ -60,6 +60,7 @@ static int clk_fixup_mux_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops clk_fixup_mux_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_fixup_mux_get_parent, .set_parent = clk_fixup_mux_set_parent, }; From patchwork Fri May 5 11:25:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232477 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 5B8D5C7EE22 for ; Fri, 5 May 2023 11:28:06 +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=jiHzRdruGJGmtQoyJf6ESgYPn7Vo5UuVcq0+khv145Y=; b=t6BaW+/x98DGyJ pQ9DphN5+BOWY70PsQuMg7Neou6e0tYa92J2sjL4h7UjkBfXAS/X/DwQ6J70Yf4U/2OVNnvGMvqJd ys87fiLjgXbPV5z4qGrZ5hVEylFIxdTouRQnBulbjzfvPIrlruxj0T1259rYoTHlGRjyRg9b3/3/g znplzlcUPOEy9xofURN43L3dtCskf+dG4KQhvTf9yna9kZvmP5SAesuhYwxFJXmmFi1ENsP38+i6q KsVwHnGqBLKir+rRu79EKLMk7ycaZ5/d7uweTcOtMLOpF89/rQFGRtCBBCHdJecBRbcGaaMFALIc5 mF7TDmjv43hOZ31jmk/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putai-00AfTd-1n; Fri, 05 May 2023 11:27:12 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putaf-00AfRm-0q for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EE4063200A63; Fri, 5 May 2023 07:27:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 05 May 2023 07:27:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286027; x=1683372427; bh=is8YG82gb0D0VuL2IA9RpmyvIfa8b6hEhpy C9GysmF8=; b=SfNI3/vy1My/OzqGwRothJ3LUKkilezvrHRbiHJUW3Nw9BEiWF5 c5/rqQPpdK838eRHxB7o9z1G/W57VjYy/aN8bR9QfRDilHzqZfhh4cq0F/Lchc8p Hhl/N+dgghLmHkI4cQO02iWz2wx0yc2NCnt1C3M/fOrlXDld9rtEJiJ1Yuh3rTcO bxzrIt7JhyeYO4WRXfrRRLCJvfG5zPnKjWJAwgqdXjCJu6RjUgiA7O5QEBpyMZDy QETLha+caEtABWzFuD9I3C1tu/3iv2y8XpSkewucuRnhZ+0btbXy5nD58PNZc3OH ra3RGhAxh4bM8f4LM0qoLULPlJE8vlWqsew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286027; x=1683372427; bh=is8YG82gb0D0VuL2IA9RpmyvIfa8b6hEhpy C9GysmF8=; b=gd1EWpe27Kg1G4WZtuHCg23Qdco7F6PxiYeZV5FeasndR7oMmyL DZ8n/9PS96HSrPS8+ktcpdDdSCx8eiE77nEOFLzGrzqd/w+ueaLNykF5DrYOqUDv ReTV8ykwBBEl7eIXaupPbmfeJTpsxV7xxWvZ/Yl8TIt1jLEHjwmDa98YInHA/ohz OfeI+vs73QB+JgCGBJMBerbN++owIgNRnzQr7lgSCDDBxHVedYA0ZlGyDSVHJxbZ R0tDfFH9o471w4j7Ghtcgf1xsMsCNVUNo3BPGmOvKYxAl8d7pRsWQW8w+0z2DtXX Wo0AaEWgOIuGnYRjyNYUQDPsbBVDCuJf0Xg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:06 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:30 +0200 Subject: [PATCH v4 28/68] clk: imx: scu: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-28-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Abel Vesa , Fabio Estevam , Peng Fan , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2401; i=maxime@cerno.tech; h=from:subject:message-id; bh=qa3Xj7t7TWFPG+dMVFbDhq/Z9XaHdUp96ZtkDRi/NwA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxcbs7R3GjCcF2RY+cx2jk1Nj8cEq4tS67jDA59cX31+ yvvOjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzEvY7hf+L1FZm/O2zDjj6PlO9/nP Ln0i82R0Pdk6teK1s7ZSwQSWRk2FaqxizNczqWv9ZuzdE11+8tU1zZezpNs/XSub2Za37IMQAA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042709_330451_CC5C36C8 X-CRM114-Status: GOOD ( 17.05 ) 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 The iMX SCU mux clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Abel Vesa Cc: Fabio Estevam Cc: Peng Fan Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team Cc: Pengutronix Kernel Team Signed-off-by: Maxime Ripard --- drivers/clk/imx/clk-scu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index 1e6870f3671f..417f893f8895 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -785,6 +785,7 @@ static int clk_gpr_mux_scu_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops clk_gpr_mux_scu_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_gpr_mux_scu_get_parent, .set_parent = clk_gpr_mux_scu_set_parent, }; From patchwork Fri May 5 11:25:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232478 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 E90BCC7EE22 for ; Fri, 5 May 2023 11:28:09 +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=NaDIwaWw8KzDy1j32fomKnjgcYMaKsNWpfMAj9yIY0A=; b=BQy1l9YpuBzSl4 QnGTDd9FtebdJgzgSMGS8CovwwnkL0eKuGkOV3jEqcGQYOhp2FWpZOjQ6yrT4iiS3gg/+41aRi/DV ooOWj3Dl+1TfP3tg7YTcBEaoegoT+W27/kwHjJ/DWRF4k5PsUE8g88Wk/uL862kA64ApNSN1n7QKE wqcJ9zNzMcST8BJABOmvtnxKD1IoeZZ1rf8/Tmz/cTRdNT0CMdd4KNCHI4D9BhTPUuYbXHDYjgCBD +fbukBpHBzZqMjAmxgS0zYpZM4491ZE0lpQb5Cn+rn4UOoWmcbxGiF2q5X4coqu+yyAWakLQ/mpEC D6P8ql0W7cRVnuMOLmgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putal-00AfVb-2v; Fri, 05 May 2023 11:27:15 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putai-00AfTZ-0z; Fri, 05 May 2023 11:27:13 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3EE353200A6A; Fri, 5 May 2023 07:27:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:27:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286030; x=1683372430; bh=4qwIMtgamexsfx/NRydXMQ2IFWJca+VyOdS WVhefn6w=; b=EtrTh+QLiZ5wFLP8AC+mxlCvqlezDyO7rKK2sFL8YKemQcxJ4ep DjO30IJ3uU6e6piRDvhUqTY/5oyLw85meySYRtqkdCJMeo0m/wGBqmGY0wvrWeR8 6NV87FMFG4t5O/4bmhrS7IOHZAcYt5r4ErjgcQesgTjkKuGTII6fdiTPiOrWSPnl QeIC7P1avkW1COTWSC/Xu7Akiews25XZRjkAiFiw26PHvtzUSER4eEil1TQkPMtL LpWKR9Nv9B5bNli82GhbpOEW9nLK5yy4C4i5Twzz6ilBS+B5N2lQvp4eQHespYZu ZwkL20alBSjlFOlFUtcgjpNHq2LEQp1Xjsw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286030; x=1683372430; bh=4qwIMtgamexsfx/NRydXMQ2IFWJca+VyOdS WVhefn6w=; b=KIwJZPFtA6wi8YTS26i2gaXDGshYuknJ3gDRrSl1Xi8OkKKIs9V VfJgyCldltWjv5pfMtKC8lPDH4f46Uh84byUGIJiEvvU6uCZxdxswElrjweS6sxq THLWXGz3vNb2xsEN1uXeaDC/OxW8ciQhu5Uj6cnhrZsauzKzmtF/QeRDqiMeiADV /+8ef2C20IfLinCL88jbyeyeZd5BMk311m9g4keOzwZdFtW7bREoiW/ofWwY78BB /mF90NGUj5rSboH7FLFL82MxYSjZEOF+ZnrrgpuhoSdy9rRM3SJOO04/Yh4oZRUy nAi+5iCG0vFgkIQoHSgevDVTyPvUDjteQRQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepieenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:10 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:31 +0200 Subject: [PATCH v4 29/68] clk: mediatek: cpumux: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-29-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , AngeloGioacchino Del Regno , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2301; i=maxime@cerno.tech; h=from:subject:message-id; bh=7Gisy3436NyUV/3JhbE86qKa2YC1f2BvDT4KEfeGF9g=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhzxf/25KafbAnySb//eRG+33zucx2XdP79jCocXOfv4C/ lfmVjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzk8S5Ghj2TezqcVY2efd/yu6Zl/s spEldi3ro6rGX9FvMg4k/x+k0M/2w8vxk1PF3M/qLM1SOm91P1Zc4JG+O2bZi9av3fTY8LirkB X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042712_375772_6ABC4354 X-CRM114-Status: GOOD ( 16.50 ) 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 The Mediatek cpumux clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: AngeloGioacchino Del Regno Cc: Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Maxime Ripard Reviewed-by: Chen-Yu Tsai --- drivers/clk/mediatek/clk-cpumux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/mediatek/clk-cpumux.c b/drivers/clk/mediatek/clk-cpumux.c index da05f06192c0..a03826db4dcb 100644 --- a/drivers/clk/mediatek/clk-cpumux.c +++ b/drivers/clk/mediatek/clk-cpumux.c @@ -53,6 +53,7 @@ static int clk_cpumux_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops clk_cpumux_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_cpumux_get_parent, .set_parent = clk_cpumux_set_parent, }; From patchwork Fri May 5 11:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232479 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 819D5C7EE2C for ; Fri, 5 May 2023 11:28:28 +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=/a/yQNDw2obMATIPI6DuaV53nfgq9q+vIPqNQYja0ZI=; b=sybcMy8YmPse+J e4lc6JhbDXc7lSNHIMSH4DStbR13WFUWvuU76togFdV8wb+D5iRQLuUijufq+SVe/JavtlSQilxkg c9RzJ3fpAy/VvksBktYfau0VjrNKB0s088BnaRnVKhN8hNxL3N4w+5iiCLG8lr4j5FOxICf7PTtHm eGKRdE5QxbQgB4zgN2pdBmY4Pz3z9zZWZdLKJ8I8p6545e1+4GF4j1hJGL41DB7/TpHPAzu3G00cz YWoKdKr9QAtq6Hv+GVZLBvgntbH5pJtLbVDlaqei/cTxXoNtV8CURm/qgh2Ko/2hfJJ8qHAWyvPqc jUqzehlGQ0GEO9u3XbLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putax-00AfdZ-39; Fri, 05 May 2023 11:27:28 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putau-00Afb5-14 for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:25 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 4710F3200907; Fri, 5 May 2023 07:27:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:27:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286042; x=1683372442; bh=S/HR25t5MMz/iMAs8j1aFma0SMCGKNR7/Wi h/qTo4iU=; b=IwOxUqPLa60ar1P6+aJ931QDqsVWsUHiwB1s0YvELFe8ZH1ijwO ThpDrMVDAP7UKNm6pMvOgWOKurJz1oBhQqAh4iYxEPd3iWsP7NjFtXKYm548B4Xv aJwq0L/o3fmx0OkVArKntS/2cZ6W1hBfRJibXUfk5GxCsz3kRkGhiU7O7nXzh8jz LagfOBkveVd7f3h6rZbvNN6f/cI5o0G+vAoNqCeq+jw3Uls+8xYPbU4p0KJ7B93t Z7pTTlXXOf35LvNYjaWBL0g4vyYdrttN50y8NFBRX9QnsAjJ+8EkhOiXRg2dg1ka fd4/85zz53bpKcxSFKIlSYkK/iPPqeBNbsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286042; x=1683372442; bh=S/HR25t5MMz/iMAs8j1aFma0SMCGKNR7/Wi h/qTo4iU=; b=IleKLDRtqvEID2O9c9UeRODSr62k0QTNO56AwrfiZFVc9I4lCNh q4tjXW/DUjA9wgVPEwrbdCnNMSb5ksoeIS6VywUbHe2tQz5yOfwd7yC7lMbY6o7V 0nXdu9/krK+oUNLHl2MYZn7OAyshjfl1WYdrBw4/6bpeKWp6dlzR9WucvAy22uhm IA5QHuvTFPp5I/v7j2w4O4RzdbpGsSFKD6TcaBpT0HgFsBjzyeZeqe7eE0sPwlm/ aFUOKWWfXnSy37/bel+5wq0n7ipKhQG5HMqyt6PWy0Zmk7Pz0rAE//sSbYi755Dd SbWTa/c5hPjwtZ2HnpoCNF0p5HwYRHf18LA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:22 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:35 +0200 Subject: [PATCH v4 33/68] clk: stm32: core: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-33-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Alexandre Torgue , Maxime Coquelin , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2218; i=maxime@cerno.tech; h=from:subject:message-id; bh=fWYhKhv/wFYwQwGVziH2GFGzuOmOsKzPh9vOFbAKgeU=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5fY8m45Jmf+SZ/rxq/8MvYOr+Lu2ccfWq9fK6vwdOaL uys7OkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARbmWG/2VbpnbqBS1+nNteLCocwH HlvOl9dcmpJeF98/YUe3x8spHhf3n6ScEv+l/FCue6xW/4vnN61jGpzK3J65SWab170V0WxA0A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042724_402893_CF748A03 X-CRM114-Status: GOOD ( 15.38 ) 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 The STM32 mux clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the flag CLK_SET_RATE_NO_REPARENT, together with setting our determine_rate hook to __clk_mux_determine_rate(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Since the CLK_SET_RATE_NO_REPARENT flag was already set though, it seems unlikely. Cc: Alexandre Torgue Cc: Maxime Coquelin Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Maxime Ripard --- drivers/clk/stm32/clk-stm32-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c index 45a279e73779..3247539683c9 100644 --- a/drivers/clk/stm32/clk-stm32-core.c +++ b/drivers/clk/stm32/clk-stm32-core.c @@ -275,6 +275,7 @@ static int clk_stm32_mux_set_parent(struct clk_hw *hw, u8 index) } const struct clk_ops clk_stm32_mux_ops = { + .determine_rate = __clk_mux_determine_rate, .get_parent = clk_stm32_mux_get_parent, .set_parent = clk_stm32_mux_set_parent, }; From patchwork Fri May 5 11:25:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232480 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 A5273C77B75 for ; Fri, 5 May 2023 11:28:40 +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=9MwZGS+IMFJWhZfjwUJ43l0o6lv8EX50Br7/HwD9w80=; b=c7lRtXdcuCr7vR fRmYWho86AY132g8Z7tuKyxA3pQSiDR3LJX+BbITPVcz5S81Yfk7cw4BbX8Y2GYJRnKagsmK+JpMq FhtEHg8wnShjiiu7B+qvA0XJJbTqTx9hWhVd7uI7iDs09vEDeu9alyIbAUgwP46vM66Xkx4uwkOZw P2k1ZTjTeRe9aglXjuPhZJvMcb7G1KamBTVb4jbLUVCDN2/gkhmAJ6BOzd+4hrm+RGOGUOIsa303m XJ7FaY1dNi+INqzLuyDzRFi3lMLx3WVHwCjAJHYYs16Xbas2B375o84osfkmBBEy8s4uMUV4PCi1X lZ0tKMlwLcw1QD26IqTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putb9-00Afkv-13; Fri, 05 May 2023 11:27:39 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putb6-00Afiw-2P for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:38 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id BD94C32004ED; Fri, 5 May 2023 07:27:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 05 May 2023 07:27:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286055; x=1683372455; bh=zPaFx80r/zjx6/jqsTeFDCf+vLEYQDG5Sqk 4QVDkgmo=; b=F2Ta3kYxJ9VrpMPxhjlq0Q02NZlabpxqJzGIToLWoG97alPMSX6 g5GpwR/o6EF/+MpmXZg/AyH/NZwBiRMwmPuNgT3Pi6J8EejITZrIUnrFwbzJtKlf xtlevs5TGS/RTrxw8mVir8nBz/fs8IXuzYe3cJ9Ld7E50PjpSYBkXzuH1usq5rYu k2GHgnWuocyTqgvHqBXAJPEejcxCX9s1CmlFRI/hZOUmv6FwsX4RfMZkV87/sTDP tEnQ42Om4Q6uI4wXTISuIi3frqe7BG8sE4DhL1vKtaeEq2tueYAZG3GWGq7LRj8D GtgNLjltDsylbOZp8z14yE73IeXMBSFLkiQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286055; x=1683372455; bh=zPaFx80r/zjx6/jqsTeFDCf+vLEYQDG5Sqk 4QVDkgmo=; b=AyCbfZPDk9BQX8UPVwJig+LE2VfQTJ7iVVeWBkQPkyTfrXf++vM jKtwlA3AGqAbJfh1rx+VbcnFjkiLo5Phky1BCesn9L/2ct5L1sXgPk/oHTPZpClE CRjhCma/hHCgParl47/MyLrj25Bck/abVGpIALN5zlTH7XdgMspbwKcf+2bnhIi6 qDttUp6oA7fpGiaVmAF/SAS8d8sWwTB/TXpYAPoFrlg/DaYok2Yq6EFufj07STIk eGEheo05J8hruGtvpJgJOqXY301abGAG++0n9Yxm8L2OjCM4f2q16THTHKz8KRBe LEfspMax8CFbdp8NFjpO5tzhPdb58JgECiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:34 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:39 +0200 Subject: [PATCH v4 37/68] clk: ux500: prcmu: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-37-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Ulf Hansson , linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2131; i=maxime@cerno.tech; h=from:subject:message-id; bh=5jUOzNr8PQIXZ87KetW9sv83ouSz4FWuJF/pholzMmE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5eciJq1eqab77P9e3NOy89I3fRfTaGZab3xavUvunn8 C02PdpSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiWrKMDBOMumrkgwUPFKU4KUvMOh U6vXDt07dLBD4yJYTeSje6OIORoe8F42Vb96e9UW4lj8/+suE0N17Lz542/7b6gZw7xo5buQE= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042736_825843_E2F46784 X-CRM114-Status: GOOD ( 16.18 ) 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 The UX500 PRCMU "clkout" clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The PRCMU binding also allows to specify the default clock parent through a device tree cell. This will be enforced at prepare time by the driver. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. The result is that the driver relies on prepare to set the default parent, and thus the set_parent hook is effectively unused by design. We can make that decision explicit by setting the determine_rate implementation to clk_hw_determine_rate_no_reparent() that will keep the same behaviour. Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. Cc: Ulf Hansson Cc: linux-arm-kernel@lists.infradead.org Acked-by: Linus Walleij Signed-off-by: Maxime Ripard --- drivers/clk/ux500/clk-prcmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/ux500/clk-prcmu.c b/drivers/clk/ux500/clk-prcmu.c index 4deb37f19a7c..5cbf24c94606 100644 --- a/drivers/clk/ux500/clk-prcmu.c +++ b/drivers/clk/ux500/clk-prcmu.c @@ -344,6 +344,7 @@ static const struct clk_ops clk_prcmu_clkout_ops = { .prepare = clk_prcmu_clkout_prepare, .unprepare = clk_prcmu_clkout_unprepare, .recalc_rate = clk_prcmu_clkout_recalc_rate, + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_prcmu_clkout_get_parent, .set_parent = clk_prcmu_clkout_set_parent, }; From patchwork Fri May 5 11:25:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232481 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 3B06DC77B75 for ; Fri, 5 May 2023 11:28:43 +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=jiMoxiM3nxNwSBSbJ6EzfmFxJZdHPeYjtl56MPgltgQ=; b=a5seQuJcxtg29g 9c+Rd+V0W324ivkKuwp/vrSZPp5M34HZxxaCqSe0174G0wyPX9yV1fR2lkZO7ZYZSz8S9EP2ZEBim gXuFsulZ9A3WRrJH6iIMdMTUQhFdLeFhjVkVni6Me/pwLahy65Ucl51BoPOYJ8oDKaJBeCtymDE94 UgttfSTmlgO2bpXMidrMPGWAVW0Cue9XN5hUz+8ZUi49xFVOkNoBz4RtPHK3PWqxAFUPeLfn5SUzA fPML40ETRQc0WXwG5mTw/dbhwqjeANLCGLYSy/Ap4HKL873YTK2Ta/EndMpwxCWp2J1Q7K/rMbzMb n2MXXgfZsXOtX8lYdvyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbD-00Afnp-08; Fri, 05 May 2023 11:27:43 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putb9-00Afl7-2I for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:41 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B90A83200A80; Fri, 5 May 2023 07:27:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:27:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286058; x=1683372458; bh=D8rLr9OMXPZcCTtVhZhxl/mxOaqHxQqts0r YZ7FfWpo=; b=Vid7TGwpVXkLt2mESgclZOESsWOXEbEk4dsNiJmZW4KqvMhT915 j7JHxRMr2/wbYS1eJFbAAZPWnpNkLlPZnYx2s5isoWALYI+7x7xyc2JqxTk2pnvS 5TfC/VUM0gCl6oVf5lsJS17L3ZEVFZlUDgBPQqGRje+zTmz9olteyjv+nwm74v31 SkFqqVvHTjV2G0tDEQOtLNoCdF2+bajcxaqp+VEYw7LlLR81bWUs4OP89s4OHjOq 9KmEA5Kxd04U9xLjZJyOyj66PBCw488WtIWOMa88N9Gof49TRqUnl5oxyRY3EFfu Id9Olh173dRyiLmyr6dfGkKT/cjUfxZpO6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286058; x=1683372458; bh=D8rLr9OMXPZcCTtVhZhxl/mxOaqHxQqts0r YZ7FfWpo=; b=H92S22diAKEuDqPCEcfIUBHXMAaFQiVKXHKDmFUS2l4NhnKJlnN /zRj/SfFql3BaR28K2/wlo427BXWUzP9fftSvqK/5OMozatsnIVqX9WVsW6PxflO kcViETolKmIxVSsG6atNG4ZeUa3aeI2jOXs1vWOa7giHoFpjEexZZnADTM2JCzox mHYVLX6uVxDkLrZh1+G/vZROk/sA/lQ0K9xjUHpBJwv2FZ2eehNVlTRHw06dG12x ZX8tBKMhiNKWontRIcVAdCwEPGH1ha66FxVIu7P+0P90rXGwUVVp/Q3Q/gnuCY3e O5rCf06qjVQP4tg3WYVtTqzqaCIMpmVZTvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepuddtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:37 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:40 +0200 Subject: [PATCH v4 38/68] clk: ux500: sysctrl: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-38-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Ulf Hansson , linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2305; i=maxime@cerno.tech; h=from:subject:message-id; bh=PZ0luiC05wRTIkvYXLkev/HtMLESoOlpFBb4AQ2bSHc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5c8s2Sakqrz0DbW6FGiz8dfW+szPfUFJ3HVvP/9Svbg vKd/OkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARgRxGhkX6EyunzvsenF71fPOSP7 1ykp3Jq677cYrvPHDAe+q9V7MZGXadMV+3aorTBu1TZ+O0NopoJ14Oec/F43q/iuedzi+BMB4A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042739_789624_CFEB10E8 X-CRM114-Status: GOOD ( 16.84 ) 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 The UX500 sysctrl "set_parent" clocks implement a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Ulf Hansson Cc: linux-arm-kernel@lists.infradead.org Acked-by: Linus Walleij Reviewed-by: Ulf Hansson Signed-off-by: Maxime Ripard --- drivers/clk/ux500/clk-sysctrl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c index 702f2f8b43fa..ba3258c88d28 100644 --- a/drivers/clk/ux500/clk-sysctrl.c +++ b/drivers/clk/ux500/clk-sysctrl.c @@ -110,6 +110,7 @@ static const struct clk_ops clk_sysctrl_gate_fixed_rate_ops = { }; static const struct clk_ops clk_sysctrl_set_parent_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .set_parent = clk_sysctrl_set_parent, .get_parent = clk_sysctrl_get_parent, }; From patchwork Fri May 5 11:25:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232482 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 938D4C7EE23 for ; Fri, 5 May 2023 11:28:46 +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=SbcbZZGKub8PwnXmC8+Jk6r/AjFoCnto1Br2vi3iEgA=; b=xsaNKqztALYeXV Kj4dbAmahv6X9uksVDJ2YnN1w6B+khNE253niV0hc0/d6MOi4F6glgtfSHs1lg5iYytI+Vg/tcCcA WPwE71t7M7IRUcfeyJA6vl7avQHkUg/CoZnKKRA7agF/cOqz80K2y/suq5ETLUqjhQhnJIcN5033e o0V4ixz60YcFbR+37xstawmI8gwfCE542G05HXkMyT6LWQrZu0vY1wLgYRJR7mqGWUZGrCeIRrzcY KRMgQUT+a5BNWRPpVCDxqErtFC8kTqv5wDJ4BqADILGeyOOC7qdLmKfBPJJE/OC0BsJhgTEWzuFir vU8Jgo1f3Med0OcOOelg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbF-00Afpc-1S; Fri, 05 May 2023 11:27:45 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putbC-00AfnL-2J for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:27:44 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id BA08B3200A87; Fri, 5 May 2023 07:27:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 05 May 2023 07:27:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286061; x=1683372461; bh=ZIgJ5ijCTY/v1WziGp/hIgqkKCFCnTtWZxF yDL4rb90=; b=GtFaWjxlQk8x7qa9yFlpZ0Hy/I7qW4cPVQZTkwWEu4XNDXBFuf+ I1UFy/W+zOLPyowDr8bog+3SA2HYATSOUpA/Uxml4ItPCxBm4Z43BjYjvwCwq0sJ fWvgsSi4DDpMk9V7v0eGn2zeDm9HOc/zz+4MAjFlMZ3+21XoZWAXhLdJKYtCgM4r 1jMoVj771dInkceD3k8x4YMDdrvuG1qjyNPDInIQUqqoaojstF4u2sGw1js2WlFt lxmQGcvbgwiOrQ1SS1D/Y0gTjMMskVaoOtCM96gA/B860Ci7eR2PGiL3ITsq8G7O MuIDiv0vZut/Gen8TyRqMY4DZ/yBF0ofHcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286061; x=1683372461; bh=ZIgJ5ijCTY/v1WziGp/hIgqkKCFCnTtWZxF yDL4rb90=; b=Pk5WQuTCuy7NKd1s+Qq5Y99gn+uLSallJmXEAeCP+5O3Qco8/oO TXFMjRdAAzPjGAgb0gowlnlSXHnBWObOCIDmxYVdRPgQWjZ/M8T3qFDDssCw2dwW hhm/UEkyizYvvPC+/UaUs8jpHwMXW8oMowEJhMtEoc4ym+apRMUCZd14kH2oh8Fn j6SbQeE+9dVl5qZ5ebslQI3giIQiFLLiy0rCXb7VN7RRS5nXirCy5ZfhEg7ID2by scyU+R9GkMkmQUYPqnLfGAAYboYARiryBg75pL5nQI20GP9Rri16UnRd0SKEv9xZ fKoLkLFlIeKb2kPlRVIWiEGJieiqv0lLc7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepieenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:40 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:41 +0200 Subject: [PATCH v4 39/68] clk: versatile: sp810: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-39-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Linus Walleij , Pawel Moll , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1712; i=maxime@cerno.tech; h=from:subject:message-id; bh=f9fKx6fagdMn/NSMW7Lh8JOOu9FmeFzPoLjoO7VByG8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5e0rN72n/Nt3c/nCW4LC2auu5fTPiNmZ1v+pQ4rubLt MjdjO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRZG6Gf2ZvTRh0jGoUY95H7ApdLT jBPXtvxxdz359O21nuHflx3oWR4XLpxn0FnHfve+i2nO7eIanz30dHbvcRRpa5FuuWTlinww4A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042742_800511_41E02ED8 X-CRM114-Status: GOOD ( 15.98 ) 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 The Versatile sp810 "timerclken" clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. This mismatch is probably due to the fact that the driver introduction predates the determine_rate introduction, and it was never revised since then. The default, implicit, behaviour that has been in use so far has thus been to simply keep using the current parent in all cases. This is also the behaviour of the new clk_hw_determine_rate_no_reparent() helper, so we can simply use it to make our expectation explicit. Cc: Linus Walleij Cc: Pawel Moll Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard Acked-by: Linus Walleij Acked-by: Pawel Moll --- drivers/clk/versatile/clk-sp810.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/versatile/clk-sp810.c b/drivers/clk/versatile/clk-sp810.c index caf0cd2fb5b6..45adac1b4630 100644 --- a/drivers/clk/versatile/clk-sp810.c +++ b/drivers/clk/versatile/clk-sp810.c @@ -63,6 +63,7 @@ static int clk_sp810_timerclken_set_parent(struct clk_hw *hw, u8 index) } static const struct clk_ops clk_sp810_timerclken_ops = { + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = clk_sp810_timerclken_get_parent, .set_parent = clk_sp810_timerclken_set_parent, }; From patchwork Fri May 5 11:25:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232483 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 A4284C77B7F for ; Fri, 5 May 2023 11:29:09 +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=uJjCaFgBeMEQfIVejWss9ThEcDxHv7kOL6vdYzPpshY=; b=enf1WcnOczDCF7 Y3ieMGw5ytfHLk3+6oKiS00PFN9QQo5tUm7vveAcDNrvoTeECQTIFbCYmui0VpaYARl4lUKl3sf4D uh78ZfdUruapyJSIYgWN1/ne5ZdtgNOEokPXdlfKysirBMyhwnYBs74zOyCk4YJZN1JTqC9ZjiF0b lSt22eN90zojtFaPu3rxTN6BazwaO0yLx9+yjmSHnMlXdX0g0P5oLZ2vRHQKWIHxQnG+mTcmvfDgF IhR0aFAVQxGtidjt/Q8YdQM4BetuRgDyOoaNRc09xBMm0zY38OAqJnqmbsQQXs3bIsnnLyxmcsws1 eFTQeExBRewEh1Q/jwtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbb-00Ag5u-2q; Fri, 05 May 2023 11:28:07 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putbV-00Ag2D-1b for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:28:05 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 115943200A60; Fri, 5 May 2023 07:28:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 05 May 2023 07:28:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286079; x=1683372479; bh=GKKf9EhaXnod3gyBbs+J+eUBVfhftHN+tr+ h5ZiCjC8=; b=kbHFdePpG/Gw+jbXUa3N+59OdNbjWCGnY7Cu7w0JiZJ7pLYILm8 vDbvyTjq6fOcKNHwATv7V+Punxh0CEHbch7BiOgl3RaNUBzvoPNEFEH1g2Yey8DW eoJd6FzbUTmDkEjPwbRhhNR0oR3azfNoEjurtDQKkW8Kx5vjH1khLn21NkqGX6Tq TSR3ohItxvZOm83oKxY5iW9ioy5Cslx5EAx2BMpWT31BYk+RuqfMQ8mtMkLtK+Cs Umbqm8XbvLq3hlHI6U6cVUpv1Z1joElbamz/yXjbtatdOpSd8QwUXeSlW5YvuUMV VJiwciI726CKODf5gxYmTtLb7m4FpO2neNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286079; x=1683372479; bh=GKKf9EhaXnod3gyBbs+J+eUBVfhftHN+tr+ h5ZiCjC8=; b=VQSdl3StcDi4VuqmS+qnbmXi42yDUbAbtTyVcx41J8Gv1C7x0yg v3BNe1khACFWAEBGnkPioylZPKsVrRbbjlXuxXzLS+rhvQqrQ6/L9sM4dEuIwPpm kg9U8dCxMMV8n3zrO27NJ8Cucqvl9Lgl+xsHXphesxlaE+Qd9gIVfMao6gccfSyM icIIRxM5IwBmrFqjnXeAS2bynlJiXwoAc0aRh3y3/Co7tJo0g5wvqUCY5+xr/lzO ZM2towkOZJbPBRMXGJikzv/I2Lf78+kogii1ERuKTftPfRFqBMPkDicU9BpIqh03 0IKVu3ngYN8x6x4wGZLGACEF02+RYhw+bLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:27:58 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:47 +0200 Subject: [PATCH v4 45/68] rtc: sun6i: Add a determine_rate hook MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-45-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Alessandro Zummo , Alexandre Belloni , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org, linux-sunxi@lists.linux.dev X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2434; i=maxime@cerno.tech; h=from:subject:message-id; bh=3Q4a/GiK9m4nbc17ziwEKJILlFgG0TnxAPcyIHI/6dg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5d0iC+vOvuh+erPO47+UwKe3ag7Ne8JU2d16s92qaZV Fyd2dZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAihmcZGS6u8GTslXq+ppOt98rWyZ rF7BL521e7spZwuO4U2HO6N5DhF/ObEiW/j/GiF9QK5k5bEOchfrrjZcKpmf139+jI7dW/wgwA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042801_620065_525EEF43 X-CRM114-Status: GOOD ( 18.91 ) 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 The Allwinner sun6i RTC clock implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidates to trigger that parent change are either the assigned-clock-parents device tree property or a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. Similarly, it doesn't look like the device tree using that clock driver uses any of the assigned-clock properties on that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The latter case would be equivalent to setting the determine_rate implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no determine_rate implementation is provided, clk_round_rate() (through clk_core_round_rate_nolock()) will call itself on the parent if CLK_SET_RATE_PARENT is set, and will not change the clock rate otherwise. And if it was an oversight, then we are at least explicit about our behavior now and it can be further refined down the line. Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: Chen-Yu Tsai Cc: Jernej Skrabec Cc: Samuel Holland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rtc@vger.kernel.org Cc: linux-sunxi@lists.linux.dev Signed-off-by: Maxime Ripard Acked-by: Jernej Skrabec --- drivers/rtc/rtc-sun6i.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index dc76537f1b62..71548dd59a3a 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -214,6 +214,7 @@ static int sun6i_rtc_osc_set_parent(struct clk_hw *hw, u8 index) static const struct clk_ops sun6i_rtc_osc_ops = { .recalc_rate = sun6i_rtc_osc_recalc_rate, + .determine_rate = clk_hw_determine_rate_no_reparent, .get_parent = sun6i_rtc_osc_get_parent, .set_parent = sun6i_rtc_osc_set_parent, From patchwork Fri May 5 11:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232484 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 26C79C77B75 for ; Fri, 5 May 2023 11:29:12 +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=kag7MtgccpUKrjp5T/HnxiSr2Cv+mERyFZZ4ri9bGbI=; b=u63mAOVizMhF87 m/ekB88Pt4KtMMoL6mdrQr6AS2xqWpL1R3oVAlropdxzaebup5aooXxvINCz3v+wT+mE+iVH/8A7/ YuqzTMPdXa17wwKN6EJY3bzvUDwPLvb/ho794ffgmGeB3BA4pSuOx+375hP/rsf/XzC1PnOLlaXy3 F/dp1Ed0C/sbk8gMMCzpF4YjKauDZKCBwOgEJpVT/B4ILb13UbKLQL5X2u+e+shVSEP49HIFxZuYO eLKTdpnEQKyZP16Ifzj7KP7ADNaVl7kZvWeM0SW+CNfnbAC/eZCIGqGqvch3olKR8xnEm19QbwnZ7 25++MuX/aT12pMLN760Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbh-00Ag9b-0s; Fri, 05 May 2023 11:28:13 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putbb-00Ag61-2D; Fri, 05 May 2023 11:28:09 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 901A032008FB; Fri, 5 May 2023 07:28:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 05 May 2023 07:28:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286086; x=1683372486; bh=PfWTmImKxKIpJoAkzALAsFwdadzDzzsF9hz gcNjJ/uM=; b=MoCmgjhsDTvl3uJotlR7ENT73i/kptayfrfL9bhtdT5Dwidwidx HsLeomfFqiX2GVWLsUSiLw+UNkh2BxnfJsg2enhvUyb2ehM5ol7Z2pXRFCzbdwYc fDlViFdBb1nOnK7F0aCrRzSmLnZOxQYb8A+/1vFXva2B/WbuCfBj33QvlZLtexCq nG//lRj5Lj0sGjJiOhUN8BiMBm6AhY7qhsU8DS4WnDGb9W/3nd7pMyoU4ITJAgDd phuQe9kLDLPOpqsMjQE0jEuANUZW18Oufm/AbuEZ3L0tvV1q9mNJxbHuf9UlOcMQ 2eJD8JVikfetlmTY9Nmt72jXs22eiCMAylg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286086; x=1683372486; bh=PfWTmImKxKIpJoAkzALAsFwdadzDzzsF9hz gcNjJ/uM=; b=TItGzxbivLbfvsh0+JM3Y5n/og4h8AnbJUlcW7j+EjoLxyakirm vmJLYy+AvOr9/YhHd69mAuUemjqV0i0REJLL4z9PjaRAL8lTb1X8z/jI2AA87L+E ojl5Ki/YaeoU1nskSez0rlV6rBHBwcdEO/lm79UncRMKEdmRYNex0rjOuij/51ro UPc0AiJJGyqh7AQcKUqkzoOtRhOMoUlf9TNBe4kJBcSj6SVDaKoVgezOrGLIsDgH mYe11kdPdKhgp7NkqWkO+d1v6RtufshDLA52zpV1TRJvX971DlHyzk+22AmKTe4t /RA4JEB34v8C82LvYR3EHA10F1cQ87dDTCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:28:05 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:49 +0200 Subject: [PATCH v4 47/68] clk: actions: composite: div: Switch to determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-47-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , linux-actions@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2950; i=maxime@cerno.tech; h=from:subject:message-id; bh=UZMNzkOWFIjD+gDO2VaoM7lgoJwIkakPOuo1/dGFvM0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5es+PMwXjlnkXZ9M8PES2UHJ1/+VRUrVnTwtlDOheUC PsoWHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZjIhB+MDAemSDZ0v3hb1v1PxrBs05 sDHeG5qTfdlSN/m5/4vPuSbQrDf6cZ7FWGLDWiB3RmGSQ9E7h/dfbfHaxuR9qkJcuqs2czMwMA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042807_823403_7FD14C4B X-CRM114-Status: GOOD ( 18.98 ) 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 The Actions composite divider clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: "Andreas Färber" Cc: Manivannan Sadhasivam Cc: linux-actions@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/actions/owl-composite.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/clk/actions/owl-composite.c b/drivers/clk/actions/owl-composite.c index e7784f9e5bf6..2f1e282134b2 100644 --- a/drivers/clk/actions/owl-composite.c +++ b/drivers/clk/actions/owl-composite.c @@ -53,13 +53,19 @@ static int owl_comp_is_enabled(struct clk_hw *hw) return owl_gate_clk_is_enabled(common, &comp->gate_hw); } -static long owl_comp_div_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static int owl_comp_div_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct owl_composite *comp = hw_to_owl_comp(hw); + long rate; - return owl_divider_helper_round_rate(&comp->common, &comp->rate.div_hw, - rate, parent_rate); + rate = owl_divider_helper_round_rate(&comp->common, &comp->rate.div_hw, + req->rate, &req->best_parent_rate); + if (rate < 0) + return rate; + + req->rate = rate; + return 0; } static unsigned long owl_comp_div_recalc_rate(struct clk_hw *hw, @@ -152,7 +158,7 @@ const struct clk_ops owl_comp_div_ops = { .is_enabled = owl_comp_is_enabled, /* div_ops */ - .round_rate = owl_comp_div_round_rate, + .determine_rate = owl_comp_div_determine_rate, .recalc_rate = owl_comp_div_recalc_rate, .set_rate = owl_comp_div_set_rate, }; From patchwork Fri May 5 11:25:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232485 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 361FFC77B75 for ; Fri, 5 May 2023 11:29:17 +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=cTrDfhZZ1+xiqedMN2m2dgxc5xBxqVaG5HuVtYD5l+A=; b=P2tje1epbfFxaq 2vchxqHwUmkYzV0APajH3UWFgjog0mr5wE1vPDyboEJCXEsI9WVEYY86GWkdwWi+P2O8bNgXQic+U N9QnfARgMiKttoikixAkoQrJQ2FfOP7Zx8KwKLGz1VdmJ20I2hJo6lnBp0FK5h15DaBYZb2hLm3O/ 4osu4kb01l/S4I3RvUQbTsKpv3t/T49k3G+oyL6T3vu9DV2YvRL80J4dZbYEAbpsWs0nCP7ku9XKA HDmh4ijka3al80xnFcN518LqSAaaxFuZI1feDEdeTdSIcS4xvbvZnSN+CqpY6wwCFGud8iNbfptna 6111UFJ3xg99+8ul4j4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbk-00AgCT-1W; Fri, 05 May 2023 11:28:16 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putbe-00Ag8J-2J; Fri, 05 May 2023 11:28:12 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A5E623200907; Fri, 5 May 2023 07:28:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 05 May 2023 07:28:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286089; x=1683372489; bh=sdlpRXLo9d8u/J02F/pSNfCPqLv0NBH2V0R YgvZa5mY=; b=JRNlKYx5ZjG7zOJpXUi3/XJSejKbZX1IEatjK+1LzXY09LJGIj7 b1eMzGYQcDKMI4wVEV2C6OzNSN8N2+Isz5YyvwZoHGaUswBpKHkTIhzO1pYUGnZR kqiWNG+p8VNNX5LGxZP1CplMliPHQ81KOLQ+5se8n6UBb6UnnXIq4S49tiUePC0Y 6qe3iP9fnBoFuAU3YAnSsXzgdMQxNPRmmHFXxS2y6Zyp4qIks/ZnFqTbaPTFKOKN vNe7ZlYYjUIvUE+M+ELC70JKlAF7A77ZYYPa3vVGTH4TAuCz7FrwrAtd4TgWTTvZ pm2w0Wm8muoP/2goGduAbvztEp6xfry3K5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286089; x=1683372489; bh=sdlpRXLo9d8u/J02F/pSNfCPqLv0NBH2V0R YgvZa5mY=; b=NUCmixA9zL8L/xBglG89pLuYW0lZeXXEAbPbUgdjtmkUnJ5s7ko L8WugmAFgNNZsF1pZ8TW/H2aE+W9JN9GgTSiOvYwKw9fYhw5LCxAkCDJPnTVWXT8 c+ZtFj9TUW6Cmb01rdQlvf2uGht73/nvsCqhR7mM2+mftymVjnR2kNh69nM8zyQz eIneK4xFDDQIUbUJXsGdDSaW5z4yFphLMxC2nD9qWTWSAOD4SsF8fVpDkenwGajh f8Xydgfm966mPT0GJvVDF1Kr5BXYlpX4OCtIH0M47nNCIacC4Mwg2LN76FgOnFZe UTl7ZsLIXRJiOflWiOmaBnbaaFZV6BvrudQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:28:08 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:50 +0200 Subject: [PATCH v4 48/68] clk: actions: composite: fact: Switch to determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-48-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , linux-actions@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2964; i=maxime@cerno.tech; h=from:subject:message-id; bh=uyBaAmdNnpNkmO3cXNcw5v1QgunRrFr2A3EejTTdAcw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5dk5XiULZ1mt7v/ydqcltQ5arNe2MwO/b0pW76nWb+0 gv9DRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACai8oSR4eC6gJLpr+pi5yVslVlx8P yLFXyvb3j1ZbGf2VhgrN220Yjhr0Cl9lkWabGDHiduBn3Qfa6mcMLHJm2lTr74pwWcqk1NDAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042810_787220_13F6BE2B X-CRM114-Status: GOOD ( 18.81 ) 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 The Actions composite factor clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: "Andreas Färber" Cc: Manivannan Sadhasivam Cc: linux-actions@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/actions/owl-composite.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/clk/actions/owl-composite.c b/drivers/clk/actions/owl-composite.c index 2f1e282134b2..48f177f6ce9c 100644 --- a/drivers/clk/actions/owl-composite.c +++ b/drivers/clk/actions/owl-composite.c @@ -86,14 +86,20 @@ static int owl_comp_div_set_rate(struct clk_hw *hw, unsigned long rate, rate, parent_rate); } -static long owl_comp_fact_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static int owl_comp_fact_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct owl_composite *comp = hw_to_owl_comp(hw); + long rate; - return owl_factor_helper_round_rate(&comp->common, - &comp->rate.factor_hw, - rate, parent_rate); + rate = owl_factor_helper_round_rate(&comp->common, + &comp->rate.factor_hw, + req->rate, &req->best_parent_rate); + if (rate < 0) + return rate; + + req->rate = rate; + return 0; } static unsigned long owl_comp_fact_recalc_rate(struct clk_hw *hw, @@ -175,7 +181,7 @@ const struct clk_ops owl_comp_fact_ops = { .is_enabled = owl_comp_is_enabled, /* fact_ops */ - .round_rate = owl_comp_fact_round_rate, + .determine_rate = owl_comp_fact_determine_rate, .recalc_rate = owl_comp_fact_recalc_rate, .set_rate = owl_comp_fact_set_rate, }; From patchwork Fri May 5 11:25:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232486 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 0DFE1C77B7F for ; Fri, 5 May 2023 11:29:23 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=W/rFGkrWx6+abuA/fpe6gCTx+YM+pg77nl9+0eqDA7s=; b=y/ZUx7PGMuXvy0 EPITky9V1eIoe1XjnfyajqHnttb1VVUDkyR739i0BYSqtH6JQy5pE9/ZBqARDjYTbl7fFQfilzjmg V0/FkJZayvo4hfwO9wdWqn1jozWdYHt4E4j3hHeflmH3LxKWkf16hXvCjArA8KHPqXZ8kAbOKjKfs +EOBJk1lagFDKB3wQNtJK6E/RTFSp6lrsNXhgiGzjtsUUwEnkrxF/5F8hS16xw0GB0C3TAcje6rwB KtokodoQMTQfyIgTu75scay/BhLzYX69fQeFtlOUg6YR+eqszp0n05Dcl1WpnuNOzjbrRy4RbEddj a0rt14H+qx5cObxr3BFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putbo-00AgG3-1t; Fri, 05 May 2023 11:28:20 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putbh-00AgAO-2h for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:28:16 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id B542B320030E; Fri, 5 May 2023 07:28:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 05 May 2023 07:28:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286092; x=1683372492; bh=ZL1o1TNKbYDVKyE4kDrtDmEhXk1RcDLRMHB Arg+j7Qo=; b=jGXFwXmY8pg3srh5sSfuY5pN701WOIIRXwtqX6x57G5dvAlIgmq uJ3sWCBxKtbemVvKkW41YwAotGCqt8/2jaDafEuon34fbq+IVgnarOO7huvhz3ky mf3kX7ibziT1XAp1ji639NKMJObsAw6uP/sADI0rZKvMlaD8pPULqESvnLjkcwnm yHRZGx4koETCfZ+pnYYSmTIPL/YcVpjI27iq99aiG+05saSqANPs0tRc8wZs2BuT ue416hgSrZf5JVo/u1RlWm3Si2Sc62Nrzm68BQuIjkoXVRZbUJnkYhZQRnxdB59c adlglNQ8o+B+w1ui0tNJHIcAGD72NoDNsgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286092; x=1683372492; bh=ZL1o1TNKbYDVKyE4kDrtDmEhXk1RcDLRMHB Arg+j7Qo=; b=UgEckuuZnfwhXGnSKXdKg4iRbs6y34PTnDh/Rm0VGslX3SngVpY Up3PFqWIN7bzJWRCkp9tggCIvUXunR7pc6hPIUwq2YXTpCQ0fg86PAsjM+9u39Vg 1OLbTnz5Xq84/ymL/Pij2Wtv7CVH+O98SwdO6YH6lzt/31Af0Ff/vLf3ERxD+hjb HkzSsZIGuNDWpGGfqjeVoaTTNRw+9RWSCPJHKjeAOudcDugbpYQ21Sw3sCj7OhmB ngG04ABOWWOFEP5Ib9GYVgja9jWcg/qgGtWhXESNsFd098T69uV3s7H8wdXvLnqf l6nJwU1s+o7i+wthFbA5gVcSZK8VYGfFwbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepleenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:28:11 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:25:51 +0200 Subject: [PATCH v4 49/68] clk: at91: smd: Switch to determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-49-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3550; i=maxime@cerno.tech; h=from:subject:message-id; bh=grvfNEMJDxKC39E6gpEk+/fzaJf3lwNJrJ82SYiqrIg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5e4Z+dNUNeaxeK//vuWGuH/VqlC9WZb2bZYiR1IU999 1Seio5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABPZKcHwT5HjVA5nqrosw8el75cdaJ wolLfFpnev6iYeJTYvXp7OdkaGS7stK1+timTd92Nf9wYtz9dqISp22W8MVVRv6mza3irPAAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042813_961606_BCA73211 X-CRM114-Status: GOOD ( 20.02 ) 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: , Cc: Alexandre Belloni , linux-clk@vger.kernel.org, Maxime Ripard , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Atmel SAM9x5 SMD clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: Nicolas Ferre Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Maxime Ripard --- drivers/clk/at91/clk-smd.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c index 160378438f1b..09c649c8598e 100644 --- a/drivers/clk/at91/clk-smd.c +++ b/drivers/clk/at91/clk-smd.c @@ -36,26 +36,31 @@ static unsigned long at91sam9x5_clk_smd_recalc_rate(struct clk_hw *hw, return parent_rate / (smddiv + 1); } -static long at91sam9x5_clk_smd_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static int at91sam9x5_clk_smd_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { unsigned long div; unsigned long bestrate; unsigned long tmp; - if (rate >= *parent_rate) - return *parent_rate; + if (req->rate >= req->best_parent_rate) { + req->rate = req->best_parent_rate; + return 0; + } - div = *parent_rate / rate; - if (div > SMD_MAX_DIV) - return *parent_rate / (SMD_MAX_DIV + 1); + div = req->best_parent_rate / req->rate; + if (div > SMD_MAX_DIV) { + req->rate = req->best_parent_rate / (SMD_MAX_DIV + 1); + return 0; + } - bestrate = *parent_rate / div; - tmp = *parent_rate / (div + 1); - if (bestrate - rate > rate - tmp) + bestrate = req->best_parent_rate / div; + tmp = req->best_parent_rate / (div + 1); + if (bestrate - req->rate > req->rate - tmp) bestrate = tmp; - return bestrate; + req->rate = bestrate; + return 0; } static int at91sam9x5_clk_smd_set_parent(struct clk_hw *hw, u8 index) @@ -98,7 +103,7 @@ static int at91sam9x5_clk_smd_set_rate(struct clk_hw *hw, unsigned long rate, static const struct clk_ops at91sam9x5_smd_ops = { .recalc_rate = at91sam9x5_clk_smd_recalc_rate, - .round_rate = at91sam9x5_clk_smd_round_rate, + .determine_rate = at91sam9x5_clk_smd_determine_rate, .get_parent = at91sam9x5_clk_smd_get_parent, .set_parent = at91sam9x5_clk_smd_set_parent, .set_rate = at91sam9x5_clk_smd_set_rate, From patchwork Fri May 5 11:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232487 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 D7663C7EE22 for ; Fri, 5 May 2023 11:29:43 +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=S6Rj8/DtpNy626xKKT+oxkvi433+BN+JvwK/U4GvZB4=; b=qmNSVgRdhXyzVc 1GQlZD/xpubf1GnWgN+w2kyizeNhv52uagTvatVPNLLZiBygMSMGHQr4d36ym/4nLaoolcT2M755o 8Du/iFDK7vZeyNb/W8g0zURLzpUff4slT23tJEXQ1XoZMigTromHycjKrJJfidFeut5MUY6YAI+L+ f3G1IISM/kImkXl638e4A7OJabFTBx/qKsmfIfHS1W2Ld5fuX8v3UX587Cj7oPuHeiqjThB89NXio hcVGpyIgewdA5tdEibgMq5PYJ9tGpbAz/SvLLjMtqGJSA8r8sKp1KaIAbBdZstXfhVd+JFKNkumaK zU6ng2h8FCioYvfD6uPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putcB-00AgZ1-0W; Fri, 05 May 2023 11:28:43 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putc7-00AgVm-1r for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:28:41 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2766B320030E; Fri, 5 May 2023 07:28:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 05 May 2023 07:28:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286117; x=1683372517; bh=ER+fet4v2MEKBKvQO/8aEld1CvPdQ/gKISS pKV1SD6E=; b=E2zEof6/fOECfswzd8eAZOlgT/GrQS0Hg54u1s1kq4GWUhuwDlL P2ZOQ+VuS74TmmRjEwYCwfAjWPV6TAW3gJU+Xs5HmnOyH6pJRpNI5+O72uMc8JJt BNYRIU9VLJWC+6QYTzJ0CrNJdweiEb4UnxayCsHNn9XLOtdmoFgka3s/StRNiNdU yi9he8TtLJ5uR+osv7BLE5da6niE54fBw+j/WDOa9Xqy5fNSqL/mjtsIYhqpWOgp LseQiZP0WtALnvUTOj2fIVRIn2vBH6YrWPYDEdl6L5F2OQ+MGm8h3hqHsU3NxGQ0 XFVmpu56+ov8FMsZWDCIv4xmIEo0tHmDJKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286117; x=1683372517; bh=ER+fet4v2MEKBKvQO/8aEld1CvPdQ/gKISS pKV1SD6E=; b=WzCtN4+mojNDs8ZeOFPzsr7Sz03IogA/IkKyslKPfI9+MJFkVHw FC/QU4lsFP/NscmrlYCRuFQh1f9Pwipa5zGlQdFPHkpeqVeb34siq6T4YumBUqqQ p90e4mCkBxKvO8yr/5Gk46Ha8WhC+HnID6G9lwDOhN62CjxD6cLWZQNpYtTMiAa5 m2XoqZzz/yBmeQ+49eV3kDp8TCx6qDIP5q4N0VKGVh2zfOJep53dhcCEOE1ufl8W 09Gvd+FwuoNhgUqnKsoRtDI6Dnyz3W5SLlGBtFRdMIOR/xuuudQfKsJQbL77QClP a7QfpRfEuhG9k1BR9nL7ukgd87a3VMaLSvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepudegnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:28:37 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:26:00 +0200 Subject: [PATCH v4 58/68] clk: imx: scu: Switch to determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-58-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Abel Vesa , Fabio Estevam , Peng Fan , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3048; i=maxime@cerno.tech; h=from:subject:message-id; bh=hvDwbs5hvcxU7mAGefyGmd/4UuO2+LMXGrKQwF6RW1w=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5fKMFps/SV26inbkQtv3nIz/HjQ8tfcVuHFmSrHLrFc ji3zOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRDfwM/8P5Kw7tYT1SMW2Tdveyk9 JbPeptTq87x6u477texonG/JuMDCeM1AUcRB/u07WPiN3QcS5uyUvV6Tv0/ux4/2vLvL/+NcwA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042839_681120_7AB3A4F7 X-CRM114-Status: GOOD ( 21.07 ) 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 The iMX SCU clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. The round_rate() implementation being shared with other clocks, it's not removed. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Abel Vesa Cc: Fabio Estevam Cc: Peng Fan Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team Cc: Pengutronix Kernel Team Signed-off-by: Maxime Ripard --- drivers/clk/imx/clk-scu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index 417f893f8895..725b7b3edb63 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -250,6 +250,23 @@ static unsigned long clk_scu_recalc_rate(struct clk_hw *hw, return le32_to_cpu(msg.data.resp.rate); } +/* + * clk_scu_determine_rate - Returns the closest rate for a SCU clock + * @hw: clock to round rate for + * @req: clock rate request + * + * Returns 0 on success, a negative error on failure + */ +static int clk_scu_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + /* + * Assume we support all the requested rate and let the SCU firmware + * to handle the left work + */ + return 0; +} + /* * clk_scu_round_rate - Round clock rate for a SCU clock * @hw: clock to round rate for @@ -425,7 +442,7 @@ static void clk_scu_unprepare(struct clk_hw *hw) static const struct clk_ops clk_scu_ops = { .recalc_rate = clk_scu_recalc_rate, - .round_rate = clk_scu_round_rate, + .determine_rate = clk_scu_determine_rate, .set_rate = clk_scu_set_rate, .get_parent = clk_scu_get_parent, .set_parent = clk_scu_set_parent, From patchwork Fri May 5 11:26:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13232488 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 38EF5C77B7F for ; Fri, 5 May 2023 11:30:01 +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=6+IpaPG/FjhD+iUJx0MUFMB19kSWoZW/zEquMUvXj6Q=; b=kKS5twkfo/Rh9U LTMQqvISbi8wS7poSi5XsCpoihx9CeSQGMH4GaxiaXsKiemOc9JR9pRHL/PAPjF2gy+1PfWUrMXIr UVCN34VBmI1q1/lGeYBooTrCstniDFv1zwDA+b+ZwuCKpSJKkrnnrplw7UrK1N90fwiOS8swpfngE 5dBE7xszVzoFLjOoi0SqWjYGQHKTilJh7Nabcfgg5dgAAfi+mMHB2yXQOdRJJkH4lbKfckMVWeGNG JtHZSiaoM6VgTeIGMq9vlaAnTD6iTObqxIWJ/K5zrIB2qAL05V+YKkEEjQtGdnkxJDA8iD9ows2/L 2FbGYQddyTmJ8A5GYnpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1putcT-00Agm6-2L; Fri, 05 May 2023 11:29:01 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1putcP-00Agit-1M for linux-arm-kernel@lists.infradead.org; Fri, 05 May 2023 11:28:59 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 55EF83200A52; Fri, 5 May 2023 07:28:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 05 May 2023 07:28:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1683286135; x=1683372535; bh=VpZLVE8EhSTkzWzw7YaHrjXzN/zZ7xAYa0f PgC8F7To=; b=otuWj4sxN+ROryqFvQ8d9wQtEzOXg9EE9ny77dFFT6gAk4LcoQB pfu+mGkcwLIeuaaA1LB9gzUxi7sc35Zn+Z55mP3DxixP1FDTu9FfQWWZkYK18Yyb a4HZ130reFI3ft57cym+lry6htvBqcBLI3G8HXeIG9emVT2EWn8tjbbgi7auaGXs UjjihR57LA7iXT0cdeXGn+BscCmdH0/mUGBeeFHqElNIcdyiGBAJLbajWFo7uBDh p+rmx6oovpaA5wbuyH/6ETOgoWtEaFSLEmw3H2SnBs9wSU7n88M0GqnxOYBd2jm/ 8rBrwJYTLtLnHS9uqdFgP6jcPBmCYNypRsg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683286135; x=1683372535; bh=VpZLVE8EhSTkzWzw7YaHrjXzN/zZ7xAYa0f PgC8F7To=; b=P1TRGiZrVqz1sVJdTqH1J3Pnel2zuQgUsQW3jyzW0EfQKFjBNwK /ynZHjc9P/VGv0pxCcn9C6uqNy8Xxgaih9D3kPifjkWJ/0qJ6rA+kUFVhDuMoO3P 12k9Nv/ok/3Jx6fkwKlO1Qmus14Gu0CuABAQvH2jeM7F8zIWqrxtJOz5z45068bW uINL4n1Iykw8RIdmTSDCww3aJYQ+5zQLF1v4FcHY/8uToIG16EqVv2X9XzRAE++p lpNeFmpzmxySqQ2E1mLgLbge6ejBV8ah53gHsge9natgnB+2l5PpcKHXlAGQz9ZG 2tG5gZVDmWTlhieq+4cEjHOGu9oWH/6fQag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefvddggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvedvleeijeegvdekffehkeehieelhfeggfffheetkeeuledvtdeuffeh teeltdffnecuvehluhhsthgvrhfuihiivgepudeinecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 May 2023 07:28:55 -0400 (EDT) From: Maxime Ripard Date: Fri, 05 May 2023 13:26:05 +0200 Subject: [PATCH v4 63/68] clk: stm32: composite: Switch to determine_rate MIME-Version: 1.0 Message-Id: <20221018-clk-range-checks-fixes-v4-63-971d5077e7d2@cerno.tech> References: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Maxime Ripard , Alexandre Torgue , Maxime Coquelin , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4039; i=maxime@cerno.tech; h=from:subject:message-id; bh=CIEIIIZ1agmth1FxcZ4Gkd6VtvFomP0US5DsP0ecWPQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkhz5d+1rm+I7l9d8ncxgfx0+OqtbzeZoddNPl0IF3m9+6b q69ZdZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiT7UZ/hnaNyxgvDB7Rs58hkvxsw WC3uWnK3w9YelhPUH/xykFwXCGfypVbJaMz9iMvxneurXnUeDNhqNrlzrzOnu9DIy6fUH4Fj8A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230505_042857_514663_92D4EFF1 X-CRM114-Status: GOOD ( 20.68 ) 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 The STM32 composite clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Alexandre Torgue Cc: Maxime Coquelin Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Maxime Ripard --- drivers/clk/stm32/clk-stm32-core.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c index 3247539683c9..d5aa09e9fce4 100644 --- a/drivers/clk/stm32/clk-stm32-core.c +++ b/drivers/clk/stm32/clk-stm32-core.c @@ -426,15 +426,15 @@ static unsigned long clk_stm32_composite_recalc_rate(struct clk_hw *hw, composite->div_id, parent_rate); } -static long clk_stm32_composite_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) +static int clk_stm32_composite_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct clk_stm32_composite *composite = to_clk_stm32_composite(hw); - const struct stm32_div_cfg *divider; + unsigned long rate; if (composite->div_id == NO_STM32_DIV) - return rate; + return 0; divider = &composite->clock_data->dividers[composite->div_id]; @@ -445,14 +445,24 @@ static long clk_stm32_composite_round_rate(struct clk_hw *hw, unsigned long rate val = readl(composite->base + divider->offset) >> divider->shift; val &= clk_div_mask(divider->width); - return divider_ro_round_rate(hw, rate, prate, divider->table, - divider->width, divider->flags, - val); + rate = divider_ro_round_rate(hw, req->rate, &req->best_parent_rate, + divider->table, divider->width, divider->flags, + val); + if (rate < 0) + return rate; + + req->rate = rate; + return 0; } - return divider_round_rate_parent(hw, clk_hw_get_parent(hw), - rate, prate, divider->table, - divider->width, divider->flags); + rate = divider_round_rate_parent(hw, clk_hw_get_parent(hw), + req->rate, &req->best_parent_rate, + divider->table, divider->width, divider->flags); + if (rate < 0) + return rate; + + req->rate = rate; + return 0; } static u8 clk_stm32_composite_get_parent(struct clk_hw *hw) @@ -602,7 +612,7 @@ static void clk_stm32_composite_disable_unused(struct clk_hw *hw) const struct clk_ops clk_stm32_composite_ops = { .set_rate = clk_stm32_composite_set_rate, .recalc_rate = clk_stm32_composite_recalc_rate, - .round_rate = clk_stm32_composite_round_rate, + .determine_rate = clk_stm32_composite_determine_rate, .get_parent = clk_stm32_composite_get_parent, .set_parent = clk_stm32_composite_set_parent, .enable = clk_stm32_composite_gate_enable,