Linux Serial subsystem development
 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 v3 5/8] spi: qcom-geni: Use geni_se_set_rate() for setting source clock frequency
Date: Thu, 15 Oct 2026 13:09:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-172900@kernel.org> (raw)
In-Reply-To: <20261015-derive_clk_perf_tbl_from_perf_domain_opp_table-v3-5-5da1096243c9@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] pm: spi_geni_runtime_suspend() desynchronizes PM state if geni_se_set_rate() fails
- [Medium] pm: spi_geni_runtime_resume() leaks clock/power resources on geni_se_set_rate() error
--

commit 18dd7909ccc7f7c6dc80af1c7154961b4692ab24
Author: Praveen Talari <praveen.talari@oss.qualcomm.com>

spi: qcom-geni: Use geni_se_set_rate() for setting source clock frequency

On the SA8255P platform there is no Linux clock handler for the SE
source clock, so the driver has no way to look up the source clock
index and divider needed to fill the GSI CONFIG0 TRE for a requested
transfer frequency. To work around this, firmware instead exposes the
SE HW supported source clock frequencies as OPPs on the perf domain
device.

> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index 91e75e213f929..cbccd6d8689ab 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
[ ... ]
> @@ -1248,9 +1246,14 @@ static int spi_geni_runtime_suspend(struct device *dev)
>  {
>  	struct spi_controller *spi = dev_get_drvdata(dev);
>  	struct spi_geni_master *mas = spi_controller_get_devdata(spi);
> +	int ret;
> +
> +	ret = mas->dev_data->power_off ?
> +	      mas->dev_data->power_off(&mas->se) : 0;
> +	if (ret)
> +		return ret;
>  
> -	return mas->dev_data->power_off ?
> -	       mas->dev_data->power_off(&mas->se) : 0;
> +	return geni_se_set_rate(&mas->se, 0);
>  }

[Severity: High]
Does this desynchronize the PM state if geni_se_set_rate() fails?

If mas->dev_data->power_off() successfully powers off the device (disabling
clocks, interconnects, etc.), but geni_se_set_rate() subsequently fails and
returns a negative error code, the PM core will abort the suspend transition
and leave dev->power.runtime_status as RPM_ACTIVE.

Since the PM core considers the device active, will subsequent operations
bypass the pm_runtime_get_sync() resume path and directly access hardware
registers while the clocks are actually disabled, potentially leading to an
unclocked access exception?

Could the error from geni_se_set_rate() be ignored or handled gracefully,
or should geni_se_set_rate(0) be called before power_off()?

>  static int spi_geni_runtime_resume(struct device *dev)
> @@ -1265,10 +1268,7 @@ static int spi_geni_runtime_resume(struct device *dev)
>  			return ret;
>  	}
>  
> -	if (mas->se.has_opp)
> -		return dev_pm_opp_set_rate(mas->dev, mas->cur_sclk_hz);
> -
> -	return 0;
> +	return geni_se_set_rate(&mas->se, mas->cur_sclk_hz);
>  }

[Severity: Medium]
Can this leak clock and power resources if geni_se_set_rate() fails?

If power_on() successfully enables the device clocks and interconnects, but
geni_se_set_rate() fails and returns an error, this function returns that
error directly without first calling power_off() to unwind the state.

The PM core will then mark the resume as failed and transition the device
state back to RPM_SUSPENDED, orphaning the active hardware resources.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-derive_clk_perf_tbl_from_perf_domain_opp_table-v3-0-5da1096243c9@oss.qualcomm.com?part=5

  reply	other threads:[~2026-10-15 13:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 12:58 [PATCH v3 0/8] soc: qcom: geni: Derive SE clock configuration from OPP table on SA8255P Praveen Talari
2026-10-15 12:58 ` [PATCH v3 1/8] soc: qcom: geni-se: Populate clk_perf_tbl with SE source clock frequencies from perf OPP table Praveen Talari
2026-10-15 13:10   ` sashiko-bot
2026-10-15 12:58 ` [PATCH v3 2/8] soc: qcom: geni-se: Add helper to set SE clock rate via OPP Praveen Talari
2026-10-15 13:06   ` sashiko-bot
2026-10-15 12:58 ` [PATCH v3 3/8] soc: qcom: geni-se: Remove OPP rate reset from resource deactivation Praveen Talari
2026-10-15 13:16   ` sashiko-bot
2026-10-15 12:58 ` [PATCH v3 4/8] serial: qcom-geni: Use geni_se_set_rate() for source clock configuration Praveen Talari
2026-10-15 13:15   ` sashiko-bot
2026-10-15 12:58 ` [PATCH v3 5/8] spi: qcom-geni: Use geni_se_set_rate() for setting source clock frequency Praveen Talari
2026-10-15 13:09   ` sashiko-bot [this message]
2026-10-15 12:58 ` [PATCH v3 6/8] i2c: qcom-geni: Vote for SE clock rate using OPP Praveen Talari
2026-10-15 12:58 ` [PATCH v3 7/8] i2c: qcom-geni: Use common GENI resource initialization helper Praveen Talari
2026-10-15 12:58 ` [PATCH v3 8/8] i2c: qcom-geni: Use geni_se_set_rate() for setting source clock frequency 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=sashiko-outbox-172900@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox