All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praveen Talari" <praveen.talari@oss.qualcomm.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 8/9] i2c: qcom-geni: Use common GENI resource initialization helper
Date: Thu, 27 Aug 2026 18:16:28 +0000	[thread overview]
Message-ID: <20260827181628.D8D811F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-derive_clk_perf_tbl_from_perf_domain_opp_table-v2-8-091697dbeb02@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] Severe performance overhead by executing heavy interconnect calls on every I2C transfer.
- [High] DMA channels allocated during `geni_i2c_init()` are leaked if subsequent probe steps fail.

Pre-existing issues:
- [High] PM runtime usage counter leak in `geni_i2c_xfer()` on `.set_rate()` failure.
- [High] Memory leak of multi-descriptor DMA buffer tracking arrays on transfer failure.
--

commit 70cf5551bb430cb5f179e24ea3c574d784037179
Author: Praveen Talari <praveen.talari@oss.qualcomm.com>

i2c: qcom-geni: Use common GENI resource initialization helper

The driver implements a custom resources_init() callback for clock
frequency validation and bandwidth vote programming. This commit moves
the clock validation to the probe function and programs the bandwidth
vote from qcom_geni_i2c_conf(). This allows the driver to use
geni_se_resources_init() directly.

> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> index a3b7609e3cf95..0b178701e1d1e 100644
> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> @@ -242,7 +242,9 @@ static int qcom_geni_i2c_conf(struct geni_se *se, unsigned long freq)
>  	trace_geni_i2c_bus_setup(gi2c->se.dev, gi2c->clk_freq_out,
>  				 itr->clk_div, itr->t_high_cnt,
>  				 itr->t_low_cnt, itr->t_cycle_cnt);
> -	return 0;
> +
> +	return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW,
> +				  Bps_to_icc(gi2c->clk_freq_out));
>  }

[Severity: High]
Does moving this interconnect vote to qcom_geni_i2c_conf() introduce a
regression that causes severe performance degradation?

Because this function is used as the .set_rate callback, it is invoked by
geni_i2c_xfer() on every single I2C message transfer. Executing an
interconnect vote unconditionally on every transfer forces expensive SoC
fabric updates constantly.

[Severity: High]
This is a pre-existing issue, but does a failure during the rate setting phase
leak the PM runtime usage counter?

If .set_rate() (which now includes the fallible interconnect vote) fails
during an I2C transfer, the error path in geni_i2c_xfer() returns directly:

drivers/i2c/busses/i2c-qcom-geni.c:geni_i2c_xfer() {
    ...
	ret = pm_runtime_get_sync(gi2c->se.dev);
    ...
	ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out);
	if (ret)
		return ret;
    ...
	pm_runtime_put_autosuspend(gi2c->se.dev);
    ...
}

Returning early here entirely skips the pm_runtime_put_autosuspend() call,
permanently preventing the device and its enclosing power domain from
suspending.

[ ... ]

> @@ -1199,6 +1183,11 @@ static int geni_i2c_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		return ret;
>  
> +	ret = geni_i2c_clk_map_idx(gi2c);
> +	if (ret)
> +		return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n",
> +				     gi2c->clk_freq_out);
> +
>  	ret = i2c_add_adapter(&gi2c->adap);
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Error adding i2c adapter\n");

[Severity: High]
Does this error path introduce a regression by leaking the DMA channels
allocated earlier in probe?

The geni_i2c_init() function successfully requests DMA channels via
setup_gpi_dma() before this point. If geni_i2c_clk_map_idx() fails here
(e.g., due to an invalid DT clock configuration), the probe function returns
the error directly, bypassing release_gpi_dma() and leaking the channels.

[ ... ]

[Severity: High]
This is a pre-existing issue, but is it possible for the multi-descriptor
DMA buffer tracking arrays to leak on transfer failure?

During multi-message transfers, geni_i2c_gpi_xfer() dynamically allocates
tracking arrays. If an error occurs (such as an I2C NACK from a target
device), the transfer loop terminates early. 

Inside the cleanup function geni_i2c_gpi_multi_desc_unmap():

