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 08/12] i2c: qcom-geni: Isolate serial engine setup
Date: Fri, 28 Nov 2025 11:52:05 +0530 [thread overview]
Message-ID: <15a28ddc-9883-42d5-a008-b2ea22d8becc@oss.qualcomm.com> (raw)
In-Reply-To: <ar5t2wdmxzvog7smlwbg3skg6ga35au6uiahfe3rlnmumlmpyr@572sf6ru6424>
Hi Bjorn,
Thank you for review.
On 11/26/2025 9:00 PM, Bjorn Andersson wrote:
> On Sat, Nov 22, 2025 at 10:30:14AM +0530, Praveen Talari wrote:
>> Move serial engine configuration from probe to geni_i2c_init().
>>
>> Relocating the serial engine setup to a dedicated initialization function
>> enhances code clarity and simplifies future modifications.
>
> Please enhance commit message clarity. I don't think "code clarity" is
> your most significant reason for this change, and "simplifies future
> modification" is completely vague.
>
> Be specific, the reader of this commit message hasn't implemented the
> next set of commits, so they don't understand why this helps.
>
> If the reason is that this simplifies the error handling around the
> resource acquisition in the next patches, write that.
>
> If my guess is wrong and the sole reason for you change is that you
> don't like 179 lines long functions, then just say that.
>
Moving the serial engine setup to geni_i2c_init() API for a cleaner
probe function and utilizes the PM runtime API to control resources
instead of direct clock-related APIs for better resource management.
Enables reusability of the serial engine initialization in future use
cases like hibernation and deep sleep features where hardware context is
lost.
I hope the commit text above should be appropriate.
Thanks,
Praveen
> Regards,
> Bjorn
>
>>
>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>> ---
>> drivers/i2c/busses/i2c-qcom-geni.c | 148 ++++++++++++++---------------
>> 1 file changed, 73 insertions(+), 75 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
>> index 3a04016db2c3..4111afe2713e 100644
>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>> @@ -976,10 +976,75 @@ static int setup_gpi_dma(struct geni_i2c_dev *gi2c)
>> return ret;
>> }
>>
>> +static int geni_i2c_init(struct geni_i2c_dev *gi2c)
>> +{
>> + const struct geni_i2c_desc *desc = NULL;
>> + u32 proto, tx_depth;
>> + bool fifo_disable;
>> + int ret;
>> +
>> + ret = pm_runtime_resume_and_get(gi2c->se.dev);
>> + if (ret < 0) {
>> + dev_err(gi2c->se.dev, "error turning on device :%d\n", ret);
>> + return ret;
>> + }
>> +
>> + proto = geni_se_read_proto(&gi2c->se);
>> + if (proto == GENI_SE_INVALID_PROTO) {
>> + ret = geni_load_se_firmware(&gi2c->se, GENI_SE_I2C);
>> + if (ret) {
>> + dev_err_probe(gi2c->se.dev, ret, "i2c firmware load failed ret: %d\n", ret);
>> + goto err;
>> + }
>> + } else if (proto != GENI_SE_I2C) {
>> + ret = dev_err_probe(gi2c->se.dev, -ENXIO, "Invalid proto %d\n", proto);
>> + goto err;
>> + }
>> +
>> + desc = device_get_match_data(gi2c->se.dev);
>> + if (desc && desc->no_dma_support)
>> + fifo_disable = false;
>> + else
>> + fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE;
>> +
>> + if (fifo_disable) {
>> + /* FIFO is disabled, so we can only use GPI DMA */
>> + gi2c->gpi_mode = true;
>> + ret = setup_gpi_dma(gi2c);
>> + if (ret)
>> + goto err;
>> +
>> + dev_dbg(gi2c->se.dev, "Using GPI DMA mode for I2C\n");
>> + } else {
>> + gi2c->gpi_mode = false;
>> + tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se);
>> +
>> + /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */
>> + if (!tx_depth && desc)
>> + tx_depth = desc->tx_fifo_depth;
>> +
>> + if (!tx_depth) {
>> + ret = dev_err_probe(gi2c->se.dev, -EINVAL,
>> + "Invalid TX FIFO depth\n");
>> + goto err;
>> + }
>> +
>> + gi2c->tx_wm = tx_depth - 1;
>> + geni_se_init(&gi2c->se, gi2c->tx_wm, tx_depth);
>> + geni_se_config_packing(&gi2c->se, BITS_PER_BYTE,
>> + PACKING_BYTES_PW, true, true, true);
>> +
>> + dev_dbg(gi2c->se.dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth);
>> + }
>> +
>> +err:
>> + pm_runtime_put(gi2c->se.dev);
>> + return ret;
>> +}
>> +
>> static int geni_i2c_probe(struct platform_device *pdev)
>> {
>> struct geni_i2c_dev *gi2c;
>> - u32 proto, tx_depth, fifo_disable;
>> int ret;
>> struct device *dev = &pdev->dev;
>> const struct geni_i2c_desc *desc = NULL;
>> @@ -1059,79 +1124,19 @@ static int geni_i2c_probe(struct platform_device *pdev)
>> if (ret)
>> return ret;
>>
>> - ret = clk_prepare_enable(gi2c->core_clk);
>> - if (ret)
>> - return ret;
>> -
>> - ret = geni_se_resources_on(&gi2c->se);
>> - if (ret) {
>> - dev_err_probe(dev, ret, "Error turning on resources\n");
>> - goto err_clk;
>> - }
>> - proto = geni_se_read_proto(&gi2c->se);
>> - if (proto == GENI_SE_INVALID_PROTO) {
>> - ret = geni_load_se_firmware(&gi2c->se, GENI_SE_I2C);
>> - if (ret) {
>> - dev_err_probe(dev, ret, "i2c firmware load failed ret: %d\n", ret);
>> - goto err_resources;
>> - }
>> - } else if (proto != GENI_SE_I2C) {
>> - ret = dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
>> - goto err_resources;
>> - }
>> -
>> - if (desc && desc->no_dma_support)
>> - fifo_disable = false;
>> - else
>> - fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE;
>> -
>> - if (fifo_disable) {
>> - /* FIFO is disabled, so we can only use GPI DMA */
>> - gi2c->gpi_mode = true;
>> - ret = setup_gpi_dma(gi2c);
>> - if (ret)
>> - goto err_resources;
>> -
>> - dev_dbg(dev, "Using GPI DMA mode for I2C\n");
>> - } else {
>> - gi2c->gpi_mode = false;
>> - tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se);
>> -
>> - /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */
>> - if (!tx_depth && desc)
>> - tx_depth = desc->tx_fifo_depth;
>> -
>> - if (!tx_depth) {
>> - ret = dev_err_probe(dev, -EINVAL,
>> - "Invalid TX FIFO depth\n");
>> - goto err_resources;
>> - }
>> -
>> - gi2c->tx_wm = tx_depth - 1;
>> - geni_se_init(&gi2c->se, gi2c->tx_wm, tx_depth);
>> - geni_se_config_packing(&gi2c->se, BITS_PER_BYTE,
>> - PACKING_BYTES_PW, true, true, true);
>> -
>> - dev_dbg(dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth);
>> - }
>> -
>> - clk_disable_unprepare(gi2c->core_clk);
>> - ret = geni_se_resources_off(&gi2c->se);
>> - if (ret) {
>> - dev_err_probe(dev, ret, "Error turning off resources\n");
>> - goto err_dma;
>> - }
>> -
>> - ret = geni_icc_disable(&gi2c->se);
>> - if (ret)
>> - goto err_dma;
>> -
>> gi2c->suspended = 1;
>> pm_runtime_set_suspended(gi2c->se.dev);
>> pm_runtime_set_autosuspend_delay(gi2c->se.dev, I2C_AUTO_SUSPEND_DELAY);
>> pm_runtime_use_autosuspend(gi2c->se.dev);
>> pm_runtime_enable(gi2c->se.dev);
>>
>> + ret = geni_i2c_init(gi2c);
>> + if (ret < 0) {
>> + dev_err(gi2c->se.dev, "I2C init failed :%d\n", ret);
>> + pm_runtime_disable(gi2c->se.dev);
>> + goto err_dma;
>> + }
>> +
>> ret = i2c_add_adapter(&gi2c->adap);
>> if (ret) {
>> dev_err_probe(dev, ret, "Error adding i2c adapter\n");
>> @@ -1143,13 +1148,6 @@ static int geni_i2c_probe(struct platform_device *pdev)
>>
>> return ret;
>>
>> -err_resources:
>> - geni_se_resources_off(&gi2c->se);
>> -err_clk:
>> - clk_disable_unprepare(gi2c->core_clk);
>> -
>> - return ret;
>> -
>> err_dma:
>> release_gpi_dma(gi2c);
>>
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2025-11-28 6:22 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
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 [this message]
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=15a28ddc-9883-42d5-a008-b2ea22d8becc@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;
as well as URLs for NNTP newsgroup(s).