Message ID | 20230628105652.1670316-3-abel.vesa@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8834527vqr; Wed, 28 Jun 2023 04:04:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MVBhyOlsvVNzBA6CJPiwBXi293pkxFisGyXHZI1Fg7yov7zXHcKUWpljNd8ZA1koqczHq X-Received: by 2002:a05:6402:3455:b0:51d:d307:735c with SMTP id l21-20020a056402345500b0051dd307735cmr564001edc.20.1687950267896; Wed, 28 Jun 2023 04:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687950267; cv=none; d=google.com; s=arc-20160816; b=xCPuNgJIdxEGXNMcR3PpDl1/eDvpaTf1ovHf8fZ6gKbAXQY9s9Uq9eaqr2yTA6+/lG 9sQk4/Go1MSygXjowWzSCWYEqyZALxUeMsWQlmspcsHRfDSGQB8N6zQWnxTeXvOukWFa g7W008PcyXO8YVo2+WE1DAOvK94kG8E8FChfdOcCmfa2DbV3KsNIfpMgiRaEoYJ+Rdw8 LXXZjp0MYggwhR3NUpZ46ao1WcJAHZhYtsVrLh6Y176dOAtGUoeLO+ZxzUo+NaF52ySU HK2uClaJIoMPb35cSlRmj5XqNxapI0M8oPZT/x9csZx9BCktFcCLxx+c+bNfJCtGyH23 289g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/UOP/HXwOfjROV0iDHrU1g1p6LD4GcCF3K/FghLtNOU=; fh=yUwTDGrsvlHouV3fEPRrlKTGD+MlkkPh+H7LyYpVu8M=; b=lL6dNrcej0syuDBkr9iiyAaAGVYf7hEuYfcnw+zCx4steFrDCUbIhAIRe2u26CBhJ2 fNuUc8b5ayqJElOqrww2qk0milOjZsjW7PstklycuhNL4s2yoALEqOzOERg4cZQgvVlk ruEanach4wrbQRPP4VqAvzsKpx3XY+p/SMUeMLYJAUEcW98N7i4P/OFRhrq/zo4lvNi+ pKqD02f9rs9Px8kfF/E0bdF1GJB3DPPRtBjq/tIOFAw/Q10G6QPW0A5MrWlu1LN2uH16 R5TgqTmrewYnj+EFAfOEGiF0a7O22rvl+wHdg+XhXLX2aPbGSR0t5K7xbaVkZac4OcWA 0CqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dujCAIaX; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020aa7d405000000b0051d8f9aaf88si4447531edq.659.2023.06.28.04.03.48; Wed, 28 Jun 2023 04:04:27 -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=@linaro.org header.s=google header.b=dujCAIaX; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbjF1K5l (ORCPT <rfc822;adanhawthorn@gmail.com> + 99 others); Wed, 28 Jun 2023 06:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbjF1K5Z (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 28 Jun 2023 06:57:25 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 333871BF9 for <linux-kernel@vger.kernel.org>; Wed, 28 Jun 2023 03:57:01 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-98d34f1e54fso582663266b.2 for <linux-kernel@vger.kernel.org>; Wed, 28 Jun 2023 03:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687949819; x=1690541819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/UOP/HXwOfjROV0iDHrU1g1p6LD4GcCF3K/FghLtNOU=; b=dujCAIaXSqqrylpawSmjXQ0uVV5fxHuMEQFzZO//TIz9sxd1krxA8ZDYPCDBDRVh0/ BfluOhNKHaqL76P0tQO39OagrbXFJc2LI7Tg5leqj6NdydDD+PHLgE+d3n6pCSrGdu5c qsrE6I/PhnivlF9PkTMJ1Laa3igaQiDWgWYmKdVl0J3y4kuOVTJ4Mg9PU83v4ml0UsSx LK0jT/vaxWfQQJ50Yj/VnTLXf3Aj0r5qZRmcn1iRAh7QmanZn5fC3LhQaukjGHdSnlKi B/+a2PL7DVxgndOYPox3yCot4+cfYZCKp4OCr+ZnWX93JP3lLrsTMb7JnHyfIWJF5ROo sDKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687949819; x=1690541819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/UOP/HXwOfjROV0iDHrU1g1p6LD4GcCF3K/FghLtNOU=; b=OH6AB5Yurm/g0DXioZL+P2VC5tbmlFDVfoDy8lLg9dkTIEImiYNWl4N9iI5gJrYw40 C/sZyw2HYCpwFHOt+xTh/wTiHKbJfBZtkuB4ipKljUi+OYFoRDgsuqMXEnITEFNJ22gE yHZqz0fVhd3r/UgkNbLxDurjgwK6DByaM1n8ZeSMzgE0O7kcYZJbQL9XCFGlCEMlvQ0o t1mj8kP6lrHH0vclg7IwWCvEudSUrn+D2CfyjBfE/eXwlmWM09MzU1O7nMf0EuRBTEF5 pXcJfdWsI/n1dpPbSYsLYoZ7/exQZOslVR9R7I0nG/+MdQjRS9cCKUGcfuUcxy6GHgzB GLJA== X-Gm-Message-State: AC+VfDyN9yWJvzuKI0DNDRhEwYGkYfubK7YEOdujoPgQVgU/4d1tjwCq 9L241W0w+U2b3+/YIThUVdxH1g== X-Received: by 2002:a17:907:2683:b0:957:1df0:9cbf with SMTP id bn3-20020a170907268300b009571df09cbfmr25730821ejc.19.1687949819656; Wed, 28 Jun 2023 03:56:59 -0700 (PDT) Received: from hackbox.lan ([62.231.110.100]) by smtp.gmail.com with ESMTPSA id e8-20020a1709062c0800b0098921e1b064sm5544678ejh.181.2023.06.28.03.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 03:56:59 -0700 (PDT) From: Abel Vesa <abel.vesa@linaro.org> To: "Rafael J . Wysocki" <rafael@kernel.org>, Kevin Hilman <khilman@kernel.org>, Ulf Hansson <ulf.hansson@linaro.org>, avel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Bjorn Andersson <andersson@kernel.org>, Andy Gross <agross@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Mike Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Taniya Das <tdas@qti.qualcomm.com> Cc: linux-pm@vger.kernel.org, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] clk: qcom: gdsc: Add support for set_hwmode_dev Date: Wed, 28 Jun 2023 13:56:52 +0300 Message-Id: <20230628105652.1670316-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230628105652.1670316-1-abel.vesa@linaro.org> References: <20230628105652.1670316-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769944140085914063?= X-GMAIL-MSGID: =?utf-8?q?1769944140085914063?= |
Series |
PM: domains: Add control for switching back and forth to HW control
|
|
Commit Message
Abel Vesa
June 28, 2023, 10:56 a.m. UTC
Implement the GDSC specific genpd set_hwmode_dev callback in order to
switch the HW control on or off. For any GDSC that supports HW control
set this callback in order to allow its consumers to control it.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
drivers/clk/qcom/gdsc.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
Comments
On 28.06.2023 12:56, Abel Vesa wrote: > Implement the GDSC specific genpd set_hwmode_dev callback in order to > switch the HW control on or off. For any GDSC that supports HW control > set this callback in order to allow its consumers to control it. > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org> > --- This still does nothing to prevent the HW_CTRL state being changed in init, enable and disable functions. Konrad > drivers/clk/qcom/gdsc.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c > index 5358e28122ab..9a04bf2e4379 100644 > --- a/drivers/clk/qcom/gdsc.c > +++ b/drivers/clk/qcom/gdsc.c > @@ -314,6 +314,26 @@ static int gdsc_enable(struct generic_pm_domain *domain) > return 0; > } > > +static int gdsc_set_hwmode_dev(struct generic_pm_domain *domain, > + struct device *dev, bool enable) > +{ > + int ret = gdsc_hwctrl(domain_to_gdsc(domain), enable); > + > + if (ret) > + goto out; > + > + /* > + * Wait for the GDSC to go through a power down and > + * up cycle. In case there is a status polling going on > + * before the power cycle is completed it might read an > + * wrong status value. > + */ > + udelay(1); > + > +out: > + return ret; > +} > + > static int gdsc_disable(struct generic_pm_domain *domain) > { > struct gdsc *sc = domain_to_gdsc(domain); > @@ -451,6 +471,8 @@ static int gdsc_init(struct gdsc *sc) > sc->pd.power_off = gdsc_disable; > if (!sc->pd.power_on) > sc->pd.power_on = gdsc_enable; > + if (sc->flags & HW_CTRL) > + sc->pd.set_hwmode_dev = gdsc_set_hwmode_dev; > > ret = pm_genpd_init(&sc->pd, NULL, !on); > if (ret)
Hi Abel, Thanks for the patch. On 6/28/2023 10:48 PM, Konrad Dybcio wrote: > On 28.06.2023 12:56, Abel Vesa wrote: >> Implement the GDSC specific genpd set_hwmode_dev callback in order to >> switch the HW control on or off. For any GDSC that supports HW control >> set this callback in order to allow its consumers to control it. >> >> Signed-off-by: Abel Vesa <abel.vesa@linaro.org> >> --- > This still does nothing to prevent the HW_CTRL state being changed in > init, enable and disable functions. > > Konrad >> drivers/clk/qcom/gdsc.c | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c >> index 5358e28122ab..9a04bf2e4379 100644 >> --- a/drivers/clk/qcom/gdsc.c >> +++ b/drivers/clk/qcom/gdsc.c >> @@ -314,6 +314,26 @@ static int gdsc_enable(struct generic_pm_domain *domain) >> return 0; >> } >> >> +static int gdsc_set_hwmode_dev(struct generic_pm_domain *domain, >> + struct device *dev, bool enable) >> +{ >> + int ret = gdsc_hwctrl(domain_to_gdsc(domain), enable); >> + >> + if (ret) >> + goto out; >> + >> + /* >> + * Wait for the GDSC to go through a power down and >> + * up cycle. In case there is a status polling going on >> + * before the power cycle is completed it might read an >> + * wrong status value. >> + */ >> + udelay(1); >> + >> +out: >> + return ret; >> +} >> + >> static int gdsc_disable(struct generic_pm_domain *domain) >> { >> struct gdsc *sc = domain_to_gdsc(domain); >> @@ -451,6 +471,8 @@ static int gdsc_init(struct gdsc *sc) >> sc->pd.power_off = gdsc_disable; >> if (!sc->pd.power_on) >> sc->pd.power_on = gdsc_enable; >> + if (sc->flags & HW_CTRL) >> + sc->pd.set_hwmode_dev = gdsc_set_hwmode_dev; >> We do not want to move to SW mode without consumers wanting to move to this mode. We want a new flag for the consumers wanting to move to this mode. The mode in which the GDSC would be enabled would be in SW mode only. + if (sc->flags & HW_CTRL_TRIGGER) { + sc->pd.set_hwmode_dev = gdsc_set_mode; + } + >> ret = pm_genpd_init(&sc->pd, NULL, !on); >> if (ret)
On 6/28/2023 4:26 PM, Abel Vesa wrote: > Implement the GDSC specific genpd set_hwmode_dev callback in order to > switch the HW control on or off. For any GDSC that supports HW control > set this callback in order to allow its consumers to control it. > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org> > --- > drivers/clk/qcom/gdsc.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c > index 5358e28122ab..9a04bf2e4379 100644 > --- a/drivers/clk/qcom/gdsc.c > +++ b/drivers/clk/qcom/gdsc.c > @@ -314,6 +314,26 @@ static int gdsc_enable(struct generic_pm_domain *domain) > return 0; > } > > +static int gdsc_set_hwmode_dev(struct generic_pm_domain *domain, > + struct device *dev, bool enable) > +{ > + int ret = gdsc_hwctrl(domain_to_gdsc(domain), enable); > + > + if (ret) > + goto out; > + > + /* > + * Wait for the GDSC to go through a power down and > + * up cycle. In case there is a status polling going on > + * before the power cycle is completed it might read an > + * wrong status value. > + */ > + udelay(1); > + > +out: > + return ret; > +} > + > static int gdsc_disable(struct generic_pm_domain *domain) > { > struct gdsc *sc = domain_to_gdsc(domain); > @@ -451,6 +471,8 @@ static int gdsc_init(struct gdsc *sc) > sc->pd.power_off = gdsc_disable; > if (!sc->pd.power_on) > sc->pd.power_on = gdsc_enable; > + if (sc->flags & HW_CTRL) > + sc->pd.set_hwmode_dev = gdsc_set_hwmode_dev; > Forgot to add the get_mode. + if (sc->flags & HW_CTRL_TRIGGER) { + sc->pd.set_hwmode_dev = gdsc_set_mode; + sc->pd.get_hwmode_dev = gdsc_get_mode; + } + > ret = pm_genpd_init(&sc->pd, NULL, !on); > if (ret)
On 23-07-10 09:40:14, Taniya Das wrote: > Hi Abel, > > Thanks for the patch. > > On 6/28/2023 10:48 PM, Konrad Dybcio wrote: > > On 28.06.2023 12:56, Abel Vesa wrote: > > > Implement the GDSC specific genpd set_hwmode_dev callback in order to > > > switch the HW control on or off. For any GDSC that supports HW control > > > set this callback in order to allow its consumers to control it. > > > > > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org> > > > --- > > This still does nothing to prevent the HW_CTRL state being changed in > > init, enable and disable functions. > > > > Konrad > > > drivers/clk/qcom/gdsc.c | 22 ++++++++++++++++++++++ > > > 1 file changed, 22 insertions(+) > > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c > > > index 5358e28122ab..9a04bf2e4379 100644 > > > --- a/drivers/clk/qcom/gdsc.c > > > +++ b/drivers/clk/qcom/gdsc.c > > > @@ -314,6 +314,26 @@ static int gdsc_enable(struct generic_pm_domain *domain) > > > return 0; > > > } > > > +static int gdsc_set_hwmode_dev(struct generic_pm_domain *domain, > > > + struct device *dev, bool enable) > > > +{ > > > + int ret = gdsc_hwctrl(domain_to_gdsc(domain), enable); > > > + > > > + if (ret) > > > + goto out; > > > + > > > + /* > > > + * Wait for the GDSC to go through a power down and > > > + * up cycle. In case there is a status polling going on > > > + * before the power cycle is completed it might read an > > > + * wrong status value. > > > + */ > > > + udelay(1); > > > + > > > +out: > > > + return ret; > > > +} > > > + > > > static int gdsc_disable(struct generic_pm_domain *domain) > > > { > > > struct gdsc *sc = domain_to_gdsc(domain); > > > @@ -451,6 +471,8 @@ static int gdsc_init(struct gdsc *sc) > > > sc->pd.power_off = gdsc_disable; > > > if (!sc->pd.power_on) > > > sc->pd.power_on = gdsc_enable; > > > + if (sc->flags & HW_CTRL) > > > + sc->pd.set_hwmode_dev = gdsc_set_hwmode_dev; > We do not want to move to SW mode without consumers wanting to move to this > mode. > > We want a new flag for the consumers wanting to move to this mode. The mode > in which the GDSC would be enabled would be in SW mode only. > + if (sc->flags & HW_CTRL_TRIGGER) { > + sc->pd.set_hwmode_dev = gdsc_set_mode; > + } > + OK, maybe I'm missing something here. Do you suggest we have GDSCs that, even though they support HW ctrl, should not be controllable by the consumer? Why isn't dev_pm_genpd_set_hwmode good enough? If a consumer doesn't want to control it then the consumer can just skip calling the mentioned function. Or maybe you want this all hidden into the genpd provider? > > > > ret = pm_genpd_init(&sc->pd, NULL, !on); > > > if (ret) > > -- > Thanks & Regards, > Taniya Das.
diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 5358e28122ab..9a04bf2e4379 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -314,6 +314,26 @@ static int gdsc_enable(struct generic_pm_domain *domain) return 0; } +static int gdsc_set_hwmode_dev(struct generic_pm_domain *domain, + struct device *dev, bool enable) +{ + int ret = gdsc_hwctrl(domain_to_gdsc(domain), enable); + + if (ret) + goto out; + + /* + * Wait for the GDSC to go through a power down and + * up cycle. In case there is a status polling going on + * before the power cycle is completed it might read an + * wrong status value. + */ + udelay(1); + +out: + return ret; +} + static int gdsc_disable(struct generic_pm_domain *domain) { struct gdsc *sc = domain_to_gdsc(domain); @@ -451,6 +471,8 @@ static int gdsc_init(struct gdsc *sc) sc->pd.power_off = gdsc_disable; if (!sc->pd.power_on) sc->pd.power_on = gdsc_enable; + if (sc->flags & HW_CTRL) + sc->pd.set_hwmode_dev = gdsc_set_hwmode_dev; ret = pm_genpd_init(&sc->pd, NULL, !on); if (ret)