From patchwork Tue Oct 3 06:21:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Buddhabhatti, Jay" X-Patchwork-Id: 13406784 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 1F539E7542C for ; Tue, 3 Oct 2023 06:23: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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=egpBVAB4BsQDnFUY6irCpeed/FUIKEnOZGwsHzMS4IA=; b=KjoYHvgEns8++f Lmhuj6YHciZhLehKix5RvnhQ7MYZJMasMn0lFMEOP1PPaV17srRsid8FX6ER8Xo9HiThvAnGknKOn mmx++stInxMZDfM116f12p7BwmfkC1R1cMQLLzpdHIqBpP3suOeg2/K5nkygl4rNAR4yxpD2CeuoI L1HILMl/Q8cSmarO1IJ6ntzMB9zLZu3U26+frHkGb9/yX7LG5jEZKUyYZnit2ImlHfX4GkMLbAJZR UtkMHDqVJb0wXin88ff1fBSDB5S4VfgTTvegiMp37R2r3lQ+moZOxdDXi/dP6VIh37C+CgzDWY968 ST1q5cbv7Zci/VaNow8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qnYnw-00DuEY-0R; Tue, 03 Oct 2023 06:22:48 +0000 Received: from mail-dm3nam02on20615.outbound.protection.outlook.com ([2a01:111:f400:7e83::615] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qnYns-00DuCY-0r for linux-arm-kernel@lists.infradead.org; Tue, 03 Oct 2023 06:22:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J0ZtMetMc2N5XXJecM6uFulfN/h5NKB7wA59CusQZ82Nx++DRLiayzrK9uzstdeWsva59MYz35v4ovSZxMx8hL/HelK7JLFuSd/74jM4dVx1t1eYIMd1w9DrEfOkkb61J2S+dm/X+fbtslU8inWs3AutUHNaWgGWAC4Mb4D2kl9vLYZFIt6qbo0YFnlQXVqAf/uWT5CTb+/uiBMz5zjwkKa5utiIc+9Yy5Hw2aPmk3d9RvFMF3jVnbHvfVbZzO4Cy6lsH7Mnd/geHazI8E+M8DRV/cuCmEYExscWcZkPt0VPWswrbpe7JdBMO1JILZLB+o+xAZ5VEdNZ3WKnNbUEsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GN4yVn9esUyFcQcbMxFoKgdLb/vw51euHpR+9+X+buo=; b=kJsG4KXoghbtyIp22AadyTRI3UGgEg0DOk8xpO9TFH5B43qJTTcOknEMpbKvmWFvna03ihoioPaE7Wud26CBDLxZ/pEEVSCYHhCMfg/MgUgD2DXTFRBX2XAnxbwzqUB9uH8/C7wy3IIcKSe+hcFQKfr2iFhkomQcojZ1LQ4tAqew1afcgqyK7YCq9Gq7jWhJxuyER47Gp/blSxoZpFnahe406bbVzvN3hQE+P7LFYzscazJYBPN8GS6KfmiDtbUQDJCwGv0buLfRXB4+f+zkkUxjM+B6dsmos9sBdN6Xx4/koIaXCzjXgmudZ2wY5CqAzekA/HGhnrPof1my4ElY0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=baylibre.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GN4yVn9esUyFcQcbMxFoKgdLb/vw51euHpR+9+X+buo=; b=AHqHdmNdt63BujmmTXqKVnHyF9OLBeFde5rOZPfj3F1CXLgaIFqjbdVwF21LPjtmDQBPgzHKV9SBXZ/bHHfhzg6DFKzMUNJtHI4gafL94kHJCzvTp2SaYXWUFNB4vAIrLNCApt2QejtTsvc4pWq65F/FX6+MWYVP8ARKTV6R5cU= Received: from CYZPR11CA0014.namprd11.prod.outlook.com (2603:10b6:930:8d::24) by DS0PR12MB8272.namprd12.prod.outlook.com (2603:10b6:8:fc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.26; Tue, 3 Oct 2023 06:22:33 +0000 Received: from CY4PEPF0000E9CF.namprd03.prod.outlook.com (2603:10b6:930:8d:cafe::17) by CYZPR11CA0014.outlook.office365.com (2603:10b6:930:8d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31 via Frontend Transport; Tue, 3 Oct 2023 06:22:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9CF.mail.protection.outlook.com (10.167.241.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 3 Oct 2023 06:22:33 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 3 Oct 2023 01:22:31 -0500 Received: from xsjarunbala50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 3 Oct 2023 01:22:30 -0500 From: Jay Buddhabhatti To: , , CC: , , , Jay Buddhabhatti Subject: [PATCH 1/2] drivers: clk: zynqmp: calculate closest mux rate Date: Mon, 2 Oct 2023 23:21:52 -0700 Message-ID: <20231003062153.12215-2-jay.buddhabhatti@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231003062153.12215-1-jay.buddhabhatti@amd.com> References: <20231003062153.12215-1-jay.buddhabhatti@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CF:EE_|DS0PR12MB8272:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cf720ad-4a4c-47d0-bc5b-08dbc3d92124 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XtfyiLDbamowImTNj8Y2C6AmtPLAdar3dEBSMxF6EdMRTdu5DllSIr/Ij3rIAF97m+QeIZrE8kh89gRHHBO2vG8INGsc1L/nV3bOB4XCDdT6TIrmxp6i6QnLwNUjSJXTCanwYFixCCr0r3lsU6aqy4YflZ5Fr0Dw4Drdcay1zpWyPemCH90pHymTiTmQynx3gcd6rSB+PBNCvBXMgDU6xirm1luqIQUyJIkfYnzOARMvUYH9f8RI4oF5tIgVYUHmsc5qjOukhdsQ7TxTJVmnij//QinQ3E4sStUBV6EjRaCvVsXfKlnj1NlDafukPNqotXIwyHt6ll8AXLmjitB6PQsan0NZ9c+IQRy84+4qxONXYck/J+lQNWObiryjm//8Y5wRoZ72sX2uSczDmhv7p/2Ouxtbf51Ba9/rWV7vhkctJI3bqP/V/leH6v6xM7bM8XsuCbfvYQX3zt4MDdCvVfh6OdDWNQP4VZMrZth3jj/LJuKEnFE/02FDjImzjRBZGc4FMWdws2RhKIoOLRY4dRq2h5LaYufjTL1jqyYsUHdbvJ+lXXcl0BVPy8FGyJGnb5f9q4mjwMXjgH89Sh9yDwgnQ5QUUcUh0X024pwXTyi5nUPkLxHjXOfAGDqd4bjYRG5/MxhttMcNKmWGZWF9H8aoNn2b+SXZS+HpmdnDprT+H4lYvpCyocbVKoGgznX6ZIW+vM5wAHMoPi3hBBz4ZrqFxAFY7ovOASrO4llhcD4RSkSqo19jwt4LLc6dVQBGIA9S7dqqjCiSbVsx2ofdYQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(230922051799003)(64100799003)(82310400011)(1800799009)(186009)(451199024)(46966006)(40470700004)(36840700001)(478600001)(2616005)(336012)(2906002)(83380400001)(26005)(47076005)(1076003)(110136005)(316002)(44832011)(70206006)(6636002)(5660300002)(41300700001)(8936002)(426003)(70586007)(54906003)(4326008)(8676002)(40460700003)(36860700001)(356005)(81166007)(82740400003)(86362001)(36756003)(40480700001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 06:22:33.3494 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cf720ad-4a4c-47d0-bc5b-08dbc3d92124 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8272 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231002_232244_307042_EB05D78E X-CRM114-Status: GOOD ( 14.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently zynqmp clock driver is not calculating closest mux rate and because of that Linux is not setting proper frequency for CPU and not able to set given frequency for dynamic frequency scaling. E.g., In current logic initial acpu clock parent and frequency as below apll1 0 0 0 2199999978 0 0 50000 Y acpu0_mux 0 0 0 2199999978 0 0 50000 Y acpu0_idiv1 0 0 0 2199999978 0 0 50000 Y acpu0 0 0 0 2199999978 0 0 50000 Y After changing acpu frequency to 549999994 Hz using CPU freq scaling its selecting incorrect parent which is not closest frequency. rpll_to_xpd 0 0 0 1599999984 0 0 50000 Y acpu0_mux 0 0 0 1599999984 0 0 50000 Y acpu0_div1 0 0 0 533333328 0 0 50000 Y acpu0 0 0 0 533333328 0 0 50000 Y Parent should remain same since 549999994 = 2199999978 / 4. So use __clk_mux_determine_rate_closest() generic function to calculate closest rate for mux clock. After this change its selecting correct parent and correct clock rate. apll1 0 0 0 2199999978 0 0 50000 Y acpu0_mux 0 0 0 2199999978 0 0 50000 Y acpu0_div1 0 0 0 549999995 0 0 50000 Y acpu0 0 0 0 549999995 0 0 50000 Y Signed-off-by: Jay Buddhabhatti --- drivers/clk/zynqmp/clk-mux-zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/zynqmp/clk-mux-zynqmp.c b/drivers/clk/zynqmp/clk-mux-zynqmp.c index 60359333f26d..9b5d3050b742 100644 --- a/drivers/clk/zynqmp/clk-mux-zynqmp.c +++ b/drivers/clk/zynqmp/clk-mux-zynqmp.c @@ -89,7 +89,7 @@ static int zynqmp_clk_mux_set_parent(struct clk_hw *hw, u8 index) static const struct clk_ops zynqmp_clk_mux_ops = { .get_parent = zynqmp_clk_mux_get_parent, .set_parent = zynqmp_clk_mux_set_parent, - .determine_rate = __clk_mux_determine_rate, + .determine_rate = __clk_mux_determine_rate_closest, }; static const struct clk_ops zynqmp_clk_mux_ro_ops = {