From patchwork Tue Apr 6 15:31:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12185503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CFE8C433ED for ; Tue, 6 Apr 2021 15:34:58 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8378F61380 for ; Tue, 6 Apr 2021 15:34:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8378F61380 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=eXz1NjXB2bKWFSvRxymIxZ2sAc3JFOAiT+dHAf54lqM=; b=Xz/9xQlxfixXDuywEHzgNiZKn/ JxfctIWGLHeBbU9C5U8XrKshU23Ikv6HqVXfR8M+JeKnMz+D7b9SqmbheKjZqsAdcHZYjzELsMKXT d1esdrAPLrLAnGiJMy6PzCDvdwcxu3OprprAhbmk+X0yM3kFaeUwYr34Cu9xv6ukl+NA0r4v+u5jj GQDUfnBK5Ow9ltEl8iUHu2ZZG3QY6S6tH71WSWydWRPS1Wd2BS6OWPLnMbms0Rym6KjEbec/sZFYs 7TcZH/Q/ghR/PXVJuqVBBQ7PGY3OyhcdXYxPLuP80BZe408m6cGkfhBIgg48HCA7pZ/CDawC4gBiJ S3oX+OWA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTnhT-002vet-Qq; Tue, 06 Apr 2021 15:33:07 +0000 Received: from mail-mw2nam10on2041.outbound.protection.outlook.com ([40.107.94.41] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lTnhP-002veD-Qx for linux-arm-kernel@lists.infradead.org; Tue, 06 Apr 2021 15:33:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gTzOvAsaGH45xlJd1T+efj9GdGLI7+JOQI+lWjouVAWSORX+i7ADUsBe85JHZkxlmze+pNoyHfXAtg5rm9VuC5Kyd1HcM8kH60G1MJ86GN6hDxaKj3aMax66qi7lvA0GFi27ZNwfD0GIfGLJrIzf7ScudSlHdlurDVUDzTpn4rBfyKyxr7eV6qZus/Umx6ltx3wTeFht3ZzZ9g8OSWxnkggqEYDwTuxyccnP2QutYmZuAabYe9ohEY4UaoD0iN7SfR5SwsnVRFRAqk5CBKBFpLFs2xlaMjVItK7f9vUX9Aa1OqBX7ALepBhsevKVyHQG2P6Zb5Ja1ygMrEpcPttDig== 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-SenderADCheck; bh=bdo6NpSrLCTj4s2AdDMj2QpYlPI5SZl1pJeJoKk6kuE=; b=TZ+JmFkyocM27bwARqsJ53yY0MspNiz9EFOdYvOAA1JWvCmz62RTrTY74k5OnkNR0QI9tjfh0Lp/02QK2ToAbb8i+A99MWWfHRqjMhn0BcjiFmDc8qe7NMXkQ4PLA+00q87qAJJfbBLdM/pGrlkWvup5HUSogzQkwR+5IG9monch65sUgznuGUTUDTbMVc92bsRBVCqwKcVcpuZfNGYRhtbESjP2you2+a1WCI516zdv3AI1ZTo39qm5+XyOA4q6yBHi/Sk5yNN4F6UfAkmDhjUCCuIa7QWQOvhVrLtATlP0USBhhBm08vp8+Eqe6eZ6gxEJh2yO1DzC1wYvlBYIuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bdo6NpSrLCTj4s2AdDMj2QpYlPI5SZl1pJeJoKk6kuE=; b=LGs6gpapi84nwZGnXPqy3Iv9IQkPPyDQzF/fpX5/Y/RnFG5uEjDyn7j1RE6Uj44QnxzgY4Bfb5iid6EQFAnU76bgFb/1VaM7Ft1ICaLcuFgQWqrjR4OXhqoTvUGDlaOaXJJ0cKK7BwwzccHWlLtbtBpcPQelrdT9t0qlYIkoHCE= Authentication-Results: baylibre.com; dkim=none (message not signed) header.d=none; baylibre.com; dmarc=none action=none header.from=windriver.com; Received: from CY4PR11MB0071.namprd11.prod.outlook.com (2603:10b6:910:7a::30) by CY4PR11MB2008.namprd11.prod.outlook.com (2603:10b6:903:22::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Tue, 6 Apr 2021 15:32:59 +0000 Received: from CY4PR11MB0071.namprd11.prod.outlook.com ([fe80::f45f:e820:49f5:3725]) by CY4PR11MB0071.namprd11.prod.outlook.com ([fe80::f45f:e820:49f5:3725%6]) with mapi id 15.20.3999.032; Tue, 6 Apr 2021 15:32:59 +0000 From: quanyang.wang@windriver.com To: Michael Turquette , Stephen Boyd , Laurent Pinchart , Michal Simek Cc: Rajan Vaja , Jolly Shah , Greg Kroah-Hartman , Quanyang Wang , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [V3][PATCH] clk: zynqmp: pll: add set_pll_mode to check condition in zynqmp_pll_enable Date: Tue, 6 Apr 2021 23:31:31 +0800 Message-Id: <20210406153131.601701-1-quanyang.wang@windriver.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: BYAPR08CA0002.namprd08.prod.outlook.com (2603:10b6:a03:100::15) To CY4PR11MB0071.namprd11.prod.outlook.com (2603:10b6:910:7a::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-qwang2-d1.wrs.com (60.247.85.82) by BYAPR08CA0002.namprd08.prod.outlook.com (2603:10b6:a03:100::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Tue, 6 Apr 2021 15:32:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b5b441b-fb2a-460e-377f-08d8f91141c5 X-MS-TrafficTypeDiagnostic: CY4PR11MB2008: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:345; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jaVJicnhJ+Pu5ckNx0RAQ9e/csi4/eE4ysWfMatpTGASGQr0B1NyZly2djpnUbGzwCRE//PfMrhYjtbfohEafnqQW8IWXtRnUCM99XdIEkrWRvObrlWOKRrQsoqO6NuwKdtp8JnEib89JTe5Z3wCSGKMVKue1U0xgCe1wjLALBDze5tPZ0H57AHQpkaiP4Dr0LaGzdbXrgMJ5PcutpUFlZt/N2qzSADoOGJt7+lpxcx+PEgTIoQA2wn9jTW9xf2j1a2ftUS5t7q6n/r+R78m9h+oddhZb8nN/45yldqhKl1uuZlM7CcJfgST8qcWAM1gVP2+BicmJIh092dZ0vE4CdRtsQC2QsM+X6mVkdNT1HaGoIbS/pJQUuNUjs7Y6ZsSQiVgncLMz+mXKKcke8y0+68lcQtfTt3/bvvhNq+oA/LW/p3WYs/dVDHK+80SLQxVpmnERc7c9qrZVGFyFou78VVII6VEcDmHYmJe8xEO3+NAKXWyarQpJ42kHV1gslBGYxNNY83+OJ9BCmFjqcHXCVlkLuqMvMgbChlnbfDNDRTuu1JNHPqVQE5tAKKYkbwP34UCTTsLlb+Bd9KSClcwxh2dEODzIoGawnmDsw0IEqfWeoABp9ByiANrC1rDDLOy5p6DOvcvJLdrtronDhKo9sLxluyCidlr9HFU8BHh4TzH4/Y9tfBfsKVeLGl0Amy5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB0071.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(136003)(366004)(39850400004)(346002)(83380400001)(956004)(2616005)(1076003)(5660300002)(54906003)(6486002)(4326008)(110136005)(36756003)(8676002)(38350700001)(2906002)(9686003)(38100700001)(316002)(6506007)(16526019)(8936002)(26005)(86362001)(66946007)(6666004)(6512007)(52116002)(66556008)(7416002)(478600001)(186003)(66476007); DIR:OUT; SFP:1101;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v9fC4kk5EQlNKwfZBBiZ1jp6qHXrI61J76jf9zJSMcu67E5LNc+4aUWiRYeBJruMqXGEOw0nbw2aioLp1ckNICMXOEP9FmduYUoIqqrXHRR4u7ap259FVpm93/NQlVJPPvnpsXlzEConI4ZZ1r+zkweR1Mh5JdO6PBZH00CLQhWozOTgj081eUxvPnM7khx4jWS74uA287Sy0I3KCfUFjPwPjw5y39fy5O17iTyPiRxS9thn4OgYGs21U/pyGzAHB5HkuD71sLfPYQgJiO38ExjWZKSnBYLXltf+y X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b5b441b-fb2a-460e-377f-08d8f91141c5 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB0071.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2021 15:32:59.0786 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Je0qS4ahOw/RQRvPAb8EoY9F0Ej0uNoTB72WTQT3SOgS37F/4BHGe5xS6W4sEaUtPqu8yg6skx5/RPbBrZGKf5sDZpBPnMKZV/Yaa0ZIznQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB2008 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_163303_999697_6C57DFAF X-CRM114-Status: GOOD ( 16.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: Quanyang Wang If there is a IOCTL_SET_PLL_FRAC_MODE request sent to ATF ever, we shouldn't skip invoking PM_CLOCK_ENABLE fn even though this pll has been enabled. In ATF implementation, it will only assign the mode to the variable (struct pm_pll *)pll->mode when handling IOCTL_SET_PLL_FRAC_MODE call. Invoking PM_CLOCK_ENABLE can force ATF send request to PWU to set the pll mode to PLL's register. There is a scenario that happens in enabling VPLL_INT(clk_id:96): 1) VPLL_INT has been enabled during booting. 2) A driver calls clk_set_rate and according to the rate, the VPLL_INT should be set to FRAC mode. Then zynqmp_pll_set_mode is called to pass IOCTL_SET_PLL_FRAC_MODE to ATF. Note that at this point ATF just stores the mode to a variable. 3) This driver calls clk_prepare_enable and zynqmp_pll_enable is called to try to enable VPLL_INT pll. Because of 1), the function zynqmp_pll_enable just returns without doing anything after checking that this pll has been enabled. In the scenario above, the pll mode of VPLL_INT will never be set successfully. So adding set_pll_mode to check condition to fix it. Fixes: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver") Signed-off-by: Quanyang Wang Tested-by: Laurent Pinchart --- V3: - add Fixes tag. V2: - add Tested-by tag, thanks Laurent. - fix typos in commit message and multiline code comments. --- drivers/clk/zynqmp/pll.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/clk/zynqmp/pll.c b/drivers/clk/zynqmp/pll.c index 92f449ed38e5..0d64268a4a84 100644 --- a/drivers/clk/zynqmp/pll.c +++ b/drivers/clk/zynqmp/pll.c @@ -14,10 +14,12 @@ * struct zynqmp_pll - PLL clock * @hw: Handle between common and hardware-specific interfaces * @clk_id: PLL clock ID + * @set_pll_mode: Whether an IOCTL_SET_PLL_FRAC_MODE request be sent to ATF */ struct zynqmp_pll { struct clk_hw hw; u32 clk_id; + bool set_pll_mode; }; #define to_zynqmp_pll(_hw) container_of(_hw, struct zynqmp_pll, hw) @@ -81,6 +83,8 @@ static inline void zynqmp_pll_set_mode(struct clk_hw *hw, bool on) if (ret) pr_warn_once("%s() PLL set frac mode failed for %s, ret = %d\n", __func__, clk_name, ret); + else + clk->set_pll_mode = true; } /** @@ -240,9 +244,15 @@ static int zynqmp_pll_enable(struct clk_hw *hw) u32 clk_id = clk->clk_id; int ret; - if (zynqmp_pll_is_enabled(hw)) + /* + * Don't skip enabling clock if there is an IOCTL_SET_PLL_FRAC_MODE request + * that has been sent to ATF. + */ + if (zynqmp_pll_is_enabled(hw) && (!clk->set_pll_mode)) return 0; + clk->set_pll_mode = false; + ret = zynqmp_pm_clock_enable(clk_id); if (ret) pr_warn_once("%s() clock enable failed for %s, ret = %d\n",