Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp944866rwb; Thu, 12 Jan 2023 14:39:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXuen5krjFlxJMHEthgK15ZJGBA67PybvTaZsHXljyIvI3dJT80LtU8cf28zUS/UbSZoYuCF X-Received: by 2002:a17:907:8b09:b0:7c0:e5c8:d439 with SMTP id sz9-20020a1709078b0900b007c0e5c8d439mr72834588ejc.3.1673563187027; Thu, 12 Jan 2023 14:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673563187; cv=none; d=google.com; s=arc-20160816; b=huDYT3SmJAEvKKPdtRJ0xCPlIFKjfzoZ9Ny40rkGW0t8rHGHIwJJ8fLBYw/1OPQCI4 13XOOor5gb9slF7ketKU6xnwX1/6nLaefSDRFbf9p1rVbkctViFBlP0K4xCldfjFqEnu OiGLlt0EEa3C3kdG1jkYOZ12hSstyn4GpijrYNxv9Dc26QtQOAeqdznPRMIEy9FlRDIs e5QTu/YlXA/nbyjeXVPPeob1xJ+bXnmEknoBYPUc8iYd4yF3RykyMhCF1BkR1WYUrOso vplPKDEslG6HfPlTqfYfBM7KiU/4Xa1FZ3Zap9sEEvlOFeZ1pIqZKH97IvAIKUOORyXu IOSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bXkUVYooFpMDNoe7wGLVhco+xDVrtzP9aCDm4xJr6so=; b=CnMpdY8f3cw938OAQoiTXiw/YKU2++mHbnDDc0gnHwC7FJaP8CD6/fZM5AD0s2/Mse PyiCpJwmB/e2aTPbqA3XhIVz0QCFWFrP2LYTaf84zVHnpxQ8ZCOO71gwVEFAeTOHQ+fP bKs7ieqbJLGnu5rzbe1gD0X0g83+GzZVV1r1apgEe7uXcpdGLC2Qvc3YGAfNkz4PB31S MvsOX2+KEamsMgfqXZnpZmx+komWm/O5bouQYlgL80SJ8gMDXtcftvkZfD6grISgxhaz 0bvvUC3CdHpdHtrxvyNKmPcfwZty7KscO4/aaF2J1nVFpnBSFxS0eTEmnk8VUXsK+OJF XlrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oiutwahi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh39-20020a1709076ea700b007c10f6a46c5si19913636ejc.219.2023.01.12.14.39.31; Thu, 12 Jan 2023 14:39:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oiutwahi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235748AbjALWBl (ORCPT + 50 others); Thu, 12 Jan 2023 17:01:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbjALWAx (ORCPT ); Thu, 12 Jan 2023 17:00:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFCF1036; Thu, 12 Jan 2023 13:50:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B75E06219A; Thu, 12 Jan 2023 21:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D45DC433D2; Thu, 12 Jan 2023 21:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673560241; bh=z1MVMcH0nUjiEFIsfjTFo2Vx+dvmKdXcPvV0HKaKxAE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OiutwahifQL/899zlEGanAIEpICX83Nbr6CVNdhFwHgvP2t5Ph6DPrx/slQnUXEnN 7BKqOVlUPWraGw13BUSPlxlFTmKAlEd050kJ2/vvRJNuxZ2iiLwB8sHWrVBMK04A3w wQLGEL0JaSEU+fV+vaYE05Kvexz/TCXW2lQZ4Q4ADbgontV28eTOLgkvGQmQQld+Fh Lg2pOyJKsyOM9Mr3YDc3MynUE7uFJIUB6/9r7Yxs3lQH1bKea+a94mAwAsWP8tHqzw 6nCUWXkx/w0p754W76FM0bKzRdqoDUb+NGMY4sYNf1VRzAYuEteO7MkAt83PyqPj/8 azqqN/STjsBXA== Date: Thu, 12 Jan 2023 15:50:38 -0600 From: Bjorn Andersson To: Stephen Boyd Cc: Abel Vesa , Andy Gross , Bjorn Andersson , Konrad Dybcio , Michael Turquette , Taniya Das , Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: Re: [PATCH] clk: qcom: gdsc: Disable HW control until supported Message-ID: <20230112215038.7rl6fzbprj7xsny4@builder.lan> References: <20230112135224.3837820-1-quic_bjorande@quicinc.com> <40b90d7309246484afa09b2d2b2e23e7.sboyd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40b90d7309246484afa09b2d2b2e23e7.sboyd@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 12, 2023 at 11:10:40AM -0800, Stephen Boyd wrote: > Quoting Bjorn Andersson (2023-01-12 05:52:24) > > Software normally uses the SW_COLLAPSE bit to collapse a GDSC, but in > > some scenarios it's beneficial to let the hardware perform this without > > software intervention. > > > > This is done by configuring the GDSC in "hardware control" state, in > > which case the SW_COLLAPSE bit is ignored and some hardware signal is > > relies upon instead. > > > > The GDSCs are modelled as power-domains in Linux and as such it's > > reasonable to assume that the device drivers intend for the hardware > > block to be accessible when their power domain is active. > > > > But in the current implementation, any GDSC that is marked to support > > hardware control, gets hardware control unconditionally while the > > client driver requests it to be active. It's therefor conceivable that > > the hardware collapses a GDSC while Linux is accessing resources > > depending on it. > > Why would software want the GDSC to be enabled and accessing resources > while the hardware signals that it isn't required? Wouldn't you want a logical OR between these two? As currently written, no attention is given to the software's need for keeping the GDSC active. > It sounds like hardware control isn't complete? > Correct, we're lacking the means for a client driver to affect the hardware vs software control. > > > > There are ongoing discussions about how to properly expose this control > > Any link? When we implemented hardware clk gating years ago the design > was to have software override hardware control when the clk was enabled > in software and let the hardware control go into effect when the clk was > disabled in software. That sounds very reasonable, but it is not what's implemented in this file. In gdsc_enable() we disable SW_COLLAPSE and then immediately give the control to the hardware, and in gdsc_disable() we disable hardware control and then set SW_COLLAPSE. So effectively the GDSC state is either off when Linux says so, or in hardware control. > Hopefully with power domains this could be > implemented in a better way by connecting hardware mode to some > performance state so that enabling the power domain goes to software > mode and then transitioning to a performance state switches to hardware > control mode. > Right, this would allow the software to keep the GDSC on, give the control to the hardware or collapse it. The question is how the "some performance state" should be implemented. > > to the client drivers, but until conclusion in that discussion is > > reached, the safer option would be to keep the GDSC in software control > > mode. > > > > Signed-off-by: Bjorn Andersson > > --- > > drivers/clk/qcom/gdsc.c | 48 ++++++----------------------------------- > > 1 file changed, 7 insertions(+), 41 deletions(-) > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c > > index 9e4d6ce891aa..6d3b36a52a48 100644 > > --- a/drivers/clk/qcom/gdsc.c > > +++ b/drivers/clk/qcom/gdsc.c > > @@ -439,6 +398,13 @@ static int gdsc_init(struct gdsc *sc) > > on = true; > > } > > > > + /* Disable HW trigger mode until propertly supported */ > > + if (sc->flags & HW_CTRL) { > > + ret = gdsc_hwctrl(sc, false); > > + if (ret < 0) > > + return ret; > > + } > > + > > Is it a problem for all hardware controlled gdscs? Or just some of them? > Should we backport this to stable kernels? Sorry, I probably wasn't clear enough. There is no observed problem, this simply knocks out the hardware control mode. The reason for sending this ahead of a design conclusion is that the current behavior doesn't make sense to me (Linux says "enable!" and we just ignore that) and consider how the "some performance state" would relate to this, I don't see that it will be an amendment to the current flow. > I seem to recall that hardware mode was required for some drivers like > camera and video? Given that the current implementation only adhere to the hardware signal in-between gdsc_enable() and gdsc_disable(), the drivers for these blocks must have been written such that the software-state covers the needs of the hardware. As mentioned above, the opposite is however not clear. The GDSC might be collapsed at any time, even if Linux thinks it has the GDSC non-collapsed. I not clear to me why the current logic hasn't caused strange issues for us over the years... > Are they going to keep working if we simply knock out the hardware > control mode here? If anything, we might keep the light on longer than today by missing opportunities where the hardware control currently collapses the GDSC behind Linux's back - and we haven't noticed. Regards, Bjorn