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: 13388735 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DAF7CD13D2 for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238442AbjIQWk7 (ORCPT ); Sun, 17 Sep 2023 18:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233811AbjIQWki (ORCPT ); Sun, 17 Sep 2023 18:40:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD5112C; Sun, 17 Sep 2023 15:40:33 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401da71b83cso44664655e9.2; 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=vger.kernel.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=SquOoCsH2dp5wpiAJU4Yd/OCW0mWlmWI2IXwwNROol79+i22MLuTBZ5jHRaTENwPgL 8HzfRHCeZi0FyxMO38qYGqMz5kopYlp64l4rme7lbJbnolv+Qjcwu6x3qbTUn6b6Oq/k CzXg4imPrBcW2l31ZOR4uIr8Ev3xk4RPcU8z2MjJP1y3K49/S4QGbqdzBGJMXTlomC8G ekqBzWz6vNMyB2zMmqA62xuwKP9y55tmICSxPgVMlWMI7o668SjlnVp72a6SuwUXUbc0 gSWAl7pVrzDKGxpkfDV4EMvyM/1lkvzE9px32nK4autzs7rtMkKm6QgxJtkTQtF/QzKW QIJQ== 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=rsw486R6bov89vTaJ4byHTSBGdd9XyU2pLuPt3Oy2SBnyf9OoZwiu+ZxOizyJXRagY bZklmUa1Dda/868T2Crv0JkIgV+SFVqqPfTgp/VoDe5i6DXeJiIK41JUIOppL/MeVyVn zQsepnWb94MB1zzcEHVYMnX6DWjdmd55LGgkFHa4DydodhdfKIUStpZSVs1xJsiipgzj suR1NXnGxWSa6cJVPTKyGSWONWV2VXrSg6WIl/Xva/AbBdfTRj9PoKniHDBFbvJok6qj rMsUI+o/i27nrqWwIKF3kGDwMpOipFUtlfhaazI83/KwFa2Yb1RqN9Nlp643txtk7Gpy aI5w== X-Gm-Message-State: AOJu0YxBpb4dg0HkE/mk6s+64VN5nUc8JRY6Ogf3XaG4+YaT7TII7EMt r3nyHYph+PrXYRs9MoDrQBs= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388734 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EA20CD13D8 for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239032AbjIQWk7 (ORCPT ); Sun, 17 Sep 2023 18:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbjIQWkj (ORCPT ); Sun, 17 Sep 2023 18:40:39 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 627B512D; Sun, 17 Sep 2023 15:40:34 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-403012f27e3so44636355e9.3; 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=vger.kernel.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=jWIKQ39oDrDUCkUhPcCAP2YKqL8LQrFWAuoPYs5oa6/WcgEklDOBebTnpL1di7pmyk IB2cx3qnoGhUR9+DYYSibj8n7mgvOVnjbtmbvdaQWptg8Li9k2504ESc0KHuURItErY5 qoKCwH916xGxsL2vryMLmBeVzf6LbHrdlOMq71IVko5isXDfgpTiBFimjZQ85cnfT5dx 0jAxRKd8OQaDqkz0bkmBe/JcVCogPInq+cMuNFDhJCTaXgb/IJ/Dnc805YpBWz8Vtu3M jPPb39XJ5a3UiRxuuT/qUaUPSRcejbnFLvwbwnXSMOraR3v/faQB5Io7VkxLqyYmS3Hx +hIg== 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=BMBgEmxRkNzxV45WAZM8j+jbpuoyvWPnJrqaPUu+9IYtPcQptxlKXZnrjHfqjGhFsS wfSddRAWiGpVznbZn4Z21AmRmz4QQqh4nLkOIigCueSWDBGqmzjhyjb7fp1ns/UIexSH LjYQxDVx3Gg6/5YuB2/hwkezwtKowGRM3DkNCieNzMnGPck7Q6GYvFlwp092VvTouEBb WjicOpaWC8/qKWbCs3Wt0KhXXTEPf6p8QbSjZV1SRfIyrBsGKFi1f40I+Y4ulqEyPYnx VTGXnZNys4kRbRYYojKo9336xOtE8tlmqjnkFA/hcA8AauaTqmK5RTJSq2CAzpx9wBQi wGYQ== X-Gm-Message-State: AOJu0Yylus33jOgu8RlVPZqQvHhsLTCUkJ9p7Ap5RzjArm+ryGeLAt4N AEYoFJRRy9s7MAuvnIVoqeA= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388733 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D6F1CD13CF for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238921AbjIQWk7 (ORCPT ); Sun, 17 Sep 2023 18:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234634AbjIQWkk (ORCPT ); Sun, 17 Sep 2023 18:40:40 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71FE9130; Sun, 17 Sep 2023 15:40:35 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40413ccdd4cso22025245e9.0; 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=vger.kernel.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=jeDqhSr6FI7PiMIYasG3rO2uXEgINeM15EI7HhFzBc5HHTAKN127bTEjvbYvy1P8Kd knX3QlSVpxGiQqgfTOn8CYA7FQimcw5AMZwgeYouYtcN7GRQlJMHhkCAtbBTw2HIFlFM XLRsYPsEOqN6ugvVYmW8cIOhvRMVZm0a9xJxSSV+uswCDof2Z1w3dT/sVNVbJViiT8Vl F6lARTx/LRWztFQfdC+KWdgnmVfHlOtpuSiVSYNHSPXTgi5qBnUo05YFgiCl/KhGFI3c 9vM9Q5TWSETk0LvIjckAyryjGedplRRBY/NF9kgnIsi+T193nT7Hf7qzVpld6WGtgA/c U5Mg== 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=CStjJfPMMOf+LyBbcvVhhNbPFEeNYbbBZrFlWHIrBCMJJTsFz5FaXavEPHbVrHIEiM COI4NgKaZqJvCXFjuklDh3GN9VSVUGAVFTeD2nhLeLXhOiU2zHDWHlDbQDPgmnkidlqX +xA+y9OhgofBQbc9MmhUJg0+sqVSIScQ3McI15Y+1mnIYlVQhCr/id2OX1/AXmZli/2K xM5owkAU+IP37XT4aV7gKUlUfiLydHUSHB2r/w8G7Wgy9c0BsmlVDDuECfJ7NiwYmBuA avVZWZ3SagjXMhq/wnaobbcJHH6uiuRczR7bPTmkGahbyFGoBa5BC1ns0VPFjMz0pDYA dV+A== X-Gm-Message-State: AOJu0Ywt4aX2+DXIs4PRf/rHjbYZ0ELMVYrS/gRwpKaFO6FiIdiGJCfj b8I0pZ5XtXJ4E06EBfjXXpk= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388736 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E0D0CD13D1 for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239126AbjIQWlA (ORCPT ); Sun, 17 Sep 2023 18:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234732AbjIQWkl (ORCPT ); Sun, 17 Sep 2023 18:40:41 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5119412C; Sun, 17 Sep 2023 15:40:36 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so42429945e9.1; 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=vger.kernel.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=BkNdvDP2hLNDwlr1CAMI/gfvY0qEXyu1ak+Q7zjfYCZ+UJ9jnlqKpnqonYngWhAGuL EzjcsISPsK9a4L0oE6kneUNx1/bCmkMsjL17UuZqqHAp3drULOy38j6OvZHE5VvgoynT RhDdrwNTknlDaBsuN094DKCSn0GOnCO2dF9/Z1hpA1fD2PSnzr8kSpTHLlNygr8mlKQj vAFeWoHWOTZAkDLCqlpNllpAaJJjHeJgPCS3yoNKqpfUPpbicdw3qn821H1aOD9TdpFs a1CY6gtFybeSuagYEpm8k+v2tNIgaOglwDHXxGVOZO3RVO2/lUc455zNmdB6zhcHIpnX zUog== 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=tx064o2+RKXy0Lk+4KCvP7sDvjJKMzDkg1IcfpNane9O4VxwyoV6kNq9ygJ0fRjWtq cgVKrNQjaHZtnCiqC+O2VbSFWv2+u4HRG+7Uvtf3h+UFr/hutIhFQmHJge4ZfYE9OwTw QPIF1uJ4ufY7jT0jibbVk3xU0lrC50B9bMwGIVKsycP0tUKa4R9Fd5rD47FzYBCs9gRi LIijYlKUE+rzZPnfywVeA/74s37sKKMnLQ3TjTCnyZ+73Z3RDElgpnJsQ4M07cIGHQPV BxTAW2k1+qHwSy/yFWuZgjyHPmAuIR9ckMr1vP32uHRpB3R8bwhNHqREmKwBpXbTYZLs hcnw== X-Gm-Message-State: AOJu0Yxt6WGYWkDCaRODm2C+pF0zmtIDLL7n0xzLjJsYbjREY0WBdJwX c2s4K3SZfeGspYhb0oW1uxY= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388737 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEE9ECD13DE for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239336AbjIQWlA (ORCPT ); Sun, 17 Sep 2023 18:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235283AbjIQWkm (ORCPT ); Sun, 17 Sep 2023 18:40:42 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D5D512B; Sun, 17 Sep 2023 15:40:37 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-401ec23be82so41938855e9.0; 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=1694990435; x=1695595235; darn=vger.kernel.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=c3gWT+ktkGFTAsvVOZqhzvIAYGwF0xff0TI/tiBaHCNA7vazqV8/L27g2EaeMjg/aK 3NTGmqVBnQaxqOomdOmrLGTyVfj7eDQZgZvdqg+MXT2+J0pKSt2KQGYifZ4P5O2NqH9N 5axvBr/eVnl6T+3PfiRS3zvp90aAY26AwNx+A79wpp9WH8FzpVleuI1AGNdled55l9eO OPwjK3u2W+bjfz4hCmcT05+aQ4T9V9AH7WgtvHo3y1whLZjtiMme5iH1YhzgLHiaOY6R j8d0/GTO9oGJFfLFOUvCSqVLnIuQ6KMhYYWXCL4eCmNObAS+UiszRuytendi60ww9SeW fnyg== 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=GpC49hf3RaUZOiJolYwihUaFW9kkuG/5i4Y+c4BybYMsB3S8qJY5cxLmWHmT5LiLan IDXzbg/yMCOVgf1dzd2p7qUyr9OatxEookUnFkVGFCAXUQdgv0cjcMcAjSmqpvXRe8EG GQ82byVUtY5NFSNxYAHcygDT5cfs5Q12e7eVLAw8S/8KaNVkxbDyzklwawvCU/iT/8d1 8VjsfTsUnnIWVav3rL9OTc6fw69NewtSziAcLimQtKbA3niYZrjJNbKbgHqNKeNLY5LR 7IuASN1CV/r3C5mCwwX5j9sTO/YI3V2k22PAv0ZaGjQh0CgZg9WODY3dlsNEvcUgtCfT nIcw== X-Gm-Message-State: AOJu0YxCW3X7LRuNogG1nI4GuZSICqHz7OdCDBo8y6oRn/vTlhVVnvbi zYa2p5CRnvCdBYfbXGmfIb4= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388739 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF637CD3420 for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239414AbjIQWlB (ORCPT ); Sun, 17 Sep 2023 18:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236646AbjIQWko (ORCPT ); Sun, 17 Sep 2023 18:40:44 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D4B412D; Sun, 17 Sep 2023 15:40:38 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-403012f27e1so41840165e9.1; 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=1694990436; x=1695595236; darn=vger.kernel.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=Ofm6xD6hRILie2GXLkZfknjM9VFJ5qhvjeoifGCy9YIbK/Ov0mizRL7wN1N4PV5ga1 NASPraLe8QJRa0YYO6gAd5qzXIl7/fuD11S+Gqv9dVnvR9j+QGp603L4zfAIBHNpvRYg CtMUmbHgO19lFSFgCKXLLWiFgjvV6N0tZABKxOL6oK76qfahsCtjMc6IkjIyeO6WdiyG 0wsPP8G05m7gGNeD8piyxBvcTEXwZG13wKKRsTZuUlei1K2t9FIdkN6RznUuqD0kUb+P 25OTftf40/RNAwUnWDIE0hq6MFnIkdFugeCEaeHIrA+KbMCayRKYcFSHU5v0sIMbevEX R8Vg== 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=Ke6rMRyWSg6/HoqhXNe5gWZ8LV3rY9voWXCBBsQYnYlS9XXwkv8nZK5+bPY2P7+rJp dQOO5H60M6XaqmCT9hy9S74F3f7n5ye49stxXEh46PeMUUxlMQW0fh95G8gByjP8jOP3 YtajEOBkuZOsuzk0+8A0M3oNBhy7a+ol8qfXqUtzhASUcrCu+oypK+ljdKk5QcfoJ/di YtjovA4bKfueZrRaV7VPd65F3H1OcEw723qlW7+2DmkGqOT56nsWcfmOvMjlno9yvlSx 7XIBO8jJqA+ioYgjLkR5zbjAsi9tXi5FrHaYFX0Lt2kMxF53P3QHfaR6O2fRIO9hrbAe WeVQ== X-Gm-Message-State: AOJu0Yxd5fXthXnFLHt/HuFzf71Ahqebm11CjdNiP62KS3OjVoFB4By+ DxVNv0PEykQCQA+1fSA2hjw= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388738 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF5BBCD13D9 for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239412AbjIQWlB (ORCPT ); Sun, 17 Sep 2023 18:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236690AbjIQWko (ORCPT ); Sun, 17 Sep 2023 18:40:44 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B75412C; Sun, 17 Sep 2023 15:40:39 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-404773f2501so33760315e9.0; 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=1694990437; x=1695595237; darn=vger.kernel.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=Fs1yJekj5VZUsnEwk9NjkR7+d7C7lyzCpZip1ahwWs1mGgft6TG5RqPx+wrvTtqsWZ /QCbhKrRJDXxHldMLq3iHY0DvSJ37cGAsd7rO7u7G/UnOnohw8sUhKsgv1hvGTDNDAww OX1qTn04J6/iBfzcbRpJdPelsM1+/TTMGCiYgsKVnOiS154bMd/NNIt9qBLDJeXCilSZ KH4tAyjbUS8GMCB2HoFbFGcUmmeuP6Cl+f74TnNYNpq4AkxAzW55/wRZtPH2ugWiikcC 1OO0wAH6oq7hdQYEhqqvGXuFwBi9j1ffgisbh9sYlvjgvGgiOaL7QWlnO2eQWUtCdhWw iAxA== 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=VXyNeom/Fyb4dEl2F1Y5JaxUVfwz3zHMy5p7T1SbScVrYrFJhvSsihGAOehk9q9k9P Ea55zYD7NtynzM5/E6wt2bPGX5xTQbdfThUzr5GtPezM1yo7UUnz64zaeQCG7sm6xOrA ETZXEfxQGNdKH+yL3U14tiBoxg/DD/eeyH5ukz6c7Zb7lHHpfhPSgSctb2ZSPSQtpkhU 5fhd1pwaw+PrxOtxRRABr1G1jHj/wPtmEW9ZTnTAZb7VXebpbjpIY+6oDvgW8P8II5GB +1SRmnAKEw/+4aJlee8aK9gP5j5hDKPsoIplFBwKmY8UWxmvyO+cat/NaloJzV9EUwwZ 7tfg== X-Gm-Message-State: AOJu0YyIe0uu+Qhs+6T5rOShuYIqN5wHgEn7t7u+ESt94JseKIqY0jy1 mewS16w93B3q9CTezvjGCyA= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388740 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C3F4CD3423 for ; Sun, 17 Sep 2023 22:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239447AbjIQWlC (ORCPT ); Sun, 17 Sep 2023 18:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236839AbjIQWkp (ORCPT ); Sun, 17 Sep 2023 18:40:45 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8D512B; Sun, 17 Sep 2023 15:40:40 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-401f68602a8so43049755e9.3; 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=vger.kernel.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=fb+XARL7GHZKTJ98jveBVuggR07aMYJzdA5ocCm6o02ErWQjlQDE1CBShE3P3LoxZu 4lX3/PewNS6/YmljvSfFF3EmMBBO30P0BTc3NS0TuEgCu4kEDjM/pO3AiuSOIu5dkyoo Sdb7jU2e2y64jf4G1yJHgap8G6aYOErY4viRdLPBhfBn017inFLb2HxQ0LVnRjT6qq8c 42D9C7IKJaCKPJWN1xwmxEgX44+m2dF5WDj11gFUbbhBsnRo9rgU1YyD0bKrpxp37M0L 2Uevy9U5RHzaHUC/Y1wQKiwZpMlOnCAJ4T+n/3Scpz1275nTXz36JRHX+IXflrMlcDPA ZhVA== 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=WVw8FCnrueyJR+4Yrun3q+9GKNvicO93eL69NcJIXoO3kHIgycMmHBeh3iMPSS6+5O 3GIQ/9P3BdRdoywP5OEa5yXILQkhN3jjmv9wHlq3X/8znVMAlpsAhl/rb2HZuxFvLaMa Ka/ffVS7kTop05HqaoEwHxPzH13FiZjz8EkhCDNmv2Ybo/O7sZwQ25BNV+u3BxmjsT+o ruNDPQ4s6iOg2OSVklhcY+NgYDifuqamBRok47kQ3AuUJLPJhwHhC+7UNr61X3gk5hKA s9NyzIR4t9La8Cpy+TYEvPBwVip2CQ4uicoNVWJxwsrciSREarHHPG2OYW/A5jHLH4Gm FLyg== X-Gm-Message-State: AOJu0Yygut5BIMrvDJDrIYiw5sCcvVAxzx6CmN/2Q0pGdoEQ2E8EPXrt TAYxuZOGgzt0NAf+LFRO04Q= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388744 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E01C9CD13DD for ; Sun, 17 Sep 2023 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239434AbjIQWlC (ORCPT ); Sun, 17 Sep 2023 18:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236990AbjIQWkq (ORCPT ); Sun, 17 Sep 2023 18:40:46 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E71132; Sun, 17 Sep 2023 15:40:40 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-404c023ef5eso20885735e9.2; 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=vger.kernel.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=F2jl4/uEJVJY/PDXH50nrxulj5MAz+7wSXtVOPFyXGzsqJECZs5Q89hctxlw94hYWZ MxlUIeC8l2uR3EiU03QFDGLSdM2eLjfTyiAVGVFNWK3GI69rPM2mG0wVJF/HnD99xbEZ d3ec9t7HZFV2mcnyw5Wm8s0m0yC9zwtLG4CfhmQdGwzGvf7YQPqC7kb0VdZAiBB6lDkU IQx3iV8KXp7KDISQTTX9WBqbT7E7PV2NtVebQk0d8xZweJJPRrHb6qMHO3CvuQuuHgM1 04DCoJ9NvWrgLmM3wsd1sGjznEld1LrRaqIcQ7FgGf0iFlP3H+5iuVhz6SraHCTj/5c9 pt2w== 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=sd3sGVqmvegE0mA4rFZQYsbizf5tujf4rk+Ap/2hi7RKhXJ2YxhCvjJwYOiRU2r2XK +b4Obg5Lpc97+5KDsnE3h0NEeuqu9wsauau5yGrbHJD2Eh+NWGo1K3rcCFia+c6J46sy yNOR7dxWpU37AJvE1TMl//wQR9r2xcSnuNZqb3XuefNuPbF0Usw+wN4Bh39BjYbG3W2F /+q4PKwM6KyhTTu8AT41KRMry0z3ptTvfWtVq8ucXkVYCSP72UgLxmECzzoI+9r7cpJA LcD3F5qesAgmgClQeRlGe6P0MeR+RZCg28CWUpO4nZj3MQGiqswpL5cwntUbOR+bhK0p 3ICA== X-Gm-Message-State: AOJu0Yx6p/vGn623zYjnyaGENbCbpWeJolvIyHimrqvs7B1pmBrNZZwV 42GXvXohhrbgwxLpbRCz7bI= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388742 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B0DECD3422 for ; Sun, 17 Sep 2023 22:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239451AbjIQWlD (ORCPT ); Sun, 17 Sep 2023 18:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237118AbjIQWkr (ORCPT ); Sun, 17 Sep 2023 18:40:47 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D274E133; Sun, 17 Sep 2023 15:40:41 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-404c023ef5eso20885805e9.2; 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=vger.kernel.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=GXF4INtM+N8DSHlep15jKUVWIp9r/WKwCl8Fjop4IdKCNs+55zs6CsmZHdh5+vWzax 2j1MQkQLsFQLAG6+HiIfVqVIhNeuTNlmhUZw7/cvXNlTbunHy2lPjh4dVeh/B1MtiwM+ aNEItpncQEkmeH5JyWBeN72R1YED3F2puB5a4w/8d0bRxcU6KXhTbXYqUUHqr4lTM6Q1 2p9exjVZbpjnc4u+G+6MFfJXOSgCm1Eg8D5CfLR6IrGwh2q+jZzwTVQEPpV388wLJVmK RZhgdsDXTgLEvqXIrU75R34yLu7b7xdQVnfzgiKqrpQGUVhpXApIbXkCH83igLEY+QdW mWKw== 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=mJxpvT/3SVLFW4N+UrjAsOBMfLtHXVjSKWzRH40ez5V1D/Xk1gclRyFzL6z/K5DNCy DAq8nVPs/IJl4t9YKjHjfnfvQ7c3A3SfacKUO2N6gcvvHKL+YGUcSQ4eVJIc5WiLZ2Pu QHuuLLxuWsxi2HrJhQcNIx2MzYwnq7lx0IYShpRr48ryKifEweK0nzua/Het7sRxi0+h MoLDL7UZWPxdUB6EiInOp8rfrf6VieicgCRchkM7Cd8FzxSemR92nK7IgW80BsA0/VOe SnoowwVH1DdAPnVAb6O3fv08fU9IYH5DgOHrDIjdox3Zv7HxV1+0HKFXlMbHjF0ZsQ54 vvcQ== X-Gm-Message-State: AOJu0YyamfmwwYYuMg/ytdXF8puoyP00TVs95bbO5rXbSTXLHgPsPQ/C GjUA9C1J/bGRiCSBT8ul6zM= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388741 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A141CD13DF for ; Sun, 17 Sep 2023 22:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239460AbjIQWlD (ORCPT ); Sun, 17 Sep 2023 18:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237426AbjIQWks (ORCPT ); Sun, 17 Sep 2023 18:40:48 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E81912C; Sun, 17 Sep 2023 15:40:42 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-401b5516104so42229985e9.2; 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=vger.kernel.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=EDdjdIGq2P7Xcv8PTewEF6v1RKp/aAo6CdgQlXiuUxJoN1KGwOSCvXSdin+JCy8h6c khklOsRT7uUW9r/H/LKBpi9atO1TixYZUZbqw7tupfo9Y9TNg1qK9LA03g5s5cmdnhTB 7GRVNKZRVy7FU5mpYZirDWPioOpyMYi1ylagszL2Utaja+7cwNirZU3EaZQIMHyb/tko hUaO2UKcNA2gm6QqCiGCDQSBnRy0YLXzdU68ztsltiYrG6batmzBAqTcKbBkIYVZ/jd4 SsT3cN7bI8yk7y8eN/FEn4jPQrh61ekJzoYexDrZKVs/evUeAaa4CMbnV6+QXFYzmCRm nhfA== 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=dSBtFbhFxmgvhygqfB3Y+VjsuhnKFnxgfFTeIm3m2JuwbfcWYCMIhCzzXrAidveUCi KiH/zGOiEmCQ6SfHXgDs6oT139M1L/h0EIs/SFgRJl68IhZU6Ot3xjjkM2IAbiVO0TIv NdIN157uKdSb2FV8V/vMOkrxj4mj2N9eYhx9kLQeFyvehqjDRBHm/4ob+GEdhUktPyF3 YZ5gzF9O0wbUsp5Z72zanmId+Vmd+hkSiICLQEYEtLPYMt/o9CUC/yiOYnaBlwe6IGea gsrDDGivSFaLDbBxjeKI/hqB0NdteR5hHCIxHnRtKVZD/K69t0oqLf2wknPC1NBmSYNw B4/w== X-Gm-Message-State: AOJu0Yyy8fH5syG+MI+u7y3E/6V3G0pfo1piz2YoqLWIXIQ3YWUr8bR5 F6E1IVti8lkVm+tlnueQ1HI= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388745 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A65BCD3427 for ; Sun, 17 Sep 2023 22:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234562AbjIQWlE (ORCPT ); Sun, 17 Sep 2023 18:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237519AbjIQWks (ORCPT ); Sun, 17 Sep 2023 18:40:48 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78294130; Sun, 17 Sep 2023 15:40:43 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40472f9db24so38546595e9.2; 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=vger.kernel.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=bKt6lnL5RYEGk0CZ5w0ebgl6p26PmUKjHG6i2TvfaCbONA4aV7vA25yUon31DZ6hxb 9ON0RKtvLy6bERnr2JKWA613UYyHmYiuLenpZlYGlpVBPsq7U7/K2l66rkLRMghl9f33 iF+MZLFQoGmAA2/tqahNRcRTmHTykldjvMEn638+0FnrEIkAliLfp/zbP+jJ7l/pF3au 427MYWTQINTXTUmu+ZkbZWzFxQn8w2a+/u73A/F0yRPpUHBvdsPoPbXMBuwv+Mzk0mif 3ASCcIesnzSxGZIiOqkSqBTuElg8PzvId3CDdieS47gYW3t9x01H6TLWeR1tCkl7R/Df Y/YQ== 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=M2sFkCBPcNEleRye7f9GIcAaw5X2JX4uhnZERvCcR3JuAdL4ekL8ejmf5tf2Do2g1n KJZeeKdbj1xhQcZuR/cnSColoW+Wru47QVra1pTAK456cJArcAMneZfCYsVOusMEvLec xsq0VN7Z++keW98XOqer2o9wwKMAwmmmFkyXMeIswmrwnLj2veOWGPpvx/yyLvM7i2a5 e8C3UcDDN5E04TPa7jadOwerWJrzaBNSmqKFuoDMjJePJ5pLiII2YmtueTwPXg169Dg9 IKMmVDllSJG11uoemGP3q3uPHqiYs+A6ZvdVi9avXO+ilTEwa02/3mI6FLWUq/QLVwqU F8mA== X-Gm-Message-State: AOJu0Yw9Vpd0PguUb9IX7JCnr9nnaoE2IKeFDhIVDtbEF1/6HA6WJDD3 v0AKRjg381BstA5nxaBRKxA= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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: 13388743 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B84ACD3424 for ; Sun, 17 Sep 2023 22:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239472AbjIQWlD (ORCPT ); Sun, 17 Sep 2023 18:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237657AbjIQWkt (ORCPT ); Sun, 17 Sep 2023 18:40:49 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8D312B; Sun, 17 Sep 2023 15:40:44 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40472f9db24so38546675e9.2; Sun, 17 Sep 2023 15:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694990443; x=1695595243; darn=vger.kernel.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=XPdwnmPX7Uo7XL0MbzYRHJBLD3Qw1RopjLmq1dHP420FJsWcPnZhdz6HzDovzG4q7D jNqqR1Yu0OYo6njNu5hoW2O1jS6tvX+G15gBPt2LiM9CwOtSKrymr03w9R1+mELWjtWL ZHASdkxqnU7eBMtCEy04e2vkKq1WkcsNsMDxiB6CEglVw7jkp+bMZVUlDztKRvYd66th 3cHPWcXPJWIYeeSj88mw+tsFXjKRDhyGwZGaCTzspmxK6q7q4BJTLdt1JAgp4mamg8DM q7JGxATn5DCBfSGHM34b72Vg1IivD6AyKL/GPgxw2AEiAOotWSYTfNwpKEUrlvBUS7kl lfRQ== 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=h2ZcKw13tugWoXulXCBIbN1+E2BSd5cVc6XI8uvWxrf4u3yXI6gezkv2J1fv8WWAbx 5SDcHj92wf1vnUOJGVNgQ8kqpj6IVdCwDcjQGo15i64vc5yDg+BpQnkreXS60/TkudB4 PCtXSFmvuKMSN7NXQ+dD2RdGpYIJBVJiUvAxlX+mcZoXNCzcZdN8Anl6Q5k92GH/B11H vTyP1yZqMFNFdWMG/EWxXjrbmZ9XGYEku2mPiARyFsOskluwGZmYBGJuWdOQ/0O5nOF4 YPVp4S3Lq/XwDdyGK2yjES3Jc9yShVD+eAVKcI9Plin5pfcGj1GxauKZNeXITA2cRgnI XKQw== X-Gm-Message-State: AOJu0YwEhkbUj4rBs0pHcRwHmJQK86otKeGESt6yd5L3MmiLtJGz9JLg kQwVvgw+6pYOP7Awj/SAEYA= 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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 {