From: sashiko-bot@kernel.org
To: "Praveen Talari" <praveen.talari@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
Date: Tue, 18 Aug 2026 13:48:04 +0000 [thread overview]
Message-ID: <20260818134805.2B1601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818-use_gpio_to_notify_master_of_spi_target_activity-v3-2-e1c9e0dabbda@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Masking of legitimate errors (such as -EPROBE_DEFER) from devm_gpiod_get_index_optional() breaks probe deferral.
- [High] A race condition between hardware transfer setup and completion can leave the target ready GPIO permanently asserted.
- [High] The target_gpio is manipulated from hard IRQ handlers and under spinlocks without verifying it is safe for atomic access.
- [Medium] The target ready GPIO is never asserted or deasserted when the controller operates in GENI_GPI_DMA mode.
--
--- Patch [2]: [PATCH v3 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity ---
commit 53485a3ab9e87d880b4b4561671fdbf7ecc3b9cf
Author: Praveen Talari <praveen.talari@oss.qualcomm.com>
spi: qcom-geni: Use GPIO to notify master of SPI target activity
This commit adds support for an optional ready GPIO to notify the SPI master
of target activity. The GPIO is asserted when a transfer begins and deasserted
on completion or error.
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
[ ... ]
> @@ -938,8 +943,12 @@ static int spi_geni_transfer_one(struct spi_controller *spi,
> if (mas->cur_xfer_mode == GENI_SE_FIFO || mas->cur_xfer_mode == GENI_SE_DMA) {
> ret = setup_se_xfer(xfer, mas, slv->mode, spi);
> /* SPI framework expects +ve ret code to wait for transfer complete */
> - if (!ret)
> + if (!ret) {
> + if (spi->target && mas->target_gpio)
> + gpiod_set_value(mas->target_gpio, 1);
[Severity: High]
Is it possible for the hardware to complete the transfer and trigger the ISR
before this GPIO assertion occurs?
Since setup_se_xfer() drops the mas->lock spinlock before returning, a fast
SPI master or immediate hardware error could trigger the interrupt. If the ISR
runs first and deasserts the GPIO:
geni_spi_isr()
if (mas->cur_xfer) {
...
if (spi->target && mas->target_gpio)
gpiod_set_value(mas->target_gpio, 0);
}
Would this code then unconditionally overwrite the GPIO to 1, leaving it
permanently asserted and falsely signaling readiness to the master?
> + ret = 1;
> + }
> +
> return ret;
> }
> return setup_gsi_xfer(xfer, mas, slv, spi);
[Severity: Medium]
Does the target ready GPIO need to be managed when operating in GENI_GPI_DMA
mode?
If mas->cur_xfer_mode is GENI_GPI_DMA, this path is taken, bypassing the new
GPIO assertion logic entirely. Could this leave the external SPI master
waiting indefinitely for the readiness signal?
[ ... ]
> @@ -981,6 +990,8 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
> if (mas->cur_xfer) {
> spi_finalize_current_transfer(spi);
> mas->cur_xfer = NULL;
> + if (spi->target && mas->target_gpio)
> + gpiod_set_value(mas->target_gpio, 0);
[Severity: High]
Could this cause a scheduling while atomic panic if the GPIO assigned in the
device tree is behind a sleeping controller, such as an I2C or SPI expander?
The GPIO is requested during probe without checking gpiod_cansleep() to
explicitly reject sleeping GPIOs, and is being manipulated here directly
inside a hardirq handler.
[ ... ]
> @@ -1131,8 +1144,16 @@ static int spi_geni_probe(struct platform_device *pdev)
> init_completion(&mas->rx_reset_done);
> spin_lock_init(&mas->lock);
>
> - if (spi->target)
> + if (spi->target) {
> spi->target_abort = spi_geni_target_abort;
> + mas->target_gpio = devm_gpiod_get_index_optional(dev, "ready", 0,
> + GPIOD_OUT_LOW);
> + if (IS_ERR(mas->target_gpio)) {
> + dev_err(dev, "Failed to request GPIO: %ld\n",
> + PTR_ERR(mas->target_gpio));
> + mas->target_gpio = NULL;
> + }
[Severity: High]
Does this error handling block probe deferral?
By catching all errors from devm_gpiod_get_index_optional() and replacing them
with NULL, legitimate errors like -EPROBE_DEFER will be masked.
If the GPIO provider has not probed yet, will the SPI controller permanently
fail to acquire the GPIO for this boot rather than properly deferring?
> + }
>
> pm_runtime_use_autosuspend(&pdev->dev);
> pm_runtime_set_autosuspend_delay(&pdev->dev, 250);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-use_gpio_to_notify_master_of_spi_target_activity-v3-0-e1c9e0dabbda@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-08-18 13:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 13:38 [PATCH v3 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-08-18 13:38 ` [PATCH v3 1/2] spi: dt-bindings: Document ready-gpios property Praveen Talari
2026-08-18 13:38 ` [PATCH v3 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-08-18 13:48 ` sashiko-bot [this message]
2026-08-19 14:00 ` Konrad Dybcio
2026-08-19 16:42 ` 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=20260818134805.2B1601F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=praveen.talari@oss.qualcomm.com \
--cc=robh@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).