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 B90A6C3DA49 for ; Fri, 26 Jul 2024 08:53:55 +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=O/uow5tUi6p+KYTJeircOQo9Nkglx2i1OnNlTDinozI=; b=gTU/Eg3CW/y3MGkcdroIkXra1X 0GctYw+9i2eSatfiGhmZRfEleXm8GtQSQ7DPjGpz1pxPDmHantNztjOxbp26PKvfvzy5EhDGTAEcW Ax6zVM1/BrHDoYfXDQnSAWpQ/GIPcnf4uHS1KzSRW3s1NjOxFvM2Z52yoFYIKQ9sA6tXThcZIUxRA n8JcxGYLpJODaY5mB0eKJ6cHjzW9Eh/vfMeJlsk8Bm01zv1IXKYMGiTqD2zy+oBQ29kplad+bTcIA T5l8cODyU830XdNQUN1AYCIRGRdhV+YgtzlUyAMqQqGCUYwCZq5BSYfqF4NkvHMAL50wCjPMWJtHA bvsjqOxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGhr-00000003ODR-0wV0; Fri, 26 Jul 2024 08:53:43 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGhS-00000003O8w-0zSA for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 08:53:19 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 46Q8r7ww066495; Fri, 26 Jul 2024 03:53:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1721983987; bh=O/uow5tUi6p+KYTJeircOQo9Nkglx2i1OnNlTDinozI=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=IPD6iSfzrI9BNSqD0Uf104eNnIEqraCUISCobNZdX1Rs88r5dhVV6cHTVsA5osxH1 Gwb3cCDkqYZGzz+K2iKfbTlA/Z8tYy8ZdS0xsbDztSIJ7jFU2U3S/lGUBnfsmJYHpj 4Mk++UfA2m4AMC8mLZQ6+vAlE81dR4LRqgYoLgHo= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 46Q8r7tN031537 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Jul 2024 03:53:07 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE112.ent.ti.com (157.170.170.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 03:53:07 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE104.ent.ti.com (157.170.170.34) 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 03:53:07 -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 46Q8r6mr066490; Fri, 26 Jul 2024 03:53:06 -0500 Date: Fri, 26 Jul 2024 14:23:05 +0530 From: Dhruva Gole To: "Peng Fan (OSS)" CC: , , , , , , , , Peng Fan , , Subject: Re: [PATCH] clk: scmi: add is_prepared hook Message-ID: <20240726085305.sb57f3i2ezvtwrwz@dhruva> 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-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_015318_402147_94B1B280 X-CRM114-Status: GOOD ( 19.83 ) 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 25, 2024 at 17:07:41 +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > Some clks maybe default enabled by hardware, so add is_prepared hook Why is_prepared when there is an is_enabled hook? See in the atomic case we already have something similar: ops->is_enabled = scmi_clk_atomic_is_enabled; > 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; IMO from the decription and what the function is doing is_enabled makes more sense here to me, unless there's a better explanation. Ref: linux/clk-provider.h is_prepared: Queries the hardware to determine if the clock is prepared vs is_enabled: Queries the hardware to determine if the clock is enabled -- Best regards, Dhruva Gole