Message ID | 20231004-clk-qcom-smd-rpm-unused-v2-1-9a5281f324dc@kernkonzept.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp82770vqb; Wed, 4 Oct 2023 05:11:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHs4GNVoziW56X0q3Lk7rsU8hXL/Pm+f/sCdlL/zMj+yQ2rpP6m1hZAQarqRtKhOZhPNfZX X-Received: by 2002:a05:6358:5e0f:b0:134:e549:50d6 with SMTP id q15-20020a0563585e0f00b00134e54950d6mr2198767rwn.10.1696421472333; Wed, 04 Oct 2023 05:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696421472; cv=none; d=google.com; s=arc-20160816; b=afX4KOlhgb/lJjeR8yTVuDJQJ4QqwLSBYpOX5/IJ/6QC3moTA8okszdD7UwbR21JQk BO5MLoQiIAiIC2fSeybIvfUwWpeUVZB5+mzSCkeuzdGD4gPlh46k5xJUradMi+9X9xys F+vq6gsgr/LkNG/DDUenWxaJDMhU0zIk+fh+dsJkFwi5Io4ykUXrMQXz6U50T0RDzQ/U Es+oGe2fqk/zMjD067IQSZ+ZR3fibtzyg1pPJuukwSfu0t3UAjuDJQGDrBRKZ0kQSua9 Jk8Z9XS9+IZ01HQCNTflsaCii8x/3/S2Hqo8M/5AAxlZHlr6Mpie51W8KsduStsmTCqd Fwgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=SmL8ximB3jmibA5ut1EhfI+VT8YUU8o3eptjGal/v/8=; fh=XaeVQk9XWeQSLtJweQVS54X6MGINV32aejq8ptE88as=; b=uYYVpUExPigqNkTDZnKuGinQcRdv2pguyOGMg7D+AfEXUOGlIrluVpmOiIXPapZ7dV ss31efH02dAuglPdkc0c5T+EPaBg6uevP5VI+31KSwq4MC2Uz+whn4q398ukWK8ubwWu CGzL3ciLxTAHE80xJb94bi3jGJKzR3guK1CdkhsBm3CzCgWM3RKBpvJnyh78i0VVmN5k BWb+jIO+DRKGKAFc3EqXRL+ybM8i7qTmjd6WByf9zuSZMYtJ3dEuPRvQH7jkb3K4MIY2 lGEjz0ZCK4rHzR/RtbDvlCKKmI3GF0IZVSLLNpPYmmPZzuidBRKQcCUo9XcHMYO4VczN uqCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=dTCUotHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m22-20020a637116000000b00578d78f2a70si3781112pgc.388.2023.10.04.05.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:11:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=dTCUotHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3E7268085982; Wed, 4 Oct 2023 05:11:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbjJDMKt (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Wed, 4 Oct 2023 08:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242313AbjJDMKq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Oct 2023 08:10:46 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2329C9; Wed, 4 Oct 2023 05:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:References:In-Reply-To:Reply-To: Content-ID:Content-Description; bh=SmL8ximB3jmibA5ut1EhfI+VT8YUU8o3eptjGal/v/8=; b=dTCUotHndBZzy055HBmkMgW8Jm 7PPB9RGNMRO1nXirwbGtECWdOLx0WIetYONPfmMbo90+gSbBQbkAU4U6OInftVy0P+86DMd0UNNly 9/wcR5OJXGw2JxBqr22k6IxmiWW7ACc8jiGb0eVPH8hFl3FLWMhVluGG10gb9sU02j3F/uV28vaF2 btk3tBNOTKtBBwW6CLfkzY/9D0laZA6oiHTTwi6W11K3CgC2O4OzHQeIEd+iY/ZT60QPgk49RXlbT 8frjXUjoEn+a//YGSnkRJUT2jQFAN5aXk9CX4iVzfNVQl+JGjPfM99acVm1zd78AcncjIRuwBH/DJ 2B9FUzcg==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1qo0i5-0070GG-12; Wed, 04 Oct 2023 14:10:37 +0200 From: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Date: Wed, 04 Oct 2023 14:10:34 +0200 Subject: [PATCH v2] clk: qcom: smd: Disable unused clocks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231004-clk-qcom-smd-rpm-unused-v2-1-9a5281f324dc@kernkonzept.com> X-B4-Tracking: v=1; b=H4sIADlWHWUC/zWNQQ6CMBAAv0L27JLdilI8+Q/jAekCjVBwC8aE8 HcbE49zmJkNoqiXCJdsA5W3j34KCcwhg6avQyfoXWIwZI5MVGAzPPHVTCPG0aHOI65hjeLwUVa OiI2xzJDsWaX1n1/5dk/canKWXqX+94gsl1xQRTZne6rKMzLGReb0vXai/TS4PMgC+/4FA3ZKe KcAAAA= To: Bjorn Andersson <andersson@kernel.org> Cc: Andy Gross <agross@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold <stephan@gerhold.net>, Stephan Gerhold <stephan.gerhold@kernkonzept.com> X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:11:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778826841752798082 X-GMAIL-MSGID: 1778826841752798082 |
Series |
[v2] clk: qcom: smd: Disable unused clocks
|
|
Commit Message
Stephan Gerhold
Oct. 4, 2023, 12:10 p.m. UTC
At the moment, clk-smd-rpm forces all clocks on at probe time (for
"handoff"). However, it does not make the clk core aware of that.
This means that the clocks stay enabled forever if they are not used
by anything. We can easily disable them again after bootup has been
completed, by making the clk core aware of the state. This is
implemented by returning the current state of the clock in
is_prepared().
Checking the SPMI clock registers reveals that this allows the RPM to
disable unused BB/RF clocks. This reduces the power consumption quite
significantly and is also needed to allow entering low-power states.
As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out
interconnect bus clocks") the interconnect-related clocks are no longer
managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now
critical (and never disabled).
There is still a slight chance that this change will break boot on some
devices. However, this will be most likely caused by actual mistakes in
the device tree (where required clocks were not actually specified).
Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
---
Changes in v2:
- Rebase on latest qcom/for-next, update commit message with other recent
related changes
- Link to v1: https://lore.kernel.org/linux-arm-msm/20200817140908.185976-1-stephan@gerhold.net/
---
Keeping all unused clocks on makes it very easy to forget to enable
actually required clocks. [1] is one example of that, where the crypto
engine worked fine without any clocks. IMHO we should try to get this
change in sooner than later to avoid introducing more new mistakes.
[1]: https://lore.kernel.org/linux-arm-msm/ZGdLCdSof027mk5u@gerhold.net/
---
drivers/clk/qcom/clk-smd-rpm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
base-commit: 870b5222204243ee6dbeada9ad1b90cda9ecb4da
change-id: 20231004-clk-qcom-smd-rpm-unused-b79d00122811
Best regards,
Comments
On 4.10.2023 14:10, Stephan Gerhold wrote: > At the moment, clk-smd-rpm forces all clocks on at probe time (for > "handoff"). However, it does not make the clk core aware of that. > > This means that the clocks stay enabled forever if they are not used > by anything. We can easily disable them again after bootup has been > completed, by making the clk core aware of the state. This is > implemented by returning the current state of the clock in > is_prepared(). > > Checking the SPMI clock registers reveals that this allows the RPM to > disable unused BB/RF clocks. This reduces the power consumption quite > significantly and is also needed to allow entering low-power states. > > As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out > interconnect bus clocks") the interconnect-related clocks are no longer > managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now > critical (and never disabled). > > There is still a slight chance that this change will break boot on some > devices. However, this will be most likely caused by actual mistakes in > the device tree (where required clocks were not actually specified). Precisely this, and solely as a consequence of the interconnect driver not covering all the required clocks (usually named GCC_SOME_NOC_XYZ_CLK, but there's quite a lot more). For platforms without an interconnect driver, breaking stuff this **MOST LIKELY** means that Linux uses some hw that isn't voted for (e.g. missing crypto clock under scm or something). For those with an interconnect driver, this will uncover issues that were previously hidden because of the smd-rpm interconnect being essentially broken for most of its existence. I can smell 660 breaking from however many miles you are away from me, but it's "good", as we were relying on (board specific) magic.. I've been carrying an equivalent patch in my tree for over half a year now and IIRC 8996 was mostly fine. It's also a good idea to test suspend (echo mem > /sys/power/state) and wakeup. For reasons that I don't fully recall, I do have both .is_prepared and .is_enabled though.. Konrad
On Fri, Oct 06, 2023 at 11:08:39PM +0200, Konrad Dybcio wrote: > On 4.10.2023 14:10, Stephan Gerhold wrote: > > At the moment, clk-smd-rpm forces all clocks on at probe time (for > > "handoff"). However, it does not make the clk core aware of that. > > > > This means that the clocks stay enabled forever if they are not used > > by anything. We can easily disable them again after bootup has been > > completed, by making the clk core aware of the state. This is > > implemented by returning the current state of the clock in > > is_prepared(). > > > > Checking the SPMI clock registers reveals that this allows the RPM to > > disable unused BB/RF clocks. This reduces the power consumption quite > > significantly and is also needed to allow entering low-power states. > > > > As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out > > interconnect bus clocks") the interconnect-related clocks are no longer > > managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now > > critical (and never disabled). > > > > There is still a slight chance that this change will break boot on some > > devices. However, this will be most likely caused by actual mistakes in > > the device tree (where required clocks were not actually specified). > Precisely this, and solely as a consequence of the interconnect driver > not covering all the required clocks (usually named GCC_SOME_NOC_XYZ_CLK, > but there's quite a lot more). > > For platforms without an interconnect driver, breaking stuff this **MOST > LIKELY** means that Linux uses some hw that isn't voted for (e.g. missing > crypto clock under scm or something). > > For those with an interconnect driver, this will uncover issues that were > previously hidden because of the smd-rpm interconnect being essentially > broken for most of its existence. I can smell 660 breaking from however > many miles you are away from me, but it's "good", as we were relying on > (board specific) magic.. > > I've been carrying an equivalent patch in my tree for over half a year now > and IIRC 8996 was mostly fine. It's also a good idea to test suspend > (echo mem > /sys/power/state) and wakeup. > I didn't notice any problems on 8916 and 8909 either. :-) > For reasons that I don't fully recall, I do have both .is_prepared and > .is_enabled though.. > clk-smd-rpm doesn't have any .enable()/.disable() ops (only .prepare() and .unprepare()) so I don't think is_enabled is needed. For the unused clock cleanup in drivers/clk/clk.c (clk_disable_unused()) we just care about the clk_unprepare_unused_subtree() part. That part is run when the clock reports true in .is_prepared(). The equivalent for .is_enabled() would just be a no-op because there are no .enable()/.disable() ops. Thanks, Stephan
On 10/9/23 22:15, Stephan Gerhold wrote: > On Fri, Oct 06, 2023 at 11:08:39PM +0200, Konrad Dybcio wrote: >> On 4.10.2023 14:10, Stephan Gerhold wrote: >>> At the moment, clk-smd-rpm forces all clocks on at probe time (for >>> "handoff"). However, it does not make the clk core aware of that. >>> >>> This means that the clocks stay enabled forever if they are not used >>> by anything. We can easily disable them again after bootup has been >>> completed, by making the clk core aware of the state. This is >>> implemented by returning the current state of the clock in >>> is_prepared(). >>> >>> Checking the SPMI clock registers reveals that this allows the RPM to >>> disable unused BB/RF clocks. This reduces the power consumption quite >>> significantly and is also needed to allow entering low-power states. >>> >>> As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out >>> interconnect bus clocks") the interconnect-related clocks are no longer >>> managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now >>> critical (and never disabled). >>> >>> There is still a slight chance that this change will break boot on some >>> devices. However, this will be most likely caused by actual mistakes in >>> the device tree (where required clocks were not actually specified). >> Precisely this, and solely as a consequence of the interconnect driver >> not covering all the required clocks (usually named GCC_SOME_NOC_XYZ_CLK, >> but there's quite a lot more). >> >> For platforms without an interconnect driver, breaking stuff this **MOST >> LIKELY** means that Linux uses some hw that isn't voted for (e.g. missing >> crypto clock under scm or something). >> >> For those with an interconnect driver, this will uncover issues that were >> previously hidden because of the smd-rpm interconnect being essentially >> broken for most of its existence. I can smell 660 breaking from however >> many miles you are away from me, but it's "good", as we were relying on >> (board specific) magic.. >> >> I've been carrying an equivalent patch in my tree for over half a year now >> and IIRC 8996 was mostly fine. It's also a good idea to test suspend >> (echo mem > /sys/power/state) and wakeup. >> > > I didn't notice any problems on 8916 and 8909 either. :-) > >> For reasons that I don't fully recall, I do have both .is_prepared and >> .is_enabled though.. >> > > clk-smd-rpm doesn't have any .enable()/.disable() ops (only .prepare() > and .unprepare()) so I don't think is_enabled is needed. For the unused > clock cleanup in drivers/clk/clk.c (clk_disable_unused()) we just care > about the clk_unprepare_unused_subtree() part. That part is run when the > clock reports true in .is_prepared(). The equivalent for .is_enabled() > would just be a no-op because there are no .enable()/.disable() ops. Oh I found out why :D """ The RPM clock enabling state can be found with 'enabled' in struct clk_smd_rpm. Add .is_enabled hook so that clk_summary in debugfs can a correct enabling state for RPM clocks. """ Konrad
On Tue, Oct 10, 2023 at 10:45:15PM +0200, Konrad Dybcio wrote: > On 10/9/23 22:15, Stephan Gerhold wrote: > > On Fri, Oct 06, 2023 at 11:08:39PM +0200, Konrad Dybcio wrote: > > > On 4.10.2023 14:10, Stephan Gerhold wrote: > > > > At the moment, clk-smd-rpm forces all clocks on at probe time (for > > > > "handoff"). However, it does not make the clk core aware of that. > > > > > > > > This means that the clocks stay enabled forever if they are not used > > > > by anything. We can easily disable them again after bootup has been > > > > completed, by making the clk core aware of the state. This is > > > > implemented by returning the current state of the clock in > > > > is_prepared(). > > > > > > > > Checking the SPMI clock registers reveals that this allows the RPM to > > > > disable unused BB/RF clocks. This reduces the power consumption quite > > > > significantly and is also needed to allow entering low-power states. > > > > > > > > As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out > > > > interconnect bus clocks") the interconnect-related clocks are no longer > > > > managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now > > > > critical (and never disabled). > > > > > > > > There is still a slight chance that this change will break boot on some > > > > devices. However, this will be most likely caused by actual mistakes in > > > > the device tree (where required clocks were not actually specified). > > > Precisely this, and solely as a consequence of the interconnect driver > > > not covering all the required clocks (usually named GCC_SOME_NOC_XYZ_CLK, > > > but there's quite a lot more). > > > > > > For platforms without an interconnect driver, breaking stuff this **MOST > > > LIKELY** means that Linux uses some hw that isn't voted for (e.g. missing > > > crypto clock under scm or something). > > > > > > For those with an interconnect driver, this will uncover issues that were > > > previously hidden because of the smd-rpm interconnect being essentially > > > broken for most of its existence. I can smell 660 breaking from however > > > many miles you are away from me, but it's "good", as we were relying on > > > (board specific) magic.. > > > > > > I've been carrying an equivalent patch in my tree for over half a year now > > > and IIRC 8996 was mostly fine. It's also a good idea to test suspend > > > (echo mem > /sys/power/state) and wakeup. > > > > > > > I didn't notice any problems on 8916 and 8909 either. :-) > > > > > For reasons that I don't fully recall, I do have both .is_prepared and > > > .is_enabled though.. > > > > > > > clk-smd-rpm doesn't have any .enable()/.disable() ops (only .prepare() > > and .unprepare()) so I don't think is_enabled is needed. For the unused > > clock cleanup in drivers/clk/clk.c (clk_disable_unused()) we just care > > about the clk_unprepare_unused_subtree() part. That part is run when the > > clock reports true in .is_prepared(). The equivalent for .is_enabled() > > would just be a no-op because there are no .enable()/.disable() ops. > Oh I found out why :D > > """ > The RPM clock enabling state can be found with 'enabled' in struct > clk_smd_rpm. Add .is_enabled hook so that clk_summary in debugfs > can a correct enabling state for RPM clocks. > """ > I see, thanks! I think you should see at least the "prepared" state with this patch. I'm not entirely convinced we should implement .is_enabled() if we don't actually do anything on .enable()/.disable(). Anyway, given that the debugfs state is not directly related to the main objective of disabling unused clocks I think that would be better discussed in a separate patch later. :) Thanks, Stephan
On 10/10/23 23:21, Stephan Gerhold wrote: > On Tue, Oct 10, 2023 at 10:45:15PM +0200, Konrad Dybcio wrote: >> On 10/9/23 22:15, Stephan Gerhold wrote: >>> On Fri, Oct 06, 2023 at 11:08:39PM +0200, Konrad Dybcio wrote: >>>> On 4.10.2023 14:10, Stephan Gerhold wrote: >>>>> At the moment, clk-smd-rpm forces all clocks on at probe time (for >>>>> "handoff"). However, it does not make the clk core aware of that. >>>>> >>>>> This means that the clocks stay enabled forever if they are not used >>>>> by anything. We can easily disable them again after bootup has been >>>>> completed, by making the clk core aware of the state. This is >>>>> implemented by returning the current state of the clock in >>>>> is_prepared(). >>>>> >>>>> Checking the SPMI clock registers reveals that this allows the RPM to >>>>> disable unused BB/RF clocks. This reduces the power consumption quite >>>>> significantly and is also needed to allow entering low-power states. >>>>> >>>>> As of commit d6edc31f3a68 ("clk: qcom: smd-rpm: Separate out >>>>> interconnect bus clocks") the interconnect-related clocks are no longer >>>>> managed/exposed by clk-smd-rpm. Also the BI_TCXO_AO clock is now >>>>> critical (and never disabled). >>>>> >>>>> There is still a slight chance that this change will break boot on some >>>>> devices. However, this will be most likely caused by actual mistakes in >>>>> the device tree (where required clocks were not actually specified). >>>> Precisely this, and solely as a consequence of the interconnect driver >>>> not covering all the required clocks (usually named GCC_SOME_NOC_XYZ_CLK, >>>> but there's quite a lot more). >>>> >>>> For platforms without an interconnect driver, breaking stuff this **MOST >>>> LIKELY** means that Linux uses some hw that isn't voted for (e.g. missing >>>> crypto clock under scm or something). >>>> >>>> For those with an interconnect driver, this will uncover issues that were >>>> previously hidden because of the smd-rpm interconnect being essentially >>>> broken for most of its existence. I can smell 660 breaking from however >>>> many miles you are away from me, but it's "good", as we were relying on >>>> (board specific) magic.. >>>> >>>> I've been carrying an equivalent patch in my tree for over half a year now >>>> and IIRC 8996 was mostly fine. It's also a good idea to test suspend >>>> (echo mem > /sys/power/state) and wakeup. >>>> >>> >>> I didn't notice any problems on 8916 and 8909 either. :-) >>> >>>> For reasons that I don't fully recall, I do have both .is_prepared and >>>> .is_enabled though.. >>>> >>> >>> clk-smd-rpm doesn't have any .enable()/.disable() ops (only .prepare() >>> and .unprepare()) so I don't think is_enabled is needed. For the unused >>> clock cleanup in drivers/clk/clk.c (clk_disable_unused()) we just care >>> about the clk_unprepare_unused_subtree() part. That part is run when the >>> clock reports true in .is_prepared(). The equivalent for .is_enabled() >>> would just be a no-op because there are no .enable()/.disable() ops. >> Oh I found out why :D >> >> """ >> The RPM clock enabling state can be found with 'enabled' in struct >> clk_smd_rpm. Add .is_enabled hook so that clk_summary in debugfs >> can a correct enabling state for RPM clocks. >> """ >> > > I see, thanks! I think you should see at least the "prepared" state with > this patch. I'm not entirely convinced we should implement .is_enabled() > if we don't actually do anything on .enable()/.disable(). > > Anyway, given that the debugfs state is not directly related to the main > objective of disabling unused clocks I think that would be better > discussed in a separate patch later. :) Agreed Konrad
diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c index 0191fc0dd7da..eba650ad7291 100644 --- a/drivers/clk/qcom/clk-smd-rpm.c +++ b/drivers/clk/qcom/clk-smd-rpm.c @@ -335,6 +335,13 @@ static void clk_smd_rpm_unprepare(struct clk_hw *hw) mutex_unlock(&rpm_smd_clk_lock); } +static int clk_smd_rpm_is_prepared(struct clk_hw *hw) +{ + struct clk_smd_rpm *r = to_clk_smd_rpm(hw); + + return r->enabled; +} + static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { @@ -431,6 +438,7 @@ static int clk_smd_rpm_enable_scaling(void) static const struct clk_ops clk_smd_rpm_ops = { .prepare = clk_smd_rpm_prepare, .unprepare = clk_smd_rpm_unprepare, + .is_prepared = clk_smd_rpm_is_prepared, .set_rate = clk_smd_rpm_set_rate, .round_rate = clk_smd_rpm_round_rate, .recalc_rate = clk_smd_rpm_recalc_rate, @@ -439,6 +447,7 @@ static const struct clk_ops clk_smd_rpm_ops = { static const struct clk_ops clk_smd_rpm_branch_ops = { .prepare = clk_smd_rpm_prepare, .unprepare = clk_smd_rpm_unprepare, + .is_prepared = clk_smd_rpm_is_prepared, .recalc_rate = clk_smd_rpm_recalc_rate, }; @@ -1279,6 +1288,9 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) ret = clk_smd_rpm_handoff(rpm_smd_clks[i]); if (ret) goto err; + + /* During handoff we force all clocks on */ + rpm_smd_clks[i]->enabled = true; } for (i = 0; i < desc->num_icc_clks; i++) {