Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1331584rwb; Tue, 27 Sep 2022 11:27:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7OTRna6/v+OA36r2He5dphdKzCjYWmBmpNzzRUlD9nmJdT1yiIE4wyURArVygx8bgNP5hV X-Received: by 2002:a17:902:9f90:b0:178:1a1c:85d with SMTP id g16-20020a1709029f9000b001781a1c085dmr28209825plq.85.1664303278921; Tue, 27 Sep 2022 11:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664303278; cv=none; d=google.com; s=arc-20160816; b=onz+SypfqiAACEK6s6udz+C3gGZAQmk7JUEShkyqRAyCmEVxCoKMFHMu3znWyOt66S rYnAG34SWdXT6BU82oCjSY+ISM41FY7d20Gk1nuGl9d5CwtWiWwnxzb430VwmqsAfQMG XGt0/IotbU7Ljy/rixJL0Sl1CtXgSbKv2WN9vJ9Y+7nhkje9MaS8+ehIpwL1np2Th06t 3/0r88rwywM0YS6VsHfXCL0Ue4WVfyBKvCufsLY5Jwf/mzmluajT1rSRmCkSjYssH006 g4KEZzY0WzjZnCn+j1+OLhRCJYgwNg2e2AdXnpjQniR3+NddqveVRHHprLhMFbQmQ8MO taLw== 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=qdg8zSDipVv9uvOYC44VLlBoqoIAVWuGDjuTN5TydnA=; b=tZ5CchyN1iycM3jqjD909jfextLG6sJ37L2sus2/pyZyRIpPdcFLDRnntE+laG03rO bGGU0pzewdmPK+u9rgf9beZdAgqLvyNSnDnmlfuty5G3vm9gT9aIIwSBst0h82L5mzNR /ZmPGbr5uoO4iUE5rfh7zWSQoPsPvZPSOBDfDUEdhs63ehEGlukJXsFi3tAKNmKeiiMk 6TJKZEf1Jpp5OYnLcUy5HNfYSClb1YLU8dVsRN+QEdPaGihd7re514EiSNb9p8MlCD2G sCGHIpEBkupPVSqZFbmvyVeesH3Q+bN6FVWs0fVUA9emYRmF3L6teNrVf7yteDXEEBPW krHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZI/Pv9MS"; 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 u7-20020a056a00158700b0053e3640fad1si61124pfk.368.2022.09.27.11.27.47; Tue, 27 Sep 2022 11:27:58 -0700 (PDT) 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="ZI/Pv9MS"; 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 S230418AbiI0RF7 (ORCPT + 99 others); Tue, 27 Sep 2022 13:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbiI0RFf (ORCPT ); Tue, 27 Sep 2022 13:05:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FAC5C351; Tue, 27 Sep 2022 10:05:20 -0700 (PDT) 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 3608F6171E; Tue, 27 Sep 2022 17:05:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A005CC433D7; Tue, 27 Sep 2022 17:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664298319; bh=RezG0e8yTfUZ/cPhgrgq/ESV4VhaQWW7GClmeDE1snI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZI/Pv9MSA2zEekt9RdVg4J95Uf6OsqYR7yTF1CPjvRu2YLyXF1gHyrIK+HG147ejQ zzjOo9FYjOCIIUQbllxILWHSViAlY6bd9fO+5d0ImLb6QMZYkoSwrzJQeuJlNTOF4H NT//fRz7tKz4vCZPpxplO/ldzuvgMXgjGSMqYSgEIm3R8SpViwo1MKBIe68Rd620mx NJLTdVvsduhEKYXx2wO/bF6T10G8yPTtxd2fm7RqnjsF74rVktYcnDZLGxjJ7fzVeO 5yBmvU+jUZFt2WPIOUivKZUfg1jioWDElwUTRDT3P7w4EqSNDNig9G38YZtdEK/etQ rmDN8KIP2ypJQ== Date: Tue, 27 Sep 2022 12:05:16 -0500 From: Bjorn Andersson To: AngeloGioacchino Del Regno Cc: Rajendra Nayak , agross@kernel.org, konrad.dybcio@somainline.org, mturquette@baylibre.com, sboyd@kernel.org, mka@chromium.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, johan+linaro@kernel.org, quic_kriskura@quicinc.com, dianders@chromium.org, linux-clk@vger.kernel.org Subject: Re: [PATCH v3 1/3] clk: qcom: gdsc: Fix the handling of PWRSTS_RET support Message-ID: <20220927170516.zrkzn3xl7oedzi4l@builder.lan> References: <20220920111517.10407-1-quic_rjendra@quicinc.com> <20220927030203.tz4j5vuhvrnhti6i@builder.lan> <657820a2-f945-ac6a-8a99-47ee511181d8@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <657820a2-f945-ac6a-8a99-47ee511181d8@collabora.com> X-Spam-Status: No, score=-7.2 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 Tue, Sep 27, 2022 at 01:57:59PM +0200, AngeloGioacchino Del Regno wrote: > Il 27/09/22 05:02, Bjorn Andersson ha scritto: > > On Tue, Sep 20, 2022 at 02:39:21PM +0200, AngeloGioacchino Del Regno wrote: > > > Il 20/09/22 13:15, Rajendra Nayak ha scritto: > > > > GDSCs cannot be transitioned into a Retention state in SW. > > > > When either the RETAIN_MEM bit, or both the RETAIN_MEM and > > > > RETAIN_PERIPH bits are set, and the GDSC is left ON, the HW > > > > takes care of retaining the memory/logic for the domain when > > > > the parent domain transitions to power collapse/power off state. > > > > > > > > On some platforms where the parent domains lowest power state > > > > itself is Retention, just leaving the GDSC in ON (without any > > > > RETAIN_MEM/RETAIN_PERIPH bits being set) will also transition > > > > it to Retention. > > > > > > > > The existing logic handling the PWRSTS_RET seems to set the > > > > RETAIN_MEM/RETAIN_PERIPH bits if the cxcs offsets are specified > > > > but then explicitly turns the GDSC OFF as part of _gdsc_disable(). > > > > Fix that by leaving the GDSC in ON state. > > > > > > > > Signed-off-by: Rajendra Nayak > > > > Cc: AngeloGioacchino Del Regno > > > > --- > > > > v3: > > > > Updated changelog > > > > > > > > There are a few existing users of PWRSTS_RET and I am not > > > > sure if they would be impacted with this change > > > > > > > > 1. mdss_gdsc in mmcc-msm8974.c, I am expecting that the > > > > gdsc is actually transitioning to OFF and might be left > > > > ON as part of this change, atleast till we hit system wide > > > > low power state. > > > > If we really leak more power because of this > > > > change, the right thing to do would be to update .pwrsts for > > > > mdss_gdsc to PWRSTS_OFF_ON instead of PWRSTS_RET_ON > > > > I dont have a msm8974 hardware, so if anyone who has can report > > > > any issues I can take a look further on how to fix it. > > > > > > I think that the safest option is to add a PWRSTS_RET_HW_CTRL flag (or similar), > > > used for the specific cases of SC7180 and SC7280 (and possibly others) where the > > > GDSC is automatically transitioned to a Retention state by HW control, with no > > > required software (kernel driver) intervention. > > > > > > > > > > > 2. gpu_gx_gdsc in gpucc-msm8998.c and > > > > gpu_gx_gdsc in gpucc-sdm660.c > > > > Both of these seem to add support for 3 power state > > > > OFF, RET and ON, however I dont see any logic in gdsc > > > > driver to handle 3 different power states. > > > > So I am expecting that these are infact just transitioning > > > > between ON and OFF and RET state is never really used. > > > > The ideal fix for them would be to just update their resp. > > > > .pwrsts to PWRSTS_OFF_ON only. > > > > > > static int gdsc_init(struct gdsc *sc) > > > { > > > > > > ... > > > > > > if (on || (sc->pwrsts & PWRSTS_RET)) > > > gdsc_force_mem_on(sc); > > > else > > > gdsc_clear_mem_on(sc); > > > > > > ... > > > } > > > > > > On MSM8998 and SDM630/636/660, we're reaching that point with a GDSC that is > > > left OFF from the bootloader, but we want (at least for 630/660) memretain > > > without periph-retain: this is required to make the hypervisor happy. > > > > > > > Forgive me Angelo, but can you please help me understand your concern > > here? > > > > Are yous saying that the valid states for 8998/660 are PWRSTS_OFF_ON, > > but you also want gdsc_force_mem_on() - with NO_RET_PERIPH? > > > > > > It seems to me that as Rajendra's patch is written, the gpu_gx_gdsc > > won't be affected, because pwrsts != PWRSTS_RET. So this is a question > > about the validity of fixing the pwrsts in gpucc-msm8998, rather than > > about this patch in itself? > > > > Hello Bjorn, > > my replies were related to this part of the commit description: > > >>> The ideal fix for them would be to just update their resp. > >>> .pwrsts to PWRSTS_OFF_ON only. > > By updating MSM8998 and SDM660's gpu_gx_gdsc to remove PWRSTS_RET, the gdsc_init() > flow will change, as in the aforementioned branch, `on` will be false, hence, > we will clear RETAIN_MEM during the gpu_gx_gdsc initialization, producing side > effects. > I agree on the fact that PWRSTS_RET was *not* handled correctly before this commit > and this alone will not produce any side effects on MSM8998, nor SDM660. > > So yes, this is a discussion about the validity of fixing the pwrsts in > gpucc-msm8998 and in gpucc-sdm660.c. > Okay, now I understand the context, I will move ahead and merge these patches then. And for 8998/660 you're saying that the GDSC is found to be OFF at boot and in runtime you're going to bounce it between on and off in software, but you need RETAIN_MEM set? If that's the case this GDSC can be in all 3 states. But as you can find in the discussions that lead up to this discussion, we don't have a way to represent this to the clients (today). Regards, Bjorn