From nobody Wed Apr 8 08:01:58 2026 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 0F226C32789 for ; Mon, 22 Aug 2022 08:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbiHVIOy (ORCPT ); Mon, 22 Aug 2022 04:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbiHVIOr (ORCPT ); Mon, 22 Aug 2022 04:14:47 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A603FD37 for ; Mon, 22 Aug 2022 01:14:45 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id d71so8721455pgc.13 for ; Mon, 22 Aug 2022 01:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=IE9z0fBhPksiP/pwlYETW9TxjlMXMx385aynhNYxesU=; b=a4xELweNAdtImdOryMuf97q6wznTft+2pd2NXGi9/Uu45MwqTCJeS8d9uIVlcK0R1t Wbc8Dwgtwhbpzq5tvdebGhyB+UdIUfeu0d9Qj9dA3p/WRL3HJHY/6KjrSoUqT46kAKRF AW4N7OsQirmPq4MiHJqK22PhIFuZtzTleTqVE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=IE9z0fBhPksiP/pwlYETW9TxjlMXMx385aynhNYxesU=; b=FsdfhAne7tjcInVElvCDen89jMgfPXKHVGiC5VHCn3f4gDEVLJPGWJGiNls4lEplSI 9WafqYwQKRWeOxgAX21DEoydJGG+MrhZ886M/ZdSXe/YafOdnJejXrFttxEYClvChJ/d XFpSF1LMMxuwUNpkMntc0eOBlFObJeFyJhcYofw0ZcQsCu4U9JEe/NG32d2iCXwE5U8j lgy8URMRstngdwkC9p87Q/FNdJnE0lvBkFiuKURbUHLdKq2jxCvfeWvPU9a4zncP/HWX AjUB2cJjieBBfWHJ3CKstWuqdnxmAgzrCN5H24xgk0zynVcCnNdYpWxNAudbyQ9GWLrc fAcA== X-Gm-Message-State: ACgBeo2eO5jH5mMTgHnzst6fShUniwjxB0APGzEPa+9v1NIfXHVZ/fAQ nV3b5XneupvYd+BsIbnFeHTa498A7b1EcQ== X-Google-Smtp-Source: AA6agR6Jupl9v7GziBhTOH0kDalXXlDMdRXBBnW8kLYLAJqa3IodQup2do2g2gD+AwNYygTwOsFPjg== X-Received: by 2002:a63:f94f:0:b0:429:7aef:e252 with SMTP id q15-20020a63f94f000000b004297aefe252mr16679215pgk.270.1661156084627; Mon, 22 Aug 2022 01:14:44 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:d583:9d7d:3429:1b4b]) by smtp.gmail.com with ESMTPSA id f184-20020a6238c1000000b00536b3fe1300sm1204858pfa.13.2022.08.22.01.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 01:14:44 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd Cc: Chen-Yu Tsai , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v2 1/2] clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops Date: Mon, 22 Aug 2022 16:14:23 +0800 Message-Id: <20220822081424.1310926-2-wenst@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220822081424.1310926-1-wenst@chromium.org> References: <20220822081424.1310926-1-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the previous commits that added CLK_OPS_PARENT_ENABLE, support for this flag was only added to rate change operations (rate setting and reparent) and disabling unused subtree. It was not added to the clock gate related operations. Any hardware driver that needs it for these operations will either see bogus results, or worse, hang. This has been seen on MT8192 and MT8195, where the imp_ii2_* clk drivers set this, but dumping debugfs clk_summary would cause it to hang. Fixes: fc8726a2c021 ("clk: core: support clocks which requires parents enab= le (part 2)") Fixes: a4b3518d146f ("clk: core: support clocks which requires parents enab= le (part 1)") Signed-off-by: Chen-Yu Tsai Reviewed-by: N=C3=ADcolas F. R. A. Prado Tested-by: N=C3=ADcolas F. R. A. Prado --- drivers/clk/clk.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7fc191c15507..9b365cd6d14b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -196,6 +196,9 @@ static bool clk_core_rate_is_protected(struct clk_core = *core) return core->protect_count; } =20 +static int clk_core_prepare_enable(struct clk_core *core); +static void clk_core_disable_unprepare(struct clk_core *core); + static bool clk_core_is_prepared(struct clk_core *core) { bool ret =3D false; @@ -208,7 +211,11 @@ static bool clk_core_is_prepared(struct clk_core *core) return core->prepare_count; =20 if (!clk_pm_runtime_get(core)) { + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_prepare_enable(core->parent); ret =3D core->ops->is_prepared(core->hw); + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_disable_unprepare(core->parent); clk_pm_runtime_put(core); } =20 @@ -244,7 +251,13 @@ static bool clk_core_is_enabled(struct clk_core *core) } } =20 + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_prepare_enable(core->parent); + ret =3D core->ops->is_enabled(core->hw); + + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_disable_unprepare(core->parent); done: if (core->rpm_enabled) pm_runtime_put(core->dev); @@ -812,6 +825,9 @@ int clk_rate_exclusive_get(struct clk *clk) } EXPORT_SYMBOL_GPL(clk_rate_exclusive_get); =20 +static int clk_core_enable_lock(struct clk_core *core); +static void clk_core_disable_lock(struct clk_core *core); + static void clk_core_unprepare(struct clk_core *core) { lockdep_assert_held(&prepare_lock); @@ -835,6 +851,9 @@ static void clk_core_unprepare(struct clk_core *core) =20 WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name); =20 + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_enable_lock(core->parent); + trace_clk_unprepare(core); =20 if (core->ops->unprepare) @@ -843,6 +862,9 @@ static void clk_core_unprepare(struct clk_core *core) clk_pm_runtime_put(core); =20 trace_clk_unprepare_complete(core); + + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_disable_lock(core->parent); clk_core_unprepare(core->parent); } =20 @@ -891,6 +913,9 @@ static int clk_core_prepare(struct clk_core *core) if (ret) goto runtime_put; =20 + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_enable_lock(core->parent); + trace_clk_prepare(core); =20 if (core->ops->prepare) @@ -898,6 +923,9 @@ static int clk_core_prepare(struct clk_core *core) =20 trace_clk_prepare_complete(core); =20 + if (core->flags & CLK_OPS_PARENT_ENABLE) + clk_core_disable_lock(core->parent); + if (ret) goto unprepare; } --=20 2.37.1.595.g718a3a8f04-goog From nobody Wed Apr 8 08:01:58 2026 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 C9586C28D13 for ; Mon, 22 Aug 2022 08:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233793AbiHVIPG (ORCPT ); Mon, 22 Aug 2022 04:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233755AbiHVIOt (ORCPT ); Mon, 22 Aug 2022 04:14:49 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45ED81B7B2 for ; Mon, 22 Aug 2022 01:14:47 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id u12so1670223pgb.6 for ; Mon, 22 Aug 2022 01:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DRMOGZpV+QIISp4JRXmMjfwQlEf6dwNCOFyN0rcigzk=; b=SqWGfE6mo5mD0EZqSJ3GMcIwpU2eCmW5vM8lKGmwtj5eU0LzYYVKEUJJg5Nn2RvB6J zbhTyIZqVUR/AqgYJvNP1BWSrwNYzaCxTgJhI4LwgMo3bTLjYX0FKFUqivpNkvzo8a5u OLAt2cO3XchHdpwIHe1qBtoeW2LtksfKBHUZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=DRMOGZpV+QIISp4JRXmMjfwQlEf6dwNCOFyN0rcigzk=; b=ap9xEQtOwSUWVOHyTCi4Xvb6gEVH3FKL/NEdas7RoTovVXt4A7Ep2B2BjehT7r5GiN /+ktiMi4cfUPddJIL8Rs19/E7SyrHTMIgrz5Q3pq98H88P0QkCEIh1rD4wMqarQ0DRB7 n19Byd5jNN8wntn+AITo9imz/5iWL1dY/rmLvm3Jo4vGOeLi4YIxxF8FuJPAqhwJkwF+ 9GP9a9kM44kBsqYqACK6+wbWXoBAfNXQ3KflxTNtWTiTVKI1V36NE9j5DMD/FHt8YEEj p3RF+ufuQPKU6qsI5gUnI9r32bi20y58e20ALvW8xaTAPHYoXtGrktZjGWTI4/MvSFk9 rL3A== X-Gm-Message-State: ACgBeo2EPYQdbA5Uc7IzVs63+WtWUp35+M+jw3bGxy4OGk8NLc1l6YxS IhH32hTDNYgGp0ItoqImEKHKLsBQeDdNGQ== X-Google-Smtp-Source: AA6agR7FUSE/XVfJ8Cj1cg1uhQsLHSg8Z9o+NFkZND6FLlZQjawGZ1icjFjdujCiYH2AxKCkBGSW1A== X-Received: by 2002:a63:89c7:0:b0:429:fab3:96d7 with SMTP id v190-20020a6389c7000000b00429fab396d7mr16734118pgd.597.1661156086719; Mon, 22 Aug 2022 01:14:46 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:d583:9d7d:3429:1b4b]) by smtp.gmail.com with ESMTPSA id f184-20020a6238c1000000b00536b3fe1300sm1204858pfa.13.2022.08.22.01.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 01:14:46 -0700 (PDT) From: Chen-Yu Tsai To: Michael Turquette , Stephen Boyd Cc: Chen-Yu Tsai , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v2 2/2] clk: core: Fix runtime PM sequence in clk_core_unprepare() Date: Mon, 22 Aug 2022 16:14:24 +0800 Message-Id: <20220822081424.1310926-3-wenst@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog In-Reply-To: <20220822081424.1310926-1-wenst@chromium.org> References: <20220822081424.1310926-1-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the original commit 9a34b45397e5 ("clk: Add support for runtime PM"), the commit message mentioned that pm_runtime_put_sync() would be done at the end of clk_core_unprepare(). This mirrors the operations in clk_core_prepare() in the opposite order. However, the actual code that was added wasn't in the order the commit message described. Move clk_pm_runtime_put() to the end of clk_core_unprepare() so that it is in the correct order. Fixes: 9a34b45397e5 ("clk: Add support for runtime PM") Signed-off-by: Chen-Yu Tsai Reviewed-by: N=C3=ADcolas F. R. A. Prado --- drivers/clk/clk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 9b365cd6d14b..2e29a72c68e1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -859,13 +859,12 @@ static void clk_core_unprepare(struct clk_core *core) if (core->ops->unprepare) core->ops->unprepare(core->hw); =20 - clk_pm_runtime_put(core); - trace_clk_unprepare_complete(core); =20 if (core->flags & CLK_OPS_PARENT_ENABLE) clk_core_disable_lock(core->parent); clk_core_unprepare(core->parent); + clk_pm_runtime_put(core); } =20 static void clk_core_unprepare_lock(struct clk_core *core) --=20 2.37.1.595.g718a3a8f04-goog