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 03528C3DA49 for ; Fri, 26 Jul 2024 13:44:56 +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=X0pibor5pyzf+QqC+/UM1qD3iaGriTi2Gh105sjdVh4=; b=KoB+8EOUjA/KcMLqqPQKiSRrRG oS7XJdDdHXy1jh0Gk31IAj+kgaoloNpJ97ksOQUIF7TcLM2OobN2JwGG81Wke2Ae/vaf328GogsWR 3zhGegq2FsGNF9r7oQ421P4EI4wfnkGZUpptOt4HRzaTJlhJpCw9wUNrUC4wvz4pbNPTC9g8VhdY5 m1OVFlKDy4OAxRWvLxVCqN9rcaRP7EhURLowqp3avMGgxyL1nSdWrpHoG/zt37wkOTe6fZfdAQYfW bFrmBrjhP4EU24Y1PwaQE4upj6dCxHlZy+EazLNV0gJWODjdc7Nrp83fnF8sCi/NJ98pOBLYsRr++ tCC6TmeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXLFY-000000042sA-0Xtm; Fri, 26 Jul 2024 13:44:48 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXLF9-000000042oY-1BPu for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 13:44:24 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 46QDiFiw090992; Fri, 26 Jul 2024 08:44:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1722001455; bh=X0pibor5pyzf+QqC+/UM1qD3iaGriTi2Gh105sjdVh4=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=OhCl0UwWpzz1kVYK/32vVtQ1Se9DK0Hq1B8dNyGyrObnqc/OMnHQ1dKYxzIzscWru U79EuqvTQV3+uwk0ByDzfRP8RaG00xt5fI43GVKdsn9eYOP3QP/XxDtxtcOdWziKxW mDr5V+ad34EtwewbC6uz4/d7M92xcANs2SHVWmvg= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 46QDiFlD095564 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Jul 2024 08:44:15 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 26 Jul 2024 08:44:15 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 26 Jul 2024 08:44:15 -0500 Received: from localhost (dhruva.dhcp.ti.com [172.24.227.68]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 46QDiEe4101072; Fri, 26 Jul 2024 08:44:15 -0500 Date: Fri, 26 Jul 2024 19:14:14 +0530 From: Dhruva Gole To: "Peng Fan (OSS)" CC: , , , , , , , , Peng Fan Subject: Re: [PATCH V2] clk: scmi: add is_prepared hook Message-ID: <20240726134414.2ctbtt53sd3lyfjl@dhruva> References: <20240726131007.1651996-1-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240726131007.1651996-1-peng.fan@oss.nxp.com> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_064423_476714_651EF218 X-CRM114-Status: GOOD ( 20.70 ) 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 Jul 26, 2024 at 21:10:07 +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > Some clks maybe default enabled by hardware, so add is_prepared hook > for non-atomic clk_ops 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 > --- > > V2: > Provider helper __scmi_clk_is_enabled for atomic and non-atomic usage > Move is_prepared hook out of SCMI_CLK_STATE_CTRL_SUPPORTED > > drivers/clk/clk-scmi.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c > index d86a02563f6c..15510c2ff21c 100644 > --- a/drivers/clk/clk-scmi.c > +++ b/drivers/clk/clk-scmi.c > @@ -156,13 +156,13 @@ static void scmi_clk_atomic_disable(struct clk_hw *hw) > scmi_proto_clk_ops->disable(clk->ph, clk->id, ATOMIC); > } > > -static int scmi_clk_atomic_is_enabled(struct clk_hw *hw) > +static int __scmi_clk_is_enabled(struct clk_hw *hw, bool atomic) I think we can combine other atomic/non atomic in the same way no? Let me know if I should send a follow up patch based on this to make __scmi_clk_enable(hw,atomic) and __scmi_clk_disable(hw,atomic) I'd be more than happy to do so. > { > 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, ATOMIC); > + ret = scmi_proto_clk_ops->state_get(clk->ph, clk->id, &enabled, atomic); > if (ret) > dev_warn(clk->dev, > "Failed to get state for clock ID %d\n", clk->id); > @@ -170,6 +170,16 @@ static int scmi_clk_atomic_is_enabled(struct clk_hw *hw) > return !!enabled; > } > > +static int scmi_clk_atomic_is_enabled(struct clk_hw *hw) > +{ > + return __scmi_clk_is_enabled(hw, ATOMIC); > +} > + > +static int scmi_clk_is_enabled(struct clk_hw *hw) > +{ > + return __scmi_clk_is_enabled(hw, NOT_ATOMIC); > +} > + > static int scmi_clk_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) > { > int ret; > @@ -285,6 +295,8 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key) > > if (feats_key & BIT(SCMI_CLK_ATOMIC_SUPPORTED)) > ops->is_enabled = scmi_clk_atomic_is_enabled; > + else > + ops->is_prepared = scmi_clk_is_enabled; Reviewed-by: Dhruva Gole -- Best regards, Dhruva