From patchwork Sun Sep 17 22:39:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388719 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 3C96ECD13CF for ; Sun, 17 Sep 2023 22:41:08 +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=8LQaCwRXoelMAbS8FgIEtPTJUuIJA9/P2WiDudUWZs4=; b=Yd4i9Ug7mrhpUE 1bB5w8mThOhes3VwGAIGcNzVRz7jeo8hbmAHWvv4Zjp3w7OHd7qKYXBGi174MZzNn0Ry81HNnj2XA NKvGWJQkrQUaLX/T0KkkiRStmNYB+eJamOf1QJZelp5PLSNg2Wwdc8Pf/jbS7h21eDkW9DBnDWbai psp+tjQTh0GDhVEb01jnfMolvRFuR/5hgCpjx9Tsxe2ZziautfqoaDX7eMWFCH9OLuRpZBy3BuEgk vx1G9NzjmG1gWr11NyZlG5FMA2suNCNkQcrd6wnTHjxkIr9q01/X30/1lCLsKJIE804NLfVe1hciy jg1AjZRwD8AiLD9n/kqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RX-00E51h-1A; Sun, 17 Sep 2023 22:40:43 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RN-00E4x6-2r for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:37 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-401b393ddd2so44863405e9.0 for ; Sun, 17 Sep 2023 15:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990432; x=1695595232; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EmO+eglOY/5LVFBKrEFIX+3fDVqUYjkPrRJqtH5JB30=; b=eG7CLl5Vm+Mn0n/ANth9N1HPkq3wG9FgbRETAdyMxf2IoPU1cbhy3EKCXith3dZyTl Now4VPCYTfIL/XVvI+dj32ClPGTCizL4PKw5/XGHTpuWNrYNaVrPv/CYEbC4+eXO70ju l91dPolQ2/0HGLVRnEiL2owYHt29d7Gx6CFbsifQ576a6tHIhd5ZwkInLBvaso8eR7ZT EF+4vU/bHLRw6F2aQtRuFy5qgdjYP0xDwOQL4WBjuBGybhuVJguFJdIhilU6x1WpA1kW 15SDEMFpHG1Fg3AbkBCp9scwh6obV9AhD+Qh4r3JsV4Mp7XOlLxrQAUOce4Fz65za6zU 7Lsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990432; x=1695595232; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EmO+eglOY/5LVFBKrEFIX+3fDVqUYjkPrRJqtH5JB30=; b=IOCwhGBjd2vsKnNv9yf5joaLbN38wVw7wANvgq3ytJUBi/A8OIc1Oe/LxE7/FGqb5o /SsFORERv/I7hBEKLXwYccVYpQCxF96MWJn+mXdCIcszDpR2q/hNoc+vY+INH6pBtGLY 1dCZCtv58ZBq4wZLsyvInX0+uxdljBmeOiU1uSQb6hn1rUqSsTPzH1clhNt6h48AEggZ r0cT5EGFXAh2t3xcaPk+LCcvZC+V2kSZyTqYzBB4mEi7eUcJfb0Pupe/+3ghgnQZO3UD lWPY5USdw2f2hntaiajFamGyIkVPet9yUCDVw7GWdz1kMRuuDs55ggneIw9BbFhBu5x3 R4sQ== X-Gm-Message-State: AOJu0YxMx1eAnm+53ew9D4rPGhIYeSGsC40PL818+Ta3wV+cGMm+aKRW UDj+Enw+BmPTPME50ZiaJ3U= X-Google-Smtp-Source: AGHT+IEMfrglMLkY6LiOZruW5Eu9EIdyssNQV8UWd87FhNhVYDTWF2RQUGOCbHKA/qe4SgVjsAspLg== X-Received: by 2002:a7b:cc84:0:b0:3fe:1c33:2814 with SMTP id p4-20020a7bcc84000000b003fe1c332814mr7137683wma.30.1694990431717; Sun, 17 Sep 2023 15:40:31 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:31 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:39:57 +0200 Subject: [PATCH 01/13] arm64: dts: imx8mp: lvds_bridge: use root instead of composite MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-1-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154033_926102_4648DE38 X-CRM114-Status: GOOD ( 12.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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara Use the actual root node of the media_ldb clock for the lvds_bridge. Signed-off-by: Benjamin Bara --- arch/arm64/boot/dts/freescale/imx8mp.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi index 6f2f50e1639c..c946749a3d73 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi @@ -1760,7 +1760,7 @@ lvds_bridge: bridge@5c { compatible = "fsl,imx8mp-ldb"; reg = <0x5c 0x4>, <0x128 0x4>; reg-names = "ldb", "lvds"; - clocks = <&clk IMX8MP_CLK_MEDIA_LDB>; + clocks = <&clk IMX8MP_CLK_MEDIA_LDB_ROOT>; clock-names = "ldb"; assigned-clocks = <&clk IMX8MP_CLK_MEDIA_LDB>; assigned-clock-parents = <&clk IMX8MP_VIDEO_PLL1_OUT>; From patchwork Sun Sep 17 22:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388718 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 89788CD37B4 for ; Sun, 17 Sep 2023 22:41:07 +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=3QhLTN8pFqexAPdYGSNQEnmqRliVyA9fmdYCpBjyFfc=; b=Rnv57Ky0I+U4eJ lj3NVRCZ4ZzBkZKZHCrQhhEZNpGTxzRCf7zt/GSulDuv9Kn9mCEuN1lu5oFaJkwCXKhVZVG6Kod4g WXV8yww3mkoZ4W3Dtqjv6NfSujMtv/Py8hIwnpeHeM1whxggpAtY3lTBNU6VG3eOIR0r/RtqOaFE5 mvaHrsW7LOk5DAv6uN5YXh6tynimBMAGZBoJtwpehtMWlDcy3qJmQswXVtsAKFhUzUZUWv0xBvoS3 Bq+IXR2Dc82XrGC+aU2ztrYdJqEblAav7blOjHUhWGsM9jUSxBoffXnvthG0cCMS3UjVw5ldAVwea Bi+rxdHnL891bSAhWIHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RZ-00E533-1B; Sun, 17 Sep 2023 22:40:45 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RO-00E4xK-1i for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:39 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31fe3426a61so3079084f8f.1 for ; Sun, 17 Sep 2023 15:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990433; x=1695595233; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kzm9ZqjvlbCK0SNFX+TbEk59mYOrgBPner6DepnRFUs=; b=MAtvA4Wa1tOmv+XYdJsAVqoMZQyK6UMK6MlUVJ5egFPTEv1neRR2XgUGjoaWIBbZeD +hoD+9MXi9dBmLo/TkM7HA6C/ThXsIg2ciYvTzpblfBHcN5WwZEscq6pXPX5czZ9DZ7f 4E+SWY/vdQ1Z7MM9hgw3n9M6hf1uUA0YONx/0yuGN94KzBYRLgdjwd80hbaYS451N4RE 6EonwZsP1oBlnivyF4lLKpc8nOd2c5sWkIdaAqt9u2X5ryszZQmJfO01y5wWZIDS2lUT ma1oW4PI0jCiNShWexry9bP/BLpD/MNrj2rAWZs/UbHTllwIeNkY11qf4fGmDn2/nt6+ shnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990433; x=1695595233; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kzm9ZqjvlbCK0SNFX+TbEk59mYOrgBPner6DepnRFUs=; b=QzW7NTEWr8ve0pLgq98WcAcfShK1RENuQS42VyhbLuelStRpFCtrAA+yy06XVEmi/y 9pA6Y/4Ja/zR9pG5jHvtwioNVPWXzNoFDpmJzErkI0FN7b1oM8gS6j206bwwbJmYv+Om YmNsSqwOBe+B+7steHeVIzzAkbe0yOF2byWZc+XberWSeRNw3xjO63SJsTG0ksYCnG6K ecKzOGsXQFdwh3ugIWTMtssfuHJP+rObwp53TTsxsakWiaRRgNEmIdnegBACuZ9HUB4d 0pjCwZzsdU6DIgWCT9imnAOMUNYjGBMDMbNFCWWQdCBLozyj367hC8jBYZ4IpE3tvwEH 6O0Q== X-Gm-Message-State: AOJu0Ywe2yxYV1JzLXzcq+7rME612k6FFQV/aHGeXw4k+V797znabPmX wLmDcktDgLaR6BkwxkmEG+M= X-Google-Smtp-Source: AGHT+IGWN1013/FPAnQNrT8Yy8PnHN/jWTSwQasqirYksiAE84RBS07CHFOeC869nuq6MRWGumVInw== X-Received: by 2002:a5d:6f0e:0:b0:321:4c7e:45e2 with SMTP id ay14-20020a5d6f0e000000b003214c7e45e2mr1505903wrb.8.1694990432669; Sun, 17 Sep 2023 15:40:32 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:32 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:39:58 +0200 Subject: [PATCH 02/13] arm64: dts: imx8mp: re-parent IMX8MP_CLK_MEDIA_MIPI_PHY1_REF MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-2-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara , Adam Ford X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154034_567809_3603BC8E X-CRM114-Status: GOOD ( 11.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara Similar to commit 07bb2e368820 ("arm64: dts: imx8mp: Fix video clock parents") the parent of IMX8MP_CLK_MEDIA_MIPI_PHY1_REF should be set in the media_blk_ctrl. Currently, if mipi_dsi is not in use, its parent is set to IMX8MP_VIDEO_PLL1_OUT, and might therefore clash with the constraints coming from a panel. Cc: Adam Ford Signed-off-by: Benjamin Bara --- arch/arm64/boot/dts/freescale/imx8mp.dtsi | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi index c946749a3d73..9539d747e28e 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi @@ -1640,11 +1640,6 @@ mipi_dsi: dsi@32e60000 { clocks = <&clk IMX8MP_CLK_MEDIA_APB_ROOT>, <&clk IMX8MP_CLK_MEDIA_MIPI_PHY1_REF>; clock-names = "bus_clk", "sclk_mipi"; - assigned-clocks = <&clk IMX8MP_CLK_MEDIA_APB>, - <&clk IMX8MP_CLK_MEDIA_MIPI_PHY1_REF>; - assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_800M>, - <&clk IMX8MP_CLK_24M>; - assigned-clock-rates = <200000000>, <24000000>; samsung,pll-clock-frequency = <24000000>; interrupts = ; power-domains = <&media_blk_ctrl IMX8MP_MEDIABLK_PD_MIPI_DSI_1>; @@ -1747,13 +1742,16 @@ media_blk_ctrl: blk-ctrl@32ec0000 { <&clk IMX8MP_CLK_MEDIA_APB>, <&clk IMX8MP_CLK_MEDIA_DISP1_PIX>, <&clk IMX8MP_CLK_MEDIA_DISP2_PIX>, - <&clk IMX8MP_VIDEO_PLL1>; + <&clk IMX8MP_VIDEO_PLL1>, + <&clk IMX8MP_CLK_MEDIA_MIPI_PHY1_REF>; assigned-clock-parents = <&clk IMX8MP_SYS_PLL2_1000M>, <&clk IMX8MP_SYS_PLL1_800M>, <&clk IMX8MP_VIDEO_PLL1_OUT>, - <&clk IMX8MP_VIDEO_PLL1_OUT>; + <&clk IMX8MP_VIDEO_PLL1_OUT>, + <&clk IMX8MP_CLK_24M>; assigned-clock-rates = <500000000>, <200000000>, - <0>, <0>, <1039500000>; + <0>, <0>, <1039500000>, + <24000000>; #power-domain-cells = <1>; lvds_bridge: bridge@5c { From patchwork Sun Sep 17 22:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388724 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 02E87CD13D3 for ; Sun, 17 Sep 2023 22:41:11 +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=GxR+6VcbBd4wcqa6slsEC6dclMk0ORhgWVy6YAM/skY=; b=ZcHNxZloY81tP7 JnGHiaRmeObF7bS8huFVgRtD7Zp+3E+O8ZdfWZHbV02U9+MpBkGQRQWCugnd6JHml3xokPkHuSO4/ ZTj9uyqnZ9CzxAITjVT6CMxsb/n/vt6bAMz23XWc8Pt92pvXKyMB4audzwid+hqkC6tV/1n02J/OT 2uZgzWcmOSUe7n/5/nz7NySFuDivDAkfdLuEtZmWpkl5A0uocr/ENNOfZpEoNXSFsV8ZucbGjvYGb 5x62OvdGg66QQTK081cCQC+Jy0wLDxtYBgu/3l/tomRy9w09AypUo0CRLjLfKDNdq5jBkqIJ6+Jmt QwQBGNzxTWaDBWdbc3Iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RY-00E52X-1s; Sun, 17 Sep 2023 22:40:44 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RP-00E4xb-1r for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:39 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-401187f8071so25374415e9.0 for ; Sun, 17 Sep 2023 15:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990434; x=1695595234; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AJPaLL3gJNqPRX6sTrQa6Jnq3juPdy0EeCdpo1oNzQw=; b=StM2J/VvNrtUwy7hZ88NIOH7v7XhoBjpOMMUBwlBev9feFVHwZHJEIr8Hv71H67EVq i7AJHibYwUtQv7BMoAiw7Qfeoy8fXf2XlagvR5XX4mjLpu6oN9ThfaxhDwHAwY8RB1sf XP10FCkfyGLcJscYT5I3NTDRXNqTpt3rckgw2Gtq7xZlPHoDDI29Q3Erksqqu3KKN335 WyHhCwTqvhnNgdmuY6j+9H9R1gOjC0xxi1glddrx1rQZNtYAzTu1CzMG3J4xCLwKMHND /v99LuUbrpJ3nHjyRUXWD9Gt+T5uDf0voQOLin1oodLa2al1TsCLipW6qiMJvmgURiRb XpLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990434; x=1695595234; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AJPaLL3gJNqPRX6sTrQa6Jnq3juPdy0EeCdpo1oNzQw=; b=K0GK6bGF2Y72q0mg2noYWPi8Q8bkQUuF9f6zXqBZurJSKPPf92EzmLEEq/TtRd+FMk p4Tp0ZcpbbNLn7QKtJ0l5PV39a3b7WsgP6IVz/ufh6L2BEQhvWBxJlCAFhuQpxKbT3DH cKXV6gytE6iEyP9k42NDgpxpXbGq+aMzAbElSID4RCAoatGBCQkW7KL/rP7bX+ROjDMk +7zf7WjLbO8nl+R3SfXekl8duhPJpByX+9VzY61jMWsq0OS/XBAmjsJ0/vqxVhQeXJZx Vi/TpMZrI/kBuDBJOGNCafrZr+fQTGxpbBDdvohUobc7VvjXeLIcCStCXdl2qk4e4Oig 3rwA== X-Gm-Message-State: AOJu0YyCHFLW+ZUr2BgfcNziTUyZbc1FPIOingpKOcBXcijC8mWu3a61 mzTHJHi0MLKbOS2VoyCEANc= X-Google-Smtp-Source: AGHT+IHAtcxw7kNPCGsfPeyvRci6B2TGJjm5SaBwDRo/wssjZoEUG1YriSdAYHy4qrPTLAuYhmg79A== X-Received: by 2002:a05:600c:1914:b0:401:bcec:be3e with SMTP id j20-20020a05600c191400b00401bcecbe3emr7808004wmq.17.1694990433512; Sun, 17 Sep 2023 15:40:33 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:33 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:39:59 +0200 Subject: [PATCH 03/13] clk: implement clk_hw_set_rate() MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-3-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154035_611595_FF5A7FD4 X-CRM114-Status: GOOD ( 14.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara This function can be used to set the rate of a clock hardware from a driver, e.g. to adapt the rate to a clock change coming from the parent. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 15 +++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c249f9791ae8..3e222802b712 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2462,6 +2462,21 @@ static int clk_core_set_rate_nolock(struct clk_core *core, return ret; } +int clk_hw_set_rate(struct clk_hw *hw, unsigned long req_rate) +{ + /* A rate change is ongoing, so just target the required rate. + * Note: this does not work if one clock along the line has + * CLK_RECALC_NEW_RATES active, as this overwrites the new_rate again. + */ + if (hw->core->new_rate != hw->core->rate) { + hw->core->new_rate = req_rate; + return 0; + } + + return clk_core_set_rate_nolock(hw->core, req_rate); +} +EXPORT_SYMBOL_GPL(clk_hw_set_rate); + /** * clk_set_rate - specify a new rate for clk * @clk: the clk whose rate is being changed diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index ec32ec58c59f..3fb99ed5e8d9 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -1316,6 +1316,7 @@ int clk_hw_get_parent_index(struct clk_hw *hw); int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *new_parent); unsigned int __clk_get_enable_count(struct clk *clk); unsigned long clk_hw_get_rate(const struct clk_hw *hw); +int clk_hw_set_rate(struct clk_hw *hw, unsigned long req_rate); unsigned long clk_hw_get_flags(const struct clk_hw *hw); #define clk_hw_can_set_rate_parent(hw) \ (clk_hw_get_flags((hw)) & CLK_SET_RATE_PARENT) From patchwork Sun Sep 17 22:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388720 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 DD9E9CD13D1 for ; Sun, 17 Sep 2023 22:41:08 +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=Npu3aQtNhf6KKnweDLnA7fdcpn/gX6ZEVvNJinu/VvE=; b=rZk6TjrRkDak1A L/vviOmE2qK9LUYXdYj1R5w5otDFRGBX2IC7e2f3ZxEvOTztUSvVnz8IbG+CKI3O+pbeCLjZWHswB Omk76+xfuV9hQ6jsJ4FsFd7nF52kUzsSoH+9i4xNJ1SDCViBPDLf2BuafnZkpuiu25TtDSFeRiBhN E38D7ZRyL7wwpORc8MLfGKM4/Lxl9bDxnYzV3yUVDjEyT/emV/hbQixl0Hm/uwoDiBYibnNkYf2sA 5CIKu9+JBEkWLpsZ2q712cj9rUHviFriDrEqZyWZ5XygxK/vusAEDVtdbyVlB6gGfL2r/IGog9qiQ uN8ETFaYuTkaixRNEoiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RX-00E51y-2o; Sun, 17 Sep 2023 22:40:43 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RQ-00E4xp-08 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:38 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40475103519so36036555e9.0 for ; Sun, 17 Sep 2023 15:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990435; x=1695595235; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6vxGwRmrE/ZkUF8q8weoGWwIj4Xu+tdZLwyIukopjBs=; b=G48M65Gb27GsxndLLuiJq59ETZv6mQ7IzPi9AJJJZdAqwvaebQOptlBUx9tvIJByxh Pp0P6KN9Ocomm4Xtzknq5NHlMkU8XliYpmzI15wjbs48YDk6AIj7FeHStx5pi5ac1GLf +06X1i0WJ1crXxiMRtSWX0jbD6J/hRgEqOvDaD+IyhbqCMnWjmQkDxZRDHXMEskPf+Te QcrxhoECyhJz/f2Zqn2bXzBPE6FMpoRa3W7f4SEDJGn8cUBzpduMVtzxLH6rBi594p3K 356emDysgVmt6XmqJOhRzE680kByabiQEZZFP3lW661zTqOqv+cSC2N+KHju+K9CyI0J lmgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990435; x=1695595235; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6vxGwRmrE/ZkUF8q8weoGWwIj4Xu+tdZLwyIukopjBs=; b=BUA4xe9CcZ5PvyheJB3QIQ23iYxGOx+hz8WFIbcXYKvKD9zC5a6LTXTv3sntz/v3c0 kBXIJSQ87Hg/bAz1E8qMzYIjnqIyE9SEjH7/mj+jq6Exbxty2cG/4jt+pBYiArjx18fz CjBt7SGhZSTnQBGrng6x4SeCpCDdTW07nlhFmEuLmLqUJh2DizEuxSkeEC3ZGcszV3Ix 15jRvwrAXXeNHrcVLpDJKjbVrspVqwO+zldWjIQ6LBPML4RlQRxeUJvNfx7CMeoqUwqb ySuULvfGmwOF4NzN8wj0dXjCQc1oC1928ZWIUgdZwgzjp2oy6FDtB0L/EB3lPZwuMrSJ YOYw== X-Gm-Message-State: AOJu0Yz9vWQuUDJDwcCD/A4RWyQh4p87EgTRy62NXOC0fEMfUj08kwkZ S6YxfFdhSXAuRFfl4USKFLGiuZpVmNFjDQ== X-Google-Smtp-Source: AGHT+IHMevfnk5UWYsKRhfkr5ayQmI3SajW1IKiqEwfVzf1dzHkT1BsOxFv0AQd3YBAb6HwM5sliDw== X-Received: by 2002:a05:600c:2194:b0:3fe:ef11:d79f with SMTP id e20-20020a05600c219400b003feef11d79fmr6719962wme.36.1694990434661; Sun, 17 Sep 2023 15:40:34 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:34 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:00 +0200 Subject: [PATCH 04/13] clk: print debug message if parent change is ignored MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-4-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154036_077292_F1830C7D X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara Print a debug message if the determination of the best clock rate suggests a re-config of the parent (which means the actual driver considers doing so), but the clock is not configured with CLK_SET_PARENT_RATE. This should give a good hint for clock config improvement potential. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 3e222802b712..4954d31899ce 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2241,9 +2241,14 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core, } } - if ((core->flags & CLK_SET_RATE_PARENT) && parent && - best_parent_rate != parent->rate) - top = clk_calc_new_rates(parent, best_parent_rate); + if (parent && best_parent_rate != parent->rate) { + if (core->flags & CLK_SET_RATE_PARENT) + top = clk_calc_new_rates(parent, best_parent_rate); + else + pr_debug("%s: ignore parent %s re-config from %lu to %lu\n", + core->name, parent->name, parent->rate, + best_parent_rate); + } out: clk_calc_subtree(core, new_rate, parent, p_index); From patchwork Sun Sep 17 22:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388726 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 4356CCD13CF for ; Sun, 17 Sep 2023 22:41:15 +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=u8v7E6m0jtcJOJ7f4hVckaCHH+wVZORNEet4M3sYWCw=; b=QAqZKDjKEEUjXU 96vAP42J/ycSmAf9avPsfzUlWdmPxh09VJCtiAH1H5fevrOrjvzi6dKIoDmJ4s9HcoxqHT9r5JT0b X9DcNUa6RhkaPoaT0wnW1b+3wlIE2GbdkmwJojlq+ypUX55QSNbX2Orf4ApoBTirE48ugdLqTON1Z bP4rI9C8uTYmfm6ljcNwLzYx0USurP8MRER0M9Jf8WnB4kWOOROwejSpl7xNWM5RBCPGENcfJeTYu o3TUQuBuKQWPDrfG7g3Qpf7wveiMfWpAMIBrxb07URHO4dIL3/MDigUl3ZC6wdm/JZu1yD/pvQkK2 GlpE6u8/sjFtD8WyuEuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RZ-00E53T-2u; Sun, 17 Sep 2023 22:40:45 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RR-00E4yI-25 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:40 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-404c023ef5eso20885435e9.2 for ; Sun, 17 Sep 2023 15:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990435; x=1695595235; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gCq7gxZ6dHwUyWczpY7Vh5cbaVAZn1kPig1Zw4rFZSA=; b=Dd8hBf6L5B84q5HWz0/ExwvRE9HnTjauHNRJEbDXdaPayt/WdpKcJE+Vi6wJsu+Pop gao+qZ/ToGTM86e6IgmXP3j6pVblKJuOA3SKpgI80qRBfd9Uz1DSTD8dAPT5wLP6O6Zj iNQKibKzKcVShvE4B0yR2X1fRWZ2yVGwqYUtIFQpbh0w0elASjpSuXMvtEX5FmV9dUA6 S05rG4We8KPIYg2GEDMr+Yz8cfU0RrQk+cCmPnW92t6Zif2dfBqJihSeNbFrazjvU6n9 7/CLrZ0eeLPbEd1t6Za5plzTykFp4YsbWd5UtgR3LR4ftmMlahaAuohhkbFjW95YPEKx L3Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990435; x=1695595235; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gCq7gxZ6dHwUyWczpY7Vh5cbaVAZn1kPig1Zw4rFZSA=; b=aHx2iWG95Zx4NbBipHMaXTsJv/qCEymbGTZI2udvAIUsifZKS/quwj3q10TI7CxSAZ yiDj/oNaKPJCxKCNuohyRgv7WemmpkNOgL6io5a9LO6NOkmuCEea1ZltAhbd03WX5vNj xs1bOTW97vK58IGNJEOvpkRpakZxpTNoSLqmiPIffSPoq7UsiN0dDEjv2gU1ruSzEI2z OTIE2Mul0JX6u2ulnL0QPa+4HW5OEflNHCeqTPbLWq2Yib3zvTqliUJZWRYkCA3rLHQL rKLI5W6pfySlqrP1dyscS27xyfyMO49CHSQiWjbDAGPuR5dJpNqpSXNaaePQmfAcZQ+2 bB8A== X-Gm-Message-State: AOJu0Yy5owfIvHbRfezY2QkeBj7k2kO4WslgcrULqeu/6RyGpAZg9n6Y sQm2vdjfAAJuN80M8dWfhc0= X-Google-Smtp-Source: AGHT+IE9Gpa9OGGS1u8fMnQqhz/589mtCuJtM8X+qAmxlIvQ+ije0qLFWk06/6xK0LIv4W/DRv7WnA== X-Received: by 2002:a05:600c:21d7:b0:3fe:d1e9:e6b8 with SMTP id x23-20020a05600c21d700b003fed1e9e6b8mr6261880wmj.12.1694990435584; Sun, 17 Sep 2023 15:40:35 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:35 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:01 +0200 Subject: [PATCH 05/13] clk: keep track of the trigger of an ongoing clk_set_rate MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-5-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154037_686190_1F38BA05 X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara When we keep track of the rate change trigger, we can easily check if an affected clock is affiliated with the trigger. Additionally, the trigger is added to the notify data, so that drivers can implement workarounds that might be necessary if a shared parent changes. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 12 ++++++++++++ include/linux/clk.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 4954d31899ce..8f4f92547768 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -33,6 +33,9 @@ static struct task_struct *enable_owner; static int prepare_refcnt; static int enable_refcnt; +/* responsible for ongoing rate change, protected by prepare_lock */ +static struct clk *rate_trigger_clk; + static HLIST_HEAD(clk_root_list); static HLIST_HEAD(clk_orphan_list); static LIST_HEAD(clk_notifier_list); @@ -1742,6 +1745,7 @@ static int __clk_notify(struct clk_core *core, unsigned long msg, cnd.old_rate = old_rate; cnd.new_rate = new_rate; + cnd.trigger = rate_trigger_clk ? : core->parent->hw->clk; list_for_each_entry(cn, &clk_notifier_list, node) { if (cn->clk->core == core) { @@ -2513,6 +2517,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) /* prevent racing with updates to the clock topology */ clk_prepare_lock(); + rate_trigger_clk = clk; + if (clk->exclusive_count) clk_core_rate_unprotect(clk->core); @@ -2521,6 +2527,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) if (clk->exclusive_count) clk_core_rate_protect(clk->core); + rate_trigger_clk = NULL; + clk_prepare_unlock(); return ret; @@ -2556,6 +2564,8 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) /* prevent racing with updates to the clock topology */ clk_prepare_lock(); + rate_trigger_clk = clk; + /* * The temporary protection removal is not here, on purpose * This function is meant to be used instead of clk_rate_protect, @@ -2568,6 +2578,8 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) clk->exclusive_count++; } + rate_trigger_clk = NULL; + clk_prepare_unlock(); return ret; diff --git a/include/linux/clk.h b/include/linux/clk.h index 06f1b292f8a0..f0fe78c7a0f1 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -60,6 +60,7 @@ struct clk_notifier { /** * struct clk_notifier_data - rate data to pass to the notifier callback * @clk: struct clk * being changed + * @trigger: struct clk * being responsible for the change * @old_rate: previous rate of this clk * @new_rate: new rate of this clk * @@ -70,6 +71,7 @@ struct clk_notifier { */ struct clk_notifier_data { struct clk *clk; + struct clk *trigger; unsigned long old_rate; unsigned long new_rate; }; From patchwork Sun Sep 17 22:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388723 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 6A0EACD13CF for ; Sun, 17 Sep 2023 22:41:11 +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=7lnqOZ3Ikxygv/G5Pd7fFOtnPLsmwlEQhEtOfx0kpHI=; b=knL42Lag2cG2+5 V6wwLUZtyAwukbJfMz3eviHvO2jqYDHmmiQR1XpuMOd48DvULIaaoazrckqY246xr9Lq9BoLC6sxR mieercxO4MCi7BFvgsS9mLzDtaQK1t4GAgW9rQaq7oE1kAliM7KNGdpjqtuCWjgxOnf3lKrBQP03Y Nvjoa8kwxQGK4DQsfSLwDutKzG5LIUdYFAyQUKGzoPQZUUUkwiWoEB/XeYSz32JLDDdxEtxZ0C3iy 1BrZHt5LRpbipy4MhL4gP+4Jnlay3y4Qb0G6bW6HQEDovK+ACfTV1HtgAeM8QNiEJrzuDXT1riULe ++Kfxih/dZ5RnlXh0O3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0Ra-00E53p-1P; Sun, 17 Sep 2023 22:40:46 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RR-00E4yS-2h for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:40 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-403012f27e1so41840185e9.1 for ; Sun, 17 Sep 2023 15:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990436; x=1695595236; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=a4cz3ddudUKiI7NnTMxIyuudgr4C+r48kicDtdOb7Wo=; b=BiDN8pe1oXknBZZk5JL2/gW0+OerwPhgST8qPqJg3DdNeb+3FhATvck3JZ2nXUnAzg d3iIuyjFvzNcahkPRB/432AJOS1+hBUYUkmGioLiEtDRJY1hXXKxhucApqzoI7R6PV6C fa04xTTs50ITp9GbkDNtGX5XT9DDFX9LqajmFu12L1X4DcxHAo6IqhJ7h1bOAKofLWcu BEi8LYj5SyVAOcTL2VALFV4DEHrp+NsagphJqJSpUgQUkFYyho1ZIDYFrAFEU65jCPr/ tjhTgKYnMyB7CLl5mwQNhD3O/+M9fzNI1KoERNlRwScfgcB+7WZPJHuGZEbJn0NPyc6M Mq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990436; x=1695595236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a4cz3ddudUKiI7NnTMxIyuudgr4C+r48kicDtdOb7Wo=; b=GwIKtBKsXBJ1xZtJeJQPkGGD/0joRJZhCkJ5YAw1IeLR5egLqUc1HlfM0a8jfZZ42E ZDmkr4368Lay31/w2BuN73Zf2D2L9a9MnUFlvHYEEI235aObLqlUCGkqnCG7NUi8ppUx +OC1OW0VOqv4OFzmx8Lt+nDHmV1FwgzUB1+WGKSBNHqr1TLlbxanF/TIjiIFyQUS1Zkz fSZK9tNouhtP6URYyYOn+yrI/17H8/dhWCNjdF8UfHWLEthZhGDlUyW3Ve1K+fOOs0Bs Nyoez2R0xDLmIiMTEHndSXRDDkjhqEJ4sP+W4UXxk6Y1OysFwVPqr5wm7LxS94GYBh7k MgyA== X-Gm-Message-State: AOJu0YzRpSGIgYowL6T6+SuDfEHSGpwwSQRWxbgQJ4xXuYT3jR1IsLQC iG1amEW4qJKRFvID6kfxevI= X-Google-Smtp-Source: AGHT+IE2H/LAUCgWRax7Ln7Pf/RNykjRml+cUSy7LIhvq+pmSE6UUuK6rKrg8wHXJMeh2LS9XviDXg== X-Received: by 2002:a05:600c:3781:b0:401:b2c7:349b with SMTP id o1-20020a05600c378100b00401b2c7349bmr5879782wmr.7.1694990436518; Sun, 17 Sep 2023 15:40:36 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:36 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:02 +0200 Subject: [PATCH 06/13] clk: keep track if a clock is explicitly configured MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-6-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154037_878661_932954E6 X-CRM114-Status: GOOD ( 15.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 From: Benjamin Bara When we keep track if a clock has a given rate explicitly set by a consumer, we can identify unintentional clock rate changes in an easy way. This also helps during debugging, as one can see if a rate is set by accident or due to a consumer-related change. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 25 +++++++++++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 8f4f92547768..82c65ed432c5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -70,6 +70,7 @@ struct clk_core { unsigned long rate; unsigned long req_rate; unsigned long new_rate; + unsigned long set_rate; struct clk_core *new_parent; struct clk_core *new_child; unsigned long flags; @@ -541,6 +542,12 @@ bool __clk_is_enabled(struct clk *clk) } EXPORT_SYMBOL_GPL(__clk_is_enabled); +bool __clk_is_rate_set(struct clk *clk) +{ + return clk->core->set_rate > 0; +} +EXPORT_SYMBOL_GPL(__clk_is_rate_set); + static bool mux_is_better_rate(unsigned long rate, unsigned long now, unsigned long best, unsigned long flags) { @@ -578,6 +585,19 @@ static bool clk_core_has_parent(struct clk_core *core, const struct clk_core *pa return false; } +static bool clk_core_is_ancestor(struct clk_core *core, const struct clk_core *ancestor) +{ + struct clk_core *tmp = core->parent; + + while (tmp) { + if (tmp == ancestor) + return true; + tmp = tmp->parent; + } + + return false; +} + static void clk_core_forward_rate_req(struct clk_core *core, const struct clk_rate_request *old_req, @@ -2358,6 +2378,9 @@ static void clk_change_rate(struct clk_core *core) trace_clk_set_rate_complete(core, core->new_rate); + if (rate_trigger_clk && clk_core_is_ancestor(rate_trigger_clk->core, core)) + core->set_rate = core->new_rate; + core->rate = clk_recalc(core, best_parent_rate); if (core->flags & CLK_SET_RATE_UNGATE) { @@ -2528,6 +2551,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate) clk_core_rate_protect(clk->core); rate_trigger_clk = NULL; + clk->core->set_rate = rate; clk_prepare_unlock(); @@ -2579,6 +2603,7 @@ int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) } rate_trigger_clk = NULL; + clk->core->set_rate = rate; clk_prepare_unlock(); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 3fb99ed5e8d9..e3732e0bbed9 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -1325,6 +1325,7 @@ bool clk_hw_is_prepared(const struct clk_hw *hw); bool clk_hw_rate_is_protected(const struct clk_hw *hw); bool clk_hw_is_enabled(const struct clk_hw *hw); bool __clk_is_enabled(struct clk *clk); +bool __clk_is_rate_set(struct clk *hw); struct clk *__clk_lookup(const char *name); int __clk_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req); From patchwork Sun Sep 17 22:40:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388725 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 9A7FCCD37B4 for ; Sun, 17 Sep 2023 22:41:13 +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=lhCIluGzlnPUDgSVazmRKVvIBvxfUxYOQ71I+oqwmlg=; b=MSodjFlBXRDgzi A8D7XhLlxk7kQgAmqlcN1lh9IUDflTrEKS2pqSEKMOTr9YUR+5g2oL3LFffnhXMSA2DDopi7NFnCZ PGCICFK3l9NKyt27Y2lti6ccR+7YbdYtHWT00ra8kHSadXzihSUIwPVCF8s0Z++cViHrkOySie/XO E8Ay9PqWOAkpwupyKbC8xywfOM+fqGUEXZgvs4VH8cFxBO/vNmfuhJoiqMYiBkQtW3Zfoyu4PpMM9 +GDNXYwGKqKjFwu7KYqI5Ey4XXeJk29H1jcLrB+iycFuP+xyU+LkMbw2GtMm/kM0mtm6J+tP6yMTR bnR6jUAJXf2kHOrVgaGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0Ra-00E54C-3B; Sun, 17 Sep 2023 22:40:46 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RT-00E4z4-23 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:42 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40473f1fe9fso38843345e9.2 for ; Sun, 17 Sep 2023 15:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990437; x=1695595237; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=d58DRMcmmqVdQpNWAbMiLz0ISFX3idJISFoDmPX5pV4=; b=LxRx/s7rWNW+VKj4/A27hNuBH0p4xxjzBbRZcBOaoG7TjN+ONXkJSvHPzKGZiKy04z 8R5zsSsp9J51LMh97T8lP0hCH9pzdifL+N1tRiSYCZt72XBRl4tn+awWMB1pitXjffOr 9optaT9gp3N1/y91vztYoF4uuqjYM99dwZ/4HxdSQBcR1UMJ71+vWBzS64VN6G0We3Al MLJq6jskd6vL5gY1fJRbBQ8Q3iToN9NSMxjDeImVqcO5wJKMnfxzobkJEciyQLKKVb39 czHwTLpJA2C9Im6d3OmppV1hmGDyFAn+VCIakVLEzMvo2cWzpOwohdhPw9pqJakp8G22 LPtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990437; x=1695595237; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d58DRMcmmqVdQpNWAbMiLz0ISFX3idJISFoDmPX5pV4=; b=IDzgqsy1y3mSrRYjkvUSZGNXUdlM/iQnhbRC+seDkzdud1SCoKd66bFohaUtZr8pLJ p47PSILJjs5prx3d0MEZAfJJMWDhxCIcHIKqEnSU6meZUX1esLDdQ01EFAsS/ccupE7Q 5gj7o0DrSZVy6fwAUxcnQlQtf9M8CnEIXD34D60FjF7BI23VO7/xjt0xiO9hSPOcZ/Kq WmGcsMxogSS7/NGuij+s0KKPs/HsuSnxqFEKTN8DWPa8E7kDQs1IH6T60loK0XDds9Rn bBFpmn35kwfSyYm8LEOoQg+YrFJSwmzUGmHj5E7KhgC8JMVdGl/4mBEmypBF7Wn2qAoQ yZkw== X-Gm-Message-State: AOJu0Yx06tBQHFJK930qzbFxz12RHoWwwjz9tVHcr0ZgA5Vttcne1fW4 Ot7SaMlaKmPoC0gvmWOYPto= X-Google-Smtp-Source: AGHT+IEYhBep8mg6WS7aKBOBPPKW2JCJgL7HelrqDWQ8VqlnSyxcZRRMfPYvNeB+WumXVoC+/YvMXQ== X-Received: by 2002:a05:600c:2288:b0:404:7865:bf4 with SMTP id 8-20020a05600c228800b0040478650bf4mr5869641wmf.39.1694990437396; Sun, 17 Sep 2023 15:40:37 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:37 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:03 +0200 Subject: [PATCH 07/13] clk: detect unintended rate changes MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-7-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154039_679476_936175D4 X-CRM114-Status: GOOD ( 24.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara As we now keep track of the clocks which are allowed to change - namely the ones which are along the ancestor line between the rate trigger and the top-most changed clock, we can run through the subtree of changes and look for unexpected ones. Shared parents must set their rate in a way, that all consumer-configured rates are respected. As this is sometimes not possible and clocks sometime doesn't require the *exact* rate, we might have to find a way to find out if it is *exact enough*. Then we could fix it in the core. Signed-off-by: Benjamin Bara --- drivers/clk/clk.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 82c65ed432c5..faececc44c28 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2280,6 +2280,74 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core, return top; } +/* + * If the changed clock is consumer-configured, but not an ancestor of the + * trigger, it is most likely an unintended change. As a workaround, we try to + * set the rate back to the old without changing the parent. If this is not + * possible, the change should not have been suggested in the first place. + */ +static struct clk_core *clk_detect_unintended_rate_changes(struct clk_core *core, + bool fix) +{ + struct clk_core *child, *tmp_clk; + + if (core->rate == core->new_rate) + return NULL; + + if (core->set_rate && core != rate_trigger_clk->core && + !clk_core_is_ancestor(rate_trigger_clk->core, core)) { + struct clk_core *parent = core->new_parent ? : core->parent; + struct clk_rate_request req; + + pr_debug("%s: unintended change by %s (%lu -> %lu)\n", core->name, + rate_trigger_clk->core->name, core->rate, core->new_rate); + + if (fix) { + clk_hw_init_rate_request(core->hw, &req, core->rate); + req.best_parent_rate = parent->new_rate; + req.best_parent_hw = parent->hw; + + if (clk_core_round_rate_nolock(core, &req)) + return core; + + /* TODO: how close is close enough? */ + if (req.rate != core->rate) { + pr_debug("%s: %s fix failed, req=%lu, sugg=%lu\n", + __func__, core->name, core->rate, req.rate); + return core; + } + if (req.best_parent_rate != parent->new_rate || + req.best_parent_hw != parent->hw) { + pr_debug("%s: %s fix failed, req=%s@%lu, sugg=%s@%lu\n", + __func__, core->name, parent->name, + parent->new_rate, + req.best_parent_hw->core->name, + req.best_parent_rate); + return core; + } + + core->new_rate = core->rate; + } + return NULL; + } + + hlist_for_each_entry(child, &core->children, child_node) { + if (child->new_parent && child->new_parent != core) + continue; + tmp_clk = clk_detect_unintended_rate_changes(child, fix); + if (tmp_clk) + return tmp_clk; + } + + if (core->new_child) { + tmp_clk = clk_detect_unintended_rate_changes(core->new_child, fix); + if (tmp_clk) + return tmp_clk; + } + + return NULL; +} + /* * Notify about rate changes in a subtree. Always walk down the whole tree * so that in case of an error we can walk down the whole tree again and @@ -2484,6 +2552,21 @@ static int clk_core_set_rate_nolock(struct clk_core *core, goto err; } + /* + * The notifying process offers the possibility to fix the rates of + * unrelated clocks along the tree. After that, run a detection to find + * clocks which are potentially wrongly configured now. These might be + * fixed by the core in the future. + */ + fail_clk = clk_detect_unintended_rate_changes(top, false); + if (fail_clk) { + pr_err("%s: unintended rate change cannot be fixed\n", + fail_clk->name); + ret = -EINVAL; + goto err; + } + + /* change the rates */ clk_change_rate(top); From patchwork Sun Sep 17 22:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9DA4CD37B4 for ; Sun, 17 Sep 2023 22:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EDR9vLM/2IEe2GsmOAJBY2f/Squcr/GeJCPET+rOX4w=; b=uQFSeMgGpcn81q w6TShRJygxJc2Yoy/b2fpozaS8Sc4iKl8OT0o1etPoS3xOPRUOg7sO947zwesijCXLyqDlQzAKprz 4ki9V0o1LSoiyl822nmyRIkVg1jZ6/ojJPywv4VlfMbpB1kTaDE3eYB3N8ZqbIbBZSPugiYSqMtYC 1ycYuMYP1fMOIVIOYnL1Mus2DXNCozASR9MkfdyuVtqJa8H0EaY85R6Qv6t/iOFqPHit+fFj2ZvpK zA2ynQEiegVj2oEvw9j6mLX/LlinuIPsdYwPoU24gZUb/a7yWB/XpPysyQXLbFPfiymokfOs3sj1T zJoY4u4tri49BXmyD3ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0Rb-00E54X-1j; Sun, 17 Sep 2023 22:40:47 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RU-00E4zB-07 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:42 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31dcf18f9e2so3774721f8f.0 for ; Sun, 17 Sep 2023 15:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990438; x=1695595238; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hHjjAyqptO8IMOlepeu6XUuPt7GkOQwtq9aZ8x05FNg=; b=LCv/ge62sNkcVul0H2Hw12FIQQqUH5Uy5reDJItIoTd5buHt5N52Dmjc6DbRevo7ln ZCVvsiONaACdq+qg8njHhaAaSohSx3gNUcPFyJ7aruDlj0LSQcyW6vz3IE82VMAKqM8k 9FeB5hY0E3v/gGVo8dXwHha2RfzJrPStPGAN9sL4DiNSBsLI475S2ZYewhQhLDk5lsqo 9dFeiVTJTR7GAnOXoelEoEWFAErrvK0I09+Fbr2aK6vESJcaMxSeiLZLHRb4yBbS8jvH rSBmR6/pLXb0byCmcBZTjDC+/7NkwLyQc7WOVVgDZOcvxKh+elwM/Uh7q5FWmtyyzelr i8ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990438; x=1695595238; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hHjjAyqptO8IMOlepeu6XUuPt7GkOQwtq9aZ8x05FNg=; b=hjSmAr06vxewubJAWYZNiXRDDVwUAAoy+MvffsEzFW+t0++moNRqoUvE0WiGbbGIpw hn/z+q+R6NX2AckvSEizQZUndJfzXyMSiF4QcsAQC9BciLKswyKc7KhxhhjeNIgaKoRG eDbRoJLUX10qF5KTQeJV7ZOpU1rsfDWyx1i/2xfdS5/qqmr5c08iLDPXgWH0PKv7z5Wy 0CTsK9hfhkkxbr++KME8a0xS2Wd1UuMoTdVUyngfEnGvsarPLdSYS88+cUzHHCZTlrIo pzoB5gxTWQItI9qQ2k7uRvqvjqSqKfJdj+GNn1KspiDa+4YNU4jQvERi2x8Bw4AdVhj6 1bkA== X-Gm-Message-State: AOJu0Yyq1nyfptciCbc9ni+qFtu0DPw9FXmBXbT1IAeotEeiU6v9Q546 YzivIfSf/6+F0fBunmptxYDkIps5ow7QLA== X-Google-Smtp-Source: AGHT+IFLk9i3F2eGbtKSIJ4+EO4UrKuGZHKBpH4MGvrG0hpgnN6SI7Pfgpa0h7Kabz110ICpPDUFwA== X-Received: by 2002:adf:ce09:0:b0:31f:e74e:8265 with SMTP id p9-20020adfce09000000b0031fe74e8265mr6156359wrn.56.1694990438311; Sun, 17 Sep 2023 15:40:38 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:38 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:04 +0200 Subject: [PATCH 08/13] clk: divider: stop early if an optimal divider is found MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-8-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154040_074565_37B06BBB X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara During finding the best divider, the current implementation asks the parent for the best rate for all its available dividers. If there are a lot of supported divider values and the maximum divider is far from the target rate, this can lead to many iterations. Depending on the parent, the process of calculating the best fitting rate can be quite complex. Therefore, return early if an optimal divider has been found. Signed-off-by: Benjamin Bara --- drivers/clk/clk-divider.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index a2c2b5203b0a..61b40dfb4e6f 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -332,6 +332,15 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent, bestdiv = i; best = now; *best_parent_rate = parent_rate; + if (now == rate) + /* + * Calculating fitting PLL parameters, which + * might be done in parent's round_rate, can be + * time-consuming. Therefore, the lowest parent + * rate which gives us the exact required rate + * is already optimal. + */ + return i; } } From patchwork Sun Sep 17 22:40:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388731 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 9BECBCD13CF for ; Sun, 17 Sep 2023 22:41:51 +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=KHauJ4x0qU5UB8ds4F/mUHEok4spLV4PjchqgJgs+Yc=; b=LgasZ9LGX+it10 M1BvjJ7AblwHiOlXMV6tXUpESd497PbdWaVwaJ8rHfoEC/J0hr2EWZwGw5LoNDtsYfRnAO+uYUGFP RgwF31Nm+Hh9gehAwNFpUhZdjYYL2HeeqBaCj9pgyWYzovViaRVJK7B/8+V3Yw2Uk5oeOxF6BIz3R HAwlv4t4prIW6QBDeZ1hBfh5wrzulCz7fldlPeLDxBKyjdpBVG9SXxku9VJxZGEBm+5kVitvZfex1 VzFPxdZfvEq9k8onA6biQ33Y21hgxJ0Zx0PsGtyHdCiSxmyH+dzDW8tGq7RHwoElgM2rCEfJ3zci8 k2G4qTyOf4S7P8NlYQzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0S3-00E5LW-1c; Sun, 17 Sep 2023 22:41:15 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RV-00E4zl-1S for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:44 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40476ce8b2fso32454195e9.3 for ; Sun, 17 Sep 2023 15:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990439; x=1695595239; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AleiAM5uH5i/SE/tlppNUyCKM9rbilwjAbKE5lRIkpU=; b=Y2eoRvR+Zof6k5GV7lHYUmCoOdhk66o2nNZzMqV6HhpTe5L2XteYTdJinlLkSi1W0O nZFKMZUDzsv8OgTRngbBODWdlFgRgPwHyo/oSDKfun/xKiASj/k23Ukz3E+mXek5qcZA aivzSgIaIL6q7E968uIll4yZdeVdnk8UO5xqUnPppYN0VlTCLybyOl7wpgXe3YyrxRfc ze4lnjx21syjPj3ptdB2VKhVdAcThk+UY2RgfqK/K36sp0D/sjPsMaQ9eEbJpWaRux7u y72pjDQf9F16ryLk+L4VZlAYLCu1Zzt9CdhxJHaAhKbQf3jgd8an4n1NAgHfNCXmOttn soXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990439; x=1695595239; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AleiAM5uH5i/SE/tlppNUyCKM9rbilwjAbKE5lRIkpU=; b=YhMrPFKNiWbK/LkzvWnwtCzUiSmZqM557ZEAAglhiTAwikUgUMld/uc6sfovZTUjR/ iObpnQ4WmUSdDl/Y7QOXKim9jFoakEuF5OCitRe9x7D4vrG+wM7hiAVK6weVdoOXREjm XjQNECj7xLgPizKia8ih62UK7A3r7HM2cv5e06+okz47fChKVnGBvTG6RdO5QArf/2Xv HNC0Aj1e35LokHIj+Rf5D1dXxlB9iIB7F3QaoI0S92TKRetK5yed1k/S4m3I7kkCyios eA3W+tog/LfIaOzdxowPYF3srqK94VrjoTQ+R4bUUenTXmjc1BjfXKneXH4EO6Y67hxp tRkQ== X-Gm-Message-State: AOJu0YzKChqOXbPFvetMZJxEXbNRYBXPgXt0X61v66zIBWlBZaum9jrE hDdGoZ9tfCbvCBhO4z74tYg= X-Google-Smtp-Source: AGHT+IEJd0UR3fHRkZLN2P37BaeGbazCGXTOPIKnflpTHUpPxYc7g3MXgPNqS7MyirIdKmPyviqLoQ== X-Received: by 2002:a7b:c8d6:0:b0:401:c338:ab94 with SMTP id f22-20020a7bc8d6000000b00401c338ab94mr7312693wml.29.1694990439298; Sun, 17 Sep 2023 15:40:39 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:38 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:05 +0200 Subject: [PATCH 09/13] clk: imx: pll14xx: consider active rate for re-config MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-9-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154041_486557_7D2B3507 X-CRM114-Status: GOOD ( 16.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara As the pll14xx might be the parent of multiple child clocks, the active config is most likely still required by one of them. As the children have divider, use the LCM of the old and the new rate to target for an integer multiple of the active rate. Signed-off-by: Benjamin Bara --- drivers/clk/imx/clk-pll14xx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c index 0d58d85c375e..803e8b0a7a31 100644 --- a/drivers/clk/imx/clk-pll14xx.c +++ b/drivers/clk/imx/clk-pll14xx.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,7 @@ struct clk_pll14xx { struct clk_hw hw; + unsigned long rate; void __iomem *base; enum imx_pll14xx_type type; const struct imx_pll14xx_rate_table *rate_table; @@ -235,6 +237,22 @@ static long clk_pll1443x_round_rate(struct clk_hw *hw, unsigned long rate, struct clk_pll14xx *pll = to_clk_pll14xx(hw); struct imx_pll14xx_rate_table t; + /* + * If the PLL is configured more than once, we have to consider the + * active config for the new rate. As the children have divider, also + * allow multiples of the already configured rate. This is a simple + * approach to enable dynamic re-config via SET_CLK_RATE_PARENT for more + * than one consumer. E.g. on the imx8mp, when video_pll1 is parent of + * media_ldb and media_disp2_pix (always 7:1). + */ + if (pll->rate) { + unsigned long want = rate; + + rate = lcm(pll->rate, rate); + pr_debug("%s: old=%ld, want=%ld, new=%ld\n", clk_hw_get_name(hw), + pll->rate, want, rate); + } + imx_pll14xx_calc_settings(pll, rate, *prate, &t); return t.rate; @@ -343,6 +361,8 @@ static int clk_pll1416x_set_rate(struct clk_hw *hw, unsigned long drate, tmp &= ~BYPASS_MASK; writel_relaxed(tmp, pll->base + GNRL_CTL); + pll->rate = rate->rate; + return 0; } From patchwork Sun Sep 17 22:40:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388728 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 151A1CD13CF for ; Sun, 17 Sep 2023 22:41: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=M+IpHXnQ/R1mETZeoc39a/wG9Lbn88NgJUCdoGuVVu0=; b=e5eQgQVRWQfyvJ YM7eGX3lYjR+acfnFMBdGM82AlgJagtqWMq9WxuvMdYVYRc8y+RNrFuV75sbXIzkDv6yj4l9ZRQw/ rCPQ4DiYHDgtA4YMxCsxfwAsp4ELmU3nvLzgcHyyeFGFnE5LwHtq9kcCywO86Gn7oXhpOqWgtCwUB VPb7qwiJ/NB39OSkW3a89cAxMemQf/ay7uC/D9gQtNSBJHpFiRj/oTDl6XpV0B5F08qEAJ4kjo6d9 2idTu0LsALVNKKqhcvyjqecZzoKcFH83BWo8xo+L55COpwKg2sQ7Gw3pcS8VQV/Lp9FSqlpAQFg9M 8rdxUjs/4k4igNMhaN3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0S4-00E5MZ-2H; Sun, 17 Sep 2023 22:41:16 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RW-00E509-0W for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:45 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-404c023ef5eso20885815e9.2 for ; Sun, 17 Sep 2023 15:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990440; x=1695595240; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kxgzRC83NEd59zuKYNAtW33VSR0RcAZP2Du3OW3MEsU=; b=ja9LCiTAnR9slR83iQzSRS50qz61T586UmyB7krn5Hm4osBW5IkKgx0nBylyoio4KI YKJEeV7hGR0jwBRfA7Byh0cRrikhd36aRABncommhdUL7qpLulmjRMhdRA5M7HwtqVfg 3bbOK8V0RpW9RR+A1nxW2qzAE/1OrHKffi/VlCCiYmTOrPlS3fpwcxA3nSaPY07AxqPB IpENVzvS++0MhrpbndB2ZFtgTY9unygLjeEv2jmDxcilaexriJLoAjCD1zFnMwzkcYfN mNMn4pf2IrAtE2GBHsf9zRAfmlL2XlwLEnIeAxhG5VyACaXb6AYZwMxI4HWwqXQS0h6U bYKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990440; x=1695595240; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kxgzRC83NEd59zuKYNAtW33VSR0RcAZP2Du3OW3MEsU=; b=fCkxz1LvCLSW17G0B1c6wuq6ePFYnrGahH/5V4AyPgNqa4MnmUCEk36gMs4cALEFv8 ciI4S5mWqJJkaiRbh/RZJgG+Xka1LAf0m0XrIJR8KO5gty6r76D0lgZ45SUIzNumEF/r 5P+cuqP4+CoNo7+7IwD5ABOYogIq7s0N0A/IbsDEy2swjqUn7d4cLRIvscUkZEAlGRrS dEMonTSp2g0AUGSRmizq1QsB2HO7qRxgpXwdgaYZ4ma97Rg/X8Gb0uQz7uf+yim1jxi/ p/YyQWgJoeS9IndcOF0KVmP00xL/mapgwGqd4R48LTSl/zlAuGfOD1dUbq44kK+KDYRq kDlQ== X-Gm-Message-State: AOJu0Yz56gMCHPjfUPHmqy4XNPMesN/j/6GcG0x/kXgWXZsRcsqUtCmT kT9mnJRUpAwGBUW2Lv6Vu7o= X-Google-Smtp-Source: AGHT+IFoSWsvTCvogylPfTef05sJwd//OcFKTET+KddTyezT5DcPj/b0Rpvtp0gJKAXf1ocmhph9HQ== X-Received: by 2002:a7b:ce07:0:b0:401:bdd7:499d with SMTP id m7-20020a7bce07000000b00401bdd7499dmr6467049wmc.25.1694990440181; Sun, 17 Sep 2023 15:40:40 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:40 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:06 +0200 Subject: [PATCH 10/13] clk: imx: composite-8m: convert compute_dividers to void MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-10-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154042_195927_1AFE6A39 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara As the current implementation cannot fail, drop the return value. Signed-off-by: Benjamin Bara --- drivers/clk/imx/clk-composite-8m.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index 27a08c50ac1d..a121f1285110 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -47,13 +47,12 @@ static unsigned long imx8m_clk_composite_divider_recalc_rate(struct clk_hw *hw, divider->flags, PCG_DIV_WIDTH); } -static int imx8m_clk_composite_compute_dividers(unsigned long rate, +static void imx8m_clk_composite_compute_dividers(unsigned long rate, unsigned long parent_rate, int *prediv, int *postdiv) { int div1, div2; int error = INT_MAX; - int ret = -EINVAL; *prediv = 1; *postdiv = 1; @@ -66,11 +65,9 @@ static int imx8m_clk_composite_compute_dividers(unsigned long rate, *prediv = div1; *postdiv = div2; error = new_error; - ret = 0; } } } - return ret; } static long imx8m_clk_composite_divider_round_rate(struct clk_hw *hw, @@ -80,8 +77,8 @@ static long imx8m_clk_composite_divider_round_rate(struct clk_hw *hw, int prediv_value; int div_value; - imx8m_clk_composite_compute_dividers(rate, *prate, - &prediv_value, &div_value); + imx8m_clk_composite_compute_dividers(rate, *prate, &prediv_value, + &div_value); rate = DIV_ROUND_UP(*prate, prediv_value); return DIV_ROUND_UP(rate, div_value); @@ -96,13 +93,10 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw, unsigned long flags; int prediv_value; int div_value; - int ret; u32 orig, val; - ret = imx8m_clk_composite_compute_dividers(rate, parent_rate, - &prediv_value, &div_value); - if (ret) - return -EINVAL; + imx8m_clk_composite_compute_dividers(rate, parent_rate, &prediv_value, + &div_value); spin_lock_irqsave(divider->lock, flags); @@ -118,7 +112,7 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw, spin_unlock_irqrestore(divider->lock, flags); - return ret; + return 0; } static int imx8m_divider_determine_rate(struct clk_hw *hw, From patchwork Sun Sep 17 22:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388729 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 4F136CD13CF for ; Sun, 17 Sep 2023 22:41:42 +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=ZE4agfLAapUFaTLs2jlpJ5BTREylpIFfUR/6zudu6+M=; b=T9FFrp4cLVZNJo 0j1ptFB6LT4wERxNxVnXth4VmiVfugPibWInh0BbKeVRbxZdzCaDnjrztNV3JapyaV04JOWY80jKO 3eC4CAhAKEzkM19NrgDypaR4GLHLwbgVZIHlFINvlIS61UhW3TixX5znb+mCaz/tHk8j07SrOCoCR JkHQnSm61gg9mP9R8p6mctAnrRzYHtbIOaNZhK5eltgGaMAJRG47JSjtUYKhh4Qb+NpFPd+0QVmMB G17asYpaEohqR2wNL8bZXZTuThZFZgtnTTnseHIM4Znj2O5vKv7B0LguCexMS/d/co7q899LN8Dz3 CUU5dvzsulOBIc+Sq20Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0S4-00E5M4-0N; Sun, 17 Sep 2023 22:41:16 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RW-00E50O-1J for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:44 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-402d499580dso42309955e9.1 for ; Sun, 17 Sep 2023 15:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990441; x=1695595241; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kviONp3xwBUSyMm3n9HmjGMrxjEliGN8QJc2qo9i9Gg=; b=R+nxmpqtVxEeM6PHqC02UkFXgXTClphe0jwsTTpuKPNyEdkMbQtW6/HyPb6vMIRz4K 3/UC7QKcohOuDThb86zFCZNszq41Q/FSVlyXFncSofaZJcufu5XbOUVAVUK1vNKMAkmo OkhDj+SRKzDkEnUpf369RGQdMV3hcV+szAvkSTeqabbbyZTO/z8NanP5geQMgPv3dXyY 4qa80+pKwJmdjcQVEuLrSKa7wiNpgDCzIBoRN7D3JUc2hqaXbfUFG56uJRuADCKLK+Ye BBPKn5hBY1Vw30bTrzQ/rILOaWubxkvjOltSQYAMjeAll97MZTOikbdHBVHDVDQw6Hr3 OMRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990441; x=1695595241; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kviONp3xwBUSyMm3n9HmjGMrxjEliGN8QJc2qo9i9Gg=; b=hn+6tD8YryK9z/yYUV7M7Wyhej2PQErOkIq2iK5oeFxzoEUu4iGEfzJlJvTy9pGmRY xfQG0iL6uQ12/CGIiO7ebLM7pwWI47vBoOLzeu7FpJ/6imMpiXco8bCgcaSX+Yp96Ss6 c/aRjy1DYQINx3FqVSMEzqegSGbjB4Zt9F7Cfwfx3TMFNeEem7PQnUgVHyWHbsZKov2E fI8MaduduJXFpGI6CBxam6AwliWaRA4Wm3k+EOkxk1gwLjYC8pNyw79groBDjc/O0IcJ XM1JL6fCqoNsYX+S/qSS6DDZ9PKGrVeU4ICPzxIACLmpnkxdzmE7N9IWq3+A4TxI3PEF 9Lnw== X-Gm-Message-State: AOJu0Yz9EFIt+sO5AWlNiTC39e4y9DU/rFAa1nJ87EbPM9MG/o690yRj Z8AOhIuWv7XpE13mzqF2jzo= X-Google-Smtp-Source: AGHT+IGI9iHWZr7kzzg0eUkNH07Lgn024wjCqs9NAjnnhsL3UBw49Jv26TH9svgPt6bxfNSbTxu3XQ== X-Received: by 2002:a1c:6a01:0:b0:401:b53e:6c3b with SMTP id f1-20020a1c6a01000000b00401b53e6c3bmr6295687wmc.6.1694990441025; Sun, 17 Sep 2023 15:40:41 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:40 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:07 +0200 Subject: [PATCH 11/13] clk: imx: composite-8m: implement CLK_SET_RATE_PARENT MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-11-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154042_450310_ADFC439C X-CRM114-Status: GOOD ( 23.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara One of the key parts to enable dynamic clock propagation on the imx8m, are the consumer-facing composites. They currently only divide, therefore the parent must be already quite good in shape to provide a close enough rate. Therefore, the parents are usually hard-assigned in the dt. To workaround that, this commit enables propagation to the parent of the composite. If a rate cannot be reached exactly by only dividing, the parent is asked (for now simply for the exact required rate - no dividers taken into account). If the parent already has a configured rate, it's the parent's job to ensure that all children are satisfied. By using a notifier, the propagation-enabled clocks listen to clock changes coming from the parent. If one is happening, it's the composites job to verify if the rate is satisfying and if it is an intended change. Otherwise, countermeasures have to be taken into account (e.g. setting the rate back or aborting the change). Signed-off-by: Benjamin Bara --- drivers/clk/imx/clk-composite-8m.c | 71 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c index a121f1285110..068f61df28b1 100644 --- a/drivers/clk/imx/clk-composite-8m.c +++ b/drivers/clk/imx/clk-composite-8m.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -119,8 +120,12 @@ static int imx8m_divider_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { struct clk_divider *divider = to_clk_divider(hw); + struct clk_hw *parent = clk_hw_get_parent(hw); int prediv_value; int div_value; + unsigned long target_rate; + struct clk_rate_request req_parent; + int ret; /* if read only, just return current value */ if (divider->flags & CLK_DIVIDER_READ_ONLY) { @@ -140,9 +145,29 @@ static int imx8m_divider_determine_rate(struct clk_hw *hw, divider->flags, prediv_value * div_value); } - return divider_determine_rate(hw, req, divider->table, - PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, - divider->flags); + target_rate = req->rate; + ret = divider_determine_rate(hw, req, divider->table, + PCG_PREDIV_WIDTH + PCG_DIV_WIDTH, + divider->flags); + if (ret || req->rate == target_rate) + return ret; + + /* + * If re-configuring the parent gives a better rate, do this instead. + * Avoid re-parenting for now, which could be done first if a possible + * parent already has a satisfying rate. The implementation does not + * consider the dividers between the parent and the current clock. + */ + clk_hw_forward_rate_request(hw, req, parent, &req_parent, target_rate); + if (__clk_determine_rate(parent, &req_parent)) + return 0; + + if (abs(req_parent.rate - target_rate) < abs(req->rate - target_rate)) { + req->rate = req_parent.rate; + req->best_parent_rate = req_parent.rate; + } + + return 0; } static const struct clk_ops imx8m_clk_composite_divider_ops = { @@ -198,6 +223,33 @@ static const struct clk_ops imx8m_clk_composite_mux_ops = { .determine_rate = imx8m_clk_composite_mux_determine_rate, }; +static int imx8m_clk_composite_notifier_fn(struct notifier_block *notifier, + unsigned long code, void *data) +{ + struct clk_notifier_data *cnd = data; + struct clk_hw *hw = __clk_get_hw(cnd->clk); + + if (code != PRE_RATE_CHANGE) + return NOTIFY_OK; + + if (!__clk_is_rate_set(cnd->clk)) + return NOTIFY_OK; + + /* + * Consumer of a composite-m8 clock usually use the root clk, a gate + * connected to the composite (e.g. media_ldb and media_ldb_root). + * Therefore, evaluate the trigger's parent too. + */ + if (cnd->clk != cnd->trigger && cnd->clk != clk_get_parent(cnd->trigger)) + return notifier_from_errno(clk_hw_set_rate(hw, cnd->old_rate)); + + return NOTIFY_OK; +} + +static struct notifier_block imx8m_clk_composite_notifier = { + .notifier_call = imx8m_clk_composite_notifier_fn, +}; + struct clk_hw *__imx8m_clk_hw_composite(const char *name, const char * const *parent_names, int num_parents, void __iomem *reg, @@ -211,6 +263,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, struct clk_mux *mux = NULL; const struct clk_ops *divider_ops; const struct clk_ops *mux_ops; + int ret; mux = kzalloc(sizeof(*mux), GFP_KERNEL); if (!mux) @@ -268,6 +321,18 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, if (IS_ERR(hw)) goto fail; + /* + * register a notifier which should switch back to the configured rate + * if the rate is going to be changed unintentionally. + */ + if (flags & CLK_SET_RATE_PARENT) { + ret = clk_notifier_register(hw->clk, &imx8m_clk_composite_notifier); + if (ret) { + hw = ERR_PTR(ret); + goto fail; + } + } + return hw; fail: From patchwork Sun Sep 17 22:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388727 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 59866CD37B4 for ; Sun, 17 Sep 2023 22:41:39 +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=3fj/vD1F2Jvpc5RFBQGt7s95uqUv/qcsHIqU3YkG724=; b=eHdaRN0GZpEfhF lU0Xy+7guMccg1GXttNqU+lvRA2R/gLStyFvnXRvroteiypWDfgKFW9+fbSDwAm8/++DDaBj27vGk xtuIHQlkuwpiEvB2Cv8PrfV1Aa0k5mrJQcZvyNP9eVjkj/tRi1NVh3OmXjrzaIr/kza/v7yKm1bxk ta0DLkxd74XZF/jt46aCRq3bn/wb/wOucq8oJmosPguBmmOrIsRPIfNNnChxof8F+emoRUXoLCdNt T62TCu6MbFebkCJ4a7R9lbz/a0jr0/yLyFm7dCKk8LJzYpe+xByMhJXDRu8kuDSUVORROBn8HiJks 6VH+vwhbNS09ZzmD8+wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0S5-00E5Nk-31; Sun, 17 Sep 2023 22:41:17 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RX-00E50u-0Z for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:50 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-405082a8c77so5790665e9.0 for ; Sun, 17 Sep 2023 15:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990442; x=1695595242; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dQJrC2vG5It4Q7jqZ1TqS/6dJhYmmMKtvWU2Ye0A1e0=; b=X8cjg02iYIFzygk3OQQiXaOk0cmlpvhiqwXkQ+XNm471r1Ttzx41uylCRu1Gb1TdzI dAhxy/E/gfYYpPntt3esry89cLWeqstS6Xfh6VS//PAne4XYsVOOkEQ3oXAnkbC2YUvR r0AFXOERu1HDWZWOlfGj6+bug2d/2WRX+rWhpTWoIwfGRDRIxvDcgHsbVNDbsvwVB6vz ztSc8tvb1smYXAYNLQhxSP9KiKYuxeYmW4hVR2ev1FraK7OzUccPtFtvTdENXMtiVf3b pV++kZeh3+1UIWkw4EOkJlQpke0K3YwToRg/9s2DqIwY/9rb66cG7MLo1nPqLcpcsJ8Q xf8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990442; x=1695595242; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dQJrC2vG5It4Q7jqZ1TqS/6dJhYmmMKtvWU2Ye0A1e0=; b=Z300gXz6/oiqrsvPjGLObdLzY5a/926At1kx8y01sCvSHwzeVPuJ315YEn3h9ySEWG 0Ue7VobQQm3I+SI7OBLl1MzqJhArLwx5Va/PCbanne04XNQlSapDFpVbzluz7qGGA6Fw GKqMyteArFboH17wxcKt6X1XezFMjR8G+UQSIvUZzFF5U3QzP2IRhwZt2ylPBlr7aUb2 2NiweTvzKUt+K2DyVJzxB4pITHVRVvhXzWBUh9kGXsmSoHRSjhp7Aj9Kso3dpxTgyjUV wgOKproONC09iHATj+LuR9MlH+U5+NCvNEJocctsfNoGJ+NDjw/tjmUFVe2m6y2hVLys /tVQ== X-Gm-Message-State: AOJu0Yy+3xTj/gLUUFUcjwKEFmIxKYSQGey/safZP6ocabYUVKI1w16G eZ4bTZXbWjiH03iDyrEEcN8= X-Google-Smtp-Source: AGHT+IEMN4Y0RtC3E0hFzpJCX/PfrE3WOd7fkLRSAZR+Pe5gBDiWN4mI0PGB+DeHlwh5xtWtJzNbAw== X-Received: by 2002:a1c:771a:0:b0:3fe:ba7:f200 with SMTP id t26-20020a1c771a000000b003fe0ba7f200mr6071299wmi.20.1694990441886; Sun, 17 Sep 2023 15:40:41 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:41 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:08 +0200 Subject: [PATCH 12/13] clk: imx: imx8mp: allow LVDS clocks to set parent rate MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-12-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154043_216729_80A06364 X-CRM114-Status: GOOD ( 13.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara As composit-8m are now ready to dynamically propagate the required clock rate and pll14xx is able to keep its children in the configured state, allow media_ldb and media_disp2_pix to set the rate of their parent (which is usually video_pll for both). Signed-off-by: Benjamin Bara --- drivers/clk/imx/clk-imx8mp.c | 4 ++-- drivers/clk/imx/clk.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c index 670aa2bab301..fbc63012dab9 100644 --- a/drivers/clk/imx/clk-imx8mp.c +++ b/drivers/clk/imx/clk-imx8mp.c @@ -547,7 +547,7 @@ static int imx8mp_clocks_probe(struct platform_device *pdev) hws[IMX8MP_CLK_AHB] = imx8m_clk_hw_composite_bus_critical("ahb_root", imx8mp_ahb_sels, ccm_base + 0x9000); hws[IMX8MP_CLK_AUDIO_AHB] = imx8m_clk_hw_composite_bus("audio_ahb", imx8mp_audio_ahb_sels, ccm_base + 0x9100); hws[IMX8MP_CLK_MIPI_DSI_ESC_RX] = imx8m_clk_hw_composite_bus("mipi_dsi_esc_rx", imx8mp_mipi_dsi_esc_rx_sels, ccm_base + 0x9200); - hws[IMX8MP_CLK_MEDIA_DISP2_PIX] = imx8m_clk_hw_composite_bus("media_disp2_pix", imx8mp_media_disp_pix_sels, ccm_base + 0x9300); + hws[IMX8MP_CLK_MEDIA_DISP2_PIX] = imx8m_clk_hw_composite_bus_flags("media_disp2_pix", imx8mp_media_disp_pix_sels, ccm_base + 0x9300, CLK_SET_RATE_PARENT); hws[IMX8MP_CLK_IPG_ROOT] = imx_clk_hw_divider2("ipg_root", "ahb_root", ccm_base + 0x9080, 0, 1); @@ -611,7 +611,7 @@ static int imx8mp_clocks_probe(struct platform_device *pdev) hws[IMX8MP_CLK_MEDIA_MIPI_PHY1_REF] = imx8m_clk_hw_composite("media_mipi_phy1_ref", imx8mp_media_mipi_phy1_ref_sels, ccm_base + 0xbd80); hws[IMX8MP_CLK_MEDIA_DISP1_PIX] = imx8m_clk_hw_composite("media_disp1_pix", imx8mp_media_disp_pix_sels, ccm_base + 0xbe00); hws[IMX8MP_CLK_MEDIA_CAM2_PIX] = imx8m_clk_hw_composite("media_cam2_pix", imx8mp_media_cam2_pix_sels, ccm_base + 0xbe80); - hws[IMX8MP_CLK_MEDIA_LDB] = imx8m_clk_hw_composite("media_ldb", imx8mp_media_ldb_sels, ccm_base + 0xbf00); + hws[IMX8MP_CLK_MEDIA_LDB] = imx8m_clk_hw_composite_flags("media_ldb", imx8mp_media_ldb_sels, ccm_base + 0xbf00, CLK_SET_RATE_PARENT); hws[IMX8MP_CLK_MEMREPAIR] = imx8m_clk_hw_composite_critical("mem_repair", imx8mp_memrepair_sels, ccm_base + 0xbf80); hws[IMX8MP_CLK_MEDIA_MIPI_TEST_BYTE] = imx8m_clk_hw_composite("media_mipi_test_byte", imx8mp_media_mipi_test_byte_sels, ccm_base + 0xc100); hws[IMX8MP_CLK_ECSPI3] = imx8m_clk_hw_composite("ecspi3", imx8mp_ecspi3_sels, ccm_base + 0xc180); diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index adb7ad649a0d..aa5202f284f3 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -442,6 +442,10 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, _imx8m_clk_hw_composite(name, parent_names, reg, \ IMX_COMPOSITE_BUS, IMX_COMPOSITE_CLK_FLAGS_DEFAULT) +#define imx8m_clk_hw_composite_bus_flags(name, parent_names, reg, flags) \ + _imx8m_clk_hw_composite(name, parent_names, reg, \ + IMX_COMPOSITE_BUS, IMX_COMPOSITE_CLK_FLAGS_DEFAULT | flags) + #define imx8m_clk_hw_composite_bus_critical(name, parent_names, reg) \ _imx8m_clk_hw_composite(name, parent_names, reg, \ IMX_COMPOSITE_BUS, IMX_COMPOSITE_CLK_FLAGS_CRITICAL) From patchwork Sun Sep 17 22:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 13388730 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 2436DCD37B4 for ; Sun, 17 Sep 2023 22:41:44 +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=dpK990Vf3DvcuZtmwwyjtfiXzjRYeY7048GMnWgxwHQ=; b=rY+MaTvJjNAa2P n6rY5ijpDdf9nWUJJkqmf0OHGXS+2yBGPeZ/NAZS5jDsUKvUHVqO40cCX7pvaZU10kEloQG7aLnHa fAB5Q84ko5f07oPElhOrP2jaDmuW5Xg/s4FMH/DEqlN5keNud6i6GgRmKp77LmQkRwRNEoh5YqCkC cpR9wk4OWLk8TNKWGtixh2jEoRymn+18JtIk9wRnXZpvTzZbnOqm4OEQMITutiy3mwh4tE7x9ZJWn IjD8OUqhZvBNOBAYn4Ikx4F7Cu/6ITtkTcykdU+JoVCatiRLVmHTMhfwp3lIT4vtstVEbqpLhodCX ML5hUAPr9xum4qY03/pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qi0S5-00E5NC-1A; Sun, 17 Sep 2023 22:41:17 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qi0RY-00E51g-05 for linux-arm-kernel@lists.infradead.org; Sun, 17 Sep 2023 22:40:46 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-401d80f4ef8so43730555e9.1 for ; Sun, 17 Sep 2023 15:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990443; x=1695595243; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=q73v8D96q+uYzZz3PWeYupivBABq+k9drLmqWm/npWw=; b=LPxqsdWbUpTbsvp/oKIXlnyU9AaI8kX8xsAUKeXOLoqjFZ1bqb7U6DqDTpSgnyy3g9 V96xpwuQPl2u4ij7BdCIoMD+8x0FUWksymcZITiJJQwWvJKhhiG622H1xTEmKv9Nwq1B 0B3A3V6L3XFmtOF0rXz8e9YYzyq3uGHt9neiVa82YUuFW8IKm0VYUPmIl2uGkHs7FHGx Te1rzfUtacSqPQa4ChtsvQxGtSBctODIAPDaxprqbVGvITTsi3HTvx0LLRCM8L1olt+j on9PTeqMfNQbxM8b8VRPobvZLcDiPOE1q0Uzke3zgVsXQHwDDltZKHpDsAMQKiNkhmuz SykQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694990443; x=1695595243; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q73v8D96q+uYzZz3PWeYupivBABq+k9drLmqWm/npWw=; b=BYg9B3UGs6/Xkjx32z0BYDLve+hQDFXJOZ0CDtba700DQB7dNhbEODW8hqbe+NNd8b VqtKKaPD4QpDoZE4lJCITlbVTrQ3VWmHrq0M9FTQzN6Ui+ZUPUZUQm1luhfqSSAwvorK m/RwDU5aZ5ro50V/9exbGDVy6jxNdu/pQwog5q47P5qz9Kv1GB8kOZiLc5ty6OkZEdTi U/5XmU663DWzy2bII6LOgZdP+a7ti53CW/9x9jnxAg5TX2q33uUWKjrWmNn7e/PPJLPF wpIZMTgWP8vb4iqavgWJOxbkOml/6L7q2jRKAKmKWnGlOMkOJEbQoXgkK0RyF0KRu4Be niYA== X-Gm-Message-State: AOJu0YwF9ilUSXqwnWTEvQctLUbBYems4I6Vf3AaZjocu7I1ewL9yNdJ KJEAQMdfWZ+w+OF2KQGu54g= X-Google-Smtp-Source: AGHT+IEpn3SKMcUCwDs+OcB12/E+cy0JKanTR9ByM5/NTtb05D1WNb8Mw67ZleN3ZGoklRFRYUBneQ== X-Received: by 2002:a7b:cd9a:0:b0:401:73b2:f039 with SMTP id y26-20020a7bcd9a000000b0040173b2f039mr5934394wmj.7.1694990442771; Sun, 17 Sep 2023 15:40:42 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm13642931wmc.30.2023.09.17.15.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:40:42 -0700 (PDT) From: Benjamin Bara Date: Mon, 18 Sep 2023 00:40:09 +0200 Subject: [PATCH 13/13] arm64: dts: imx8mp: remove assigned-clock-rate of IMX8MP_VIDEO_PLL1 MIME-Version: 1.0 Message-Id: <20230918-imx8mp-dtsi-v1-13-1d008b3237c0@skidata.com> References: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> In-Reply-To: <20230918-imx8mp-dtsi-v1-0-1d008b3237c0@skidata.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Michael Turquette , Stephen Boyd , Russell King , Abel Vesa , Peng Fan Cc: Frank Oltmanns , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Benjamin Bara , Lucas Stach X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_154044_070935_8FF5CDC9 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Benjamin Bara Similar to commit 16c984524862 ("arm64: dts: imx8mp: don't initialize audio clocks from CCM node"). With commit b09c68dc57c9 ("clk: imx: pll14xx: Support dynamic rates") in place, the clock consumer (e.g. a panel) is able to set a more suitable rate for the IMX8MP_VIDEO_PLL1. As composite-8m is now able to propagate the rate through, avoid setting a rate in the dtsi. Cc: Lucas Stach Cc: Sascha Hauer Signed-off-by: Benjamin Bara --- arch/arm64/boot/dts/freescale/imx8mp.dtsi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi b/arch/arm64/boot/dts/freescale/imx8mp.dtsi index 9539d747e28e..f40b40ee8f9e 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi @@ -1742,7 +1742,6 @@ media_blk_ctrl: blk-ctrl@32ec0000 { <&clk IMX8MP_CLK_MEDIA_APB>, <&clk IMX8MP_CLK_MEDIA_DISP1_PIX>, <&clk IMX8MP_CLK_MEDIA_DISP2_PIX>, - <&clk IMX8MP_VIDEO_PLL1>, <&clk IMX8MP_CLK_MEDIA_MIPI_PHY1_REF>; assigned-clock-parents = <&clk IMX8MP_SYS_PLL2_1000M>, <&clk IMX8MP_SYS_PLL1_800M>, @@ -1750,8 +1749,7 @@ media_blk_ctrl: blk-ctrl@32ec0000 { <&clk IMX8MP_VIDEO_PLL1_OUT>, <&clk IMX8MP_CLK_24M>; assigned-clock-rates = <500000000>, <200000000>, - <0>, <0>, <1039500000>, - <24000000>; + <0>, <0>, <24000000>; #power-domain-cells = <1>; lvds_bridge: bridge@5c {