drivers/i2c/busses/i2c-qcom-geni.c:geni_i2c_gpi_multi_desc_unmap() {
    ...
	for (; tx_multi_xfer->unmap_msg_cnt < msg_xfer_cnt; tx_multi_xfer->unmap_msg_cnt++) {
        ...
		if (tx_multi_xfer->unmap_msg_cnt == gi2c->num_msgs - 1) {
			kfree(tx_multi_xfer->dma_buf);
			kfree(tx_multi_xfer->dma_addr);
			break;
		}
	}
    ...
}

Because the error aborted the transfer early, msg_xfer_cnt is smaller than
num_msgs. The kfree() condition is never met, resulting in a permanent
memory leak of the kcalloc() allocated arrays.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-derive_clk_perf_tbl_from_perf_domain_opp_table-v2-0-091697dbeb02@oss.qualcomm.com?part=8

  reply	other threads:[~2026-08-27 18:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 17:59 [PATCH v2 0/9] soc: qcom: geni: Derive SE clock configuration from OPP table on SA8255P Praveen Talari
2026-08-27 17:59 ` [PATCH v2 1/9] pmdomain: arm: Fix -EINVAL from scmi_pd_set_perf_state() on state 0 Praveen Talari
2026-08-27 18:16   ` sashiko-bot
2026-09-01 14:31   ` Ulf Hansson
2026-08-27 17:59 ` [PATCH v2 2/9] soc: qcom: geni-se: Populate clk_perf_tbl with SE source clock frequencies from perf OPP table Praveen Talari
2026-08-27 18:16   ` sashiko-bot
2026-10-07  7:24   ` Mukesh Savaliya
2026-08-27 17:59 ` [PATCH v2 3/9] soc: qcom: geni-se: Add helper to set SE clock rate via OPP Praveen Talari
2026-08-27 18:14   ` sashiko-bot
2026-09-04  9:01   ` Konrad Dybcio
2026-08-27 17:59 ` [PATCH v2 4/9] soc: qcom: geni-se: Remove OPP rate reset from resource deactivation Praveen Talari
2026-08-27 18:14   ` sashiko-bot
2026-09-04  8:49   ` Konrad Dybcio
2026-09-11 17:13     ` Praveen Talari
2026-10-07  8:51   ` Mukesh Savaliya
2026-08-27 17:59 ` [PATCH v2 5/9] serial: qcom-geni: Use geni_se_set_rate() for source clock configuration Praveen Talari
2026-08-27 18:12   ` sashiko-bot
2026-10-08  7:35   ` Mukesh Savaliya
2026-08-27 17:59 ` [PATCH v2 6/9] spi: qcom-geni: Use geni_se_set_rate() for setting source clock frequency Praveen Talari
2026-08-27 18:12   ` sashiko-bot
2026-10-08 19:45   ` Mukesh Savaliya
2026-08-27 17:59 ` [PATCH v2 7/9] i2c: qcom-geni: Vote for SE clock rate using OPP Praveen Talari
2026-08-27 18:11   ` sashiko-bot
2026-09-04  8:52   ` Konrad Dybcio
2026-09-11 17:42     ` Praveen Talari
2026-08-27 17:59 ` [PATCH v2 8/9] i2c: qcom-geni: Use common GENI resource initialization helper Praveen Talari
2026-08-27 18:16   ` sashiko-bot [this message]
2026-08-27 17:59 ` [PATCH v2 9/9] i2c: qcom-geni: Use geni_se_set_rate() for setting source clock frequency Praveen Talari
2026-08-27 18:25   ` sashiko-bot
2026-09-01 14:52 ` [PATCH v2 0/9] soc: qcom: geni: Derive SE clock configuration from OPP table on SA8255P Ulf Hansson
2026-09-01 16:48   ` Praveen Talari
2026-09-04  7:56     ` Ulf Hansson
2026-09-04  9:00       ` Konrad Dybcio
2026-09-11 17:33         ` Praveen Talari
2026-09-22 13:06           ` Konrad Dybcio
2026-09-28  8:59             ` Praveen Talari
2026-09-09  6:32       ` 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=20260827181628.D8D811F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=praveen.talari@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.