From mboxrd@z Thu Jan 1 00:00:00 1970 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 7EF32C3DA49 for ; Fri, 26 Jul 2024 11:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yHdjOL8iadyIooKY4thrkLjCgb/VvgW5EHvDey2vhOM=; b=nihBRO5SrIDRvyOA2wFfv/6qWZ 2ww64bN0y9ie5jL4BIc/Nwh7qF3YO+818hYHNUikJYMTsxOAtPszwhEfQ5uDug3eiDvV9/cPy8RmB JgXi6/GHQRBMtO63X0dU4ckyROvWII4gc7+TJsuwwLoKLnjfdUhMClnGumoD5zw3QmdhkW4yb9pbN quNbROLPdsFXxmo+o29wnTp/jrCRL1UTnvZZtXZjJq/ByrYWJjcFvziBKCAfYDumwjun9TQwpEtn3 9nJKeRoD8YyOJ/TEttZBsqahxTxXnfqdCjGQCSsHDeYcieuSj99l9Zmrvntv9zDOl9jArJvtgFfOP Te+crlCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXJ72-00000003iHp-1cd7; Fri, 26 Jul 2024 11:27:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXJ6Y-00000003i9p-03cu for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 11:27:23 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED9BC1007; Fri, 26 Jul 2024 04:27:46 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0501D3F73F; Fri, 26 Jul 2024 04:27:19 -0700 (PDT) Date: Fri, 26 Jul 2024 12:27:17 +0100 From: Cristian Marussi To: "Peng Fan (OSS)" Cc: sudeep.holla@arm.com, cristian.marussi@arm.com, mturquette@baylibre.com, sboyd@kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, Peng Fan Subject: Re: [PATCH] clk: scmi: add is_prepared hook Message-ID: References: <20240725090741.1039642-1-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240725090741.1039642-1-peng.fan@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_042722_125820_A924A9A8 X-CRM114-Status: GOOD ( 20.25 ) 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 On Thu, Jul 25, 2024 at 05:07:41PM +0800, Peng Fan (OSS) wrote: > From: Peng Fan > .... one more remark.. > Some clks maybe default enabled by hardware, so add is_prepared hook > to get the status of the clk. Then when disabling unused clks, those > unused clks but default hardware on clks could be in off state to save > power. > > Signed-off-by: Peng Fan > --- > drivers/clk/clk-scmi.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c > index d86a02563f6c..d2d370337ba5 100644 > --- a/drivers/clk/clk-scmi.c > +++ b/drivers/clk/clk-scmi.c > @@ -142,6 +142,20 @@ static void scmi_clk_disable(struct clk_hw *hw) > scmi_proto_clk_ops->disable(clk->ph, clk->id, NOT_ATOMIC); > } > > +static int scmi_clk_is_enabled(struct clk_hw *hw) > +{ > + int ret; > + bool enabled = false; > + struct scmi_clk *clk = to_scmi_clk(hw); > + > + ret = scmi_proto_clk_ops->state_get(clk->ph, clk->id, &enabled, NOT_ATOMIC); > + if (ret) > + dev_warn(clk->dev, > + "Failed to get state for clock ID %d\n", clk->id); > + > + return !!enabled; > +} > + > static int scmi_clk_atomic_enable(struct clk_hw *hw) > { > struct scmi_clk *clk = to_scmi_clk(hw); > @@ -280,6 +294,7 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key) > } else { > ops->prepare = scmi_clk_enable; > ops->unprepare = scmi_clk_disable; > + ops->is_prepared = scmi_clk_is_enabled; ... you should NOT add the is_prepared ops here, since this would mean that you will have the is_prepared ops available only when SCMI_CLK_STATE_CTRL_SUPPORTED, WHILE you most probably want to be able to check (non atomically) the current enabled-status for a clock EVEN IF you are allowed to change its state...please add the is_prepared in the else-branch down below where the ATOMIC is_enabled is added Thanks, Cristian