From: Praveen Talari <praveen.talari@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>,
Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>,
Konrad Dybcio <konradybcio@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
psodagud@quicinc.com, djaggi@quicinc.com,
quic_msavaliy@quicinc.com, quic_vtanuku@quicinc.com,
quic_arandive@quicinc.com, quic_shazhuss@quicinc.com
Subject: Re: [PATCH v1 04/12] soc: qcom: geni-se: Add geni_se_resource_state() helper
Date: Fri, 28 Nov 2025 10:12:19 +0530 [thread overview]
Message-ID: <18c151c7-5c64-48ca-b6a5-3363544f292d@oss.qualcomm.com> (raw)
In-Reply-To: <bskhxahakxpc74rdoz54eqlplb4obaoleouh4pn6qdy6yjmggw@fojwzct2haxa>
H Bjorn
On 11/26/2025 8:49 PM, Bjorn Andersson wrote:
> On Sat, Nov 22, 2025 at 10:30:10AM +0530, Praveen Talari wrote:
>> The GENI SE protocol drivers (I2C, SPI, UART) implement similar resource
>> activation/deactivation sequences independently, leading to code
>> duplication.
>>
>> Introduce geni_se_resource_state() to control power state of GENI SE
>> resources. This function provides a unified interface that calls either
>> geni_se_resources_activate() to power on resources or
>> geni_se_resources_deactivate() to power off resources based on the
>> power_on parameter.
>>
>> The activate function enables ICC, clocks, and TLMM with proper error
>> handling and cleanup paths. The deactivate function disables resources
>> in reverse order including OPP rate reset, clocks, ICC and TLMM.
>>
>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>> ---
>> drivers/soc/qcom/qcom-geni-se.c | 61 ++++++++++++++++++++++++++++++++
>> include/linux/soc/qcom/geni-se.h | 2 ++
>> 2 files changed, 63 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
>> index 726b77650007..7aee7fd2e240 100644
>> --- a/drivers/soc/qcom/qcom-geni-se.c
>> +++ b/drivers/soc/qcom/qcom-geni-se.c
>> @@ -1013,6 +1013,67 @@ int geni_icc_disable(struct geni_se *se)
>> }
>> EXPORT_SYMBOL_GPL(geni_icc_disable);
>>
>> +static int geni_se_resources_deactivate(struct geni_se *se)
>> +{
>> + int ret;
>> +
>> + if (se->has_opp)
>> + dev_pm_opp_set_rate(se->dev, 0);
>> +
>> + ret = geni_se_resources_off(se);
>
> Why do we end this series with two different APIs for turning (on/) off
Currently, we have resources_off() which only manages clocks and
pinctrl. I’m leveraging that in the new API.
If you agree, I can migrate the logic from resources_off() into the new
API and remove resources_off() once support for all protocols is
implemented.
Code snippet:
static int geni_se_resources_deactivate(struct geni_se *se)
{
int ret;
if (has_acpi_companion(se->dev))
return 0;
if (se->has_opp)
dev_pm_opp_set_rate(se->dev, 0);
ret = pinctrl_pm_select_sleep_state(se->dev);
if (ret)
return ret;
geni_se_clks_off(se);
if (se->core_clk)
clk_disable_unprepare(se->core_clk);
return geni_icc_disable(se);
}
static int geni_se_resources_activate(struct geni_se *se)
{
int ret;
if (has_acpi_companion(se->dev))
return 0;
ret = geni_icc_enable(se);
if (ret)
return ret;
if (se->core_clk) {
ret = clk_prepare_enable(se->core_clk);
if (ret)
goto out_icc_disable;
}
ret = geni_se_clks_on(se);
if (ret)
goto out_clk_disable;
ret = pinctrl_pm_select_default_state(se->dev);
if (ret) {
geni_se_clks_off(se);
goto out_clk_disable;
}
return ret;
out_clk_disable:
if (se->core_clk)
clk_disable_unprepare(se->core_clk);
out_icc_disable:
geni_icc_disable(se);
return ret;
}
> the GENI resources? Can't there be a single geni_se_resources_"off"()?
>
>> + if (ret)
>> + return ret;
>> +
>> + if (se->core_clk)
>> + clk_disable_unprepare(se->core_clk);
>> +
>> + return geni_icc_disable(se);
>> +}
>> +
>> +static int geni_se_resources_activate(struct geni_se *se)
>> +{
>> + int ret;
>> +
>> + ret = geni_icc_enable(se);
>> + if (ret)
>> + return ret;
>> +
>> + if (se->core_clk) {
>> + ret = clk_prepare_enable(se->core_clk);
>> + if (ret)
>> + goto out_icc_disable;
>> + }
>> +
>> + ret = geni_se_resources_on(se);
>> + if (ret)
>> + goto out_clk_disable;
>> +
>> + return 0;
>> +
>> +out_clk_disable:
>> + if (se->core_clk)
>> + clk_disable_unprepare(se->core_clk);
>> +out_icc_disable:
>> + geni_icc_disable(se);
>> + return ret;
>> +}
>> +
>> +/**
>> + * geni_se_resources_state() - Control power state of GENI SE resources
>> + * @se: Pointer to the geni_se structure
>> + * @power_on: Boolean flag for desired power state (true = on, false = off)
>> + *
>> + * Controls GENI SE resource power state by calling activate or deactivate
>> + * functions based on the power_on parameter.
>> + *
>> + * Return: 0 on success, negative error code on failure
>> + */
>> +int geni_se_resources_state(struct geni_se *se, bool power_on)
>
> It seems the purpose of this "helper function" is to allow replacing
> geni_se_resource_on() with geni_se_resources_state(true) and
> geni_se_resource_off() with geni_se_resources_state(false) in patch 10.
>
>
> Naming a function "on", "activate", or "enable" provides a clear
> indication of what will happen when you call the function. Calling a
> function to "set state to true" is not as clear.
>
> Further, the code paths that needs to have resources turned on should be
> separate from those who signal that those resources can be turned off.
> So there should not be any gain from this function, unless the same
> obfuscation happens further up the stack.
>
> Just call the activate/deactivate in the respective code path.
Thank you for the inputs.
Sure, will review and update next patch.
Thanks,
Praveen Talari
>
> Regards,
> Bjorn
>
>> +{
>> + return power_on ? geni_se_resources_activate(se) : geni_se_resources_deactivate(se);
>> +}
>> +EXPORT_SYMBOL_GPL(geni_se_resources_state);
>> +
>> /**
>> * geni_se_resources_init() - Initialize resources for a GENI SE device.
>> * @se: Pointer to the geni_se structure representing the GENI SE device.
>> diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
>> index c182dd0f0bde..d1ca13a4e54c 100644
>> --- a/include/linux/soc/qcom/geni-se.h
>> +++ b/include/linux/soc/qcom/geni-se.h
>> @@ -541,6 +541,8 @@ int geni_icc_disable(struct geni_se *se);
>>
>> int geni_se_resources_init(struct geni_se *se);
>>
>> +int geni_se_resources_state(struct geni_se *se, bool power_on);
>> +
>> int geni_load_se_firmware(struct geni_se *se, enum geni_se_protocol_type protocol);
>> #endif
>> #endif
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2025-11-28 4:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 5:00 [PATCH v1 00/12] Enable I2C on SA8255p Qualcomm platforms Praveen Talari
2025-11-22 5:00 ` [PATCH v1 01/12] soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC path optional Praveen Talari
2025-11-26 15:07 ` Bjorn Andersson
2025-11-27 13:49 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 02/12] soc: qcom: geni-se: Add geni_icc_set_bw_ab() function Praveen Talari
2025-11-22 5:00 ` [PATCH v1 03/12] soc: qcom: geni-se: Introduce helper API for resource initialization Praveen Talari
2025-11-23 10:23 ` kernel test robot
2025-11-22 5:00 ` [PATCH v1 04/12] soc: qcom: geni-se: Add geni_se_resource_state() helper Praveen Talari
2025-11-26 15:19 ` Bjorn Andersson
2025-11-28 4:42 ` Praveen Talari [this message]
2025-11-22 5:00 ` [PATCH v1 05/12] soc: qcom: geni-se: Introduce helper API for attaching power domains Praveen Talari
2025-11-22 5:00 ` [PATCH v1 06/12] soc: qcom: geni-se: Introduce helper APIs for performance control Praveen Talari
2025-11-22 5:00 ` [PATCH v1 07/12] dt-bindings: i2c: Describe SA8255p Praveen Talari
2025-11-22 11:40 ` Krzysztof Kozlowski
2025-11-25 4:03 ` Praveen Talari
2025-11-25 7:25 ` Krzysztof Kozlowski
2025-11-26 5:02 ` Praveen Talari
2025-12-02 3:42 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 08/12] i2c: qcom-geni: Isolate serial engine setup Praveen Talari
2025-11-26 15:30 ` Bjorn Andersson
2025-11-28 6:22 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 09/12] i2c: qcom-geni: Move resource initialization to separate function Praveen Talari
2025-11-22 5:00 ` [PATCH v1 10/12] i2c: qcom-geni: Use geni_se_resources_state() API in runtime PM functions Praveen Talari
2025-11-26 15:38 ` Bjorn Andersson
2025-12-01 16:33 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 11/12] i2c: qcom-geni: Store of_device_id data in driver private struct Praveen Talari
2025-11-22 5:00 ` [PATCH v1 12/12] i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms Praveen Talari
2025-11-23 11:46 ` kernel test robot
2025-11-26 15:52 ` Bjorn Andersson
2025-12-01 17:24 ` Praveen Talari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18c151c7-5c64-48ca-b6a5-3363544f292d@oss.qualcomm.com \
--to=praveen.talari@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=andi.shyti@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djaggi@quicinc.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mukesh.savaliya@oss.qualcomm.com \
--cc=psodagud@quicinc.com \
--cc=quic_arandive@quicinc.com \
--cc=quic_msavaliy@quicinc.com \
--cc=quic_shazhuss@quicinc.com \
--cc=quic_vtanuku@quicinc.com \
--cc=robh@kernel.org \
--cc=viken.dadhaniya@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